【问题标题】:Release Invoice and Inventory Issue in code在代码中发布发票和库存问题
【发布时间】:2018-08-24 07:02:27
【问题描述】:

我有一个例行程序来发布发票并过帐到 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();
}

【问题讨论】:

    标签: c# acumatica


    【解决方案1】:

    你可以参考下面的代码并修改你的

    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();
            }
        }
    }
    

    【讨论】:

    • 查看上面的最新代码。库存问题仍未发布。其他一切都很好。发票被释放为未结状态,发货完成。
    【解决方案2】:

    在大量浏览代码存储库后,我找到了一些用于发布问题的代码。我根据我的情况对其进行了调整,并提出了以下可行的解决方案。我发布它以防其他人处于类似情况。

    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);
            }
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-07
      • 1970-01-01
      • 1970-01-01
      • 2012-05-06
      • 1970-01-01
      • 2015-06-04
      • 1970-01-01
      相关资源
      最近更新 更多