我有一个例程来发布发票并过帐到在v6.1中可用的库存。我认为它也可以在2017R2中运行,但我不确定。它似乎在2018R1中根本不起作用。发票已下达,但未发布库存问题。自动化都设置为自动释放问题,并且在手动处理时可以工作。只有我的代码无法释放该问题。我不知道为什么。有什么想法吗?
================================================ ============
我已根据您的建议将代码更新为最新版本,但是库存问题仍未发布。
foreach (EDASNShipment asnShipment in PXSelect<EDASNShipment,
Where<EDASNShipment.aSNNbr, Equal<Required<EDASN.aSNNbr>>>>.Select(this, asn.ASNNbr))
{
soShipmentGraph.Clear();
SOShipment soShipment = soShipmentGraph.Document.Search<SOShipment.shipmentNbr>(asnShipment.ShipmentNbr);
var soShipmentExt = PXCache<SOShipment>.GetExtension<SOShipmentExt>(soShipment);
SOOrderShipment soOrderShipment = PXSelect<SOOrderShipment,
Where<SOOrderShipment.shipmentNbr, Equal<Required<SOOrderShipment.shipmentNbr>>>>.Select(this, asnShipment.ShipmentNbr);
ARInvoice arInvoice = PXSelect<ARInvoice, Where<ARInvoice.refNbr, Equal<Required<ARInvoice.refNbr>>,
And<ARInvoice.docType, Equal<Required<ARInvoice.docType>>>>>.Select(this, soOrderShipment.InvoiceNbr, "INV");
if (soShipment.Status != "C")
{
if (autoReleaseInvoices)
{
if (arInvoice != null)
{
/*
soInvoiceGraph.Clear();
soInvoiceGraph.Document.Current = arInvoice;
soInvoiceGraph.release.Press();
var a = new PXAdapter(soShipmentGraph.Document)
{
Searches = new object[] { soShipment.ShipmentNbr }
};
//Note: Post Invoice to IN is Action 3
a.Arguments.Add("actionID", 3);
a.MassProcess = false; //Don't pop up invoice screen
a.MaximumRows = 1;
PXLongOperation.StartOperation(this, () =>
{
foreach (SOShipment shipment in soShipmentGraph.action.Press(a))
{
shipment.ShipmentNbr = shipment.ShipmentNbr;
}
});
*/
//Release Invoice
PXLongOperation.StartOperation(this, delegate ()
{
soInvoiceGraph.Clear();
soInvoiceGraph.Document.Current = arInvoice;
soInvoiceGraph.release.Press();
//Update IN on Shipment
soShipmentGraph.Clear();
soShipmentGraph.Document.Current =
soShipmentGraph.Document.Search<SOShipment.shipmentNbr>(asnShipment.ShipmentNbr);
soShipmentGraph.UpdateIN.Press();
});
}
else
{
statusText += String.Format("Acumatica Invoice could not be located: {0} ", soOrderShipment.InvoiceNbr);
errorOccurred = true;
bolAtLeastOneError = true;
}
}
}
soShipmentGraph.Clear();
soShipment = soShipmentGraph.Document.Search<SOShipment.shipmentNbr>(asnShipment.ShipmentNbr);
soShipmentExt = PXCache<SOShipment>.GetExtension<SOShipmentExt>(soShipment);
soShipmentExt.UsrEDIStatus = "S"; //Sent
soShipmentGraph.Document.Update(soShipment);
soShipmentGraph.Persist();
}
答案 0 :(得分:0)
您可以参考下面的代码并修改您的代码
using System.Collections;
using PX.Data;
using PX.Objects.AR;
using PX.Objects.SO;
namespace PXDemoPkg
{
public class SOShipmentEntryPXExt : PXGraphExtension<SOShipmentEntry>
{
public PXAction<SOShipment> DummyCustomAction;
[PXButton()]
[PXUIField(DisplayName = "Dummy Custom Action",
MapEnableRights = PXCacheRights.Select,
MapViewRights = PXCacheRights.Select)]
protected virtual IEnumerable dummyCustomAction(PXAdapter adapter)
{
SOShipment shipment = Base.Document.Current;
SOOrderShipment soOrderShipment = PXSelect<SOOrderShipment,
Where<SOOrderShipment.shipmentNbr, Equal<Required<SOOrderShipment.shipmentNbr>>>>.
Select(Base, shipment.ShipmentNbr);
ARInvoice arInvoice = PXSelect<ARInvoice, Where<ARInvoice.refNbr, Equal<Required<ARInvoice.refNbr>>,
And<ARInvoice.docType, Equal<Required<ARInvoice.docType>>>>>.
Select(Base, soOrderShipment.InvoiceNbr, "INV");
PXLongOperation.StartOperation(Base, delegate ()
{
SOInvoiceEntry soInvoiceGraph = PXGraph.CreateInstance<SOInvoiceEntry>();
SOShipmentEntry soShipmentGraph = PXGraph.CreateInstance<SOShipmentEntry>();
//Release Sales Invoice
soInvoiceGraph.Clear();
soInvoiceGraph.Document.Current = soInvoiceGraph.Document.Search<ARInvoice.docType, ARInvoice.refNbr>(arInvoice.DocType, arInvoice.RefNbr);
soInvoiceGraph.release.Press();
//Update IN on Shipment
soShipmentGraph.Clear();
soShipmentGraph.Document.Current = soShipmentGraph.Document.Search<SOShipment.shipmentNbr>(shipment.ShipmentNbr);
soShipmentGraph.UpdateIN.Press();
});
return adapter.Get();
}
}
}
答案 1 :(得分:0)
大量浏览代码存储库后,我发现了一些用于发布问题的代码。我根据自己的情况进行了调整,并提出了以下可行的解决方案。如果有人遇到类似情况,我会发布它。
if (arInvoice != null)
{
//Release Invoice
PXLongOperation.StartOperation(this, delegate ()
{
soInvoiceGraph.Clear();
soInvoiceGraph.Document.Current = arInvoice;
soInvoiceGraph.release.Press();
//Lookup issue, add to list, and call release
INRegister issue = PXSelect<INRegister,
Where<INRegister.sOShipmentNbr, Equal<Required<INRegister.sOShipmentNbr>>,
And<INRegister.docType, Equal<Required<INRegister.docType>>>>>
.Select(this, asnShipment.ShipmentNbr, INDocType.Issue);
//Check setup flag and issue status
if (sosetup.Current.AutoReleaseIN == true &&
issue.Hold == false &&
issue.Released == false)
{
List<INRegister> issues = new List<INRegister>();
issues.Add(issue);
INDocumentRelease.ReleaseDoc(issues, false);
}
});
}