2

このコードを使用して新しい請求書を作成しています。SOInvoiceEntry からカスタマイズを行います。デバッグしたところ、Revision ID is not empty というエラーが表示されました。customerID に値を設定すると、このコードは顧客の財務情報を取得できませんでした。これが私のコードです。ご協力ありがとうございました。

public PXAction<ARInvoice> preparePayment;

    [PXUIField(DisplayName = "Pay Invoice", Enabled = true)]
    [PXButton()]
    public IEnumerable PreparePayment(PXAdapter adapter)
    {
        List<ARRegister> doclist = new List<ARRegister>();
        SOOrderShipment soOrderShipment =
                     PXSelect
                         <SOOrderShipment,
                             Where<SOOrderShipment.invoiceNbr, Equal<Required<SOOrderShipment.invoiceNbr>>>
                             >.Select(new PXGraph(), Base.Document.Current.RefNbr);

        if (soOrderShipment != null)
        {
            SOOrder soOrder = PXSelect<SOOrder, Where<SOOrder.orderNbr,
                Equal<Required<SOOrder.orderNbr>>,
                And<SOOrder.orderType, Equal<Required<SOOrder.orderType>>>>>.Select(
                    new PXGraph(), soOrderShipment.OrderNbr, soOrderShipment.OrderType);
            SOOrderExt soExt = PXCache<SOOrder>.GetExtension<SOOrderExt>(soOrder);
            if (soExt.CustomerID != soExt.UsrARCustomer)
            {
                ARInvoiceEntry arInvoiceGraph = PXGraph.CreateInstance<ARInvoiceEntry>();
                ARInvoice invoice = (ARInvoice)arInvoiceGraph.Caches[typeof(ARInvoice)].CreateInstance();
                invoice = (ARInvoice) arInvoiceGraph.Caches[typeof (ARInvoice)].Insert(invoice);
                arInvoiceGraph.Caches[typeof(ARInvoice)].SetValue<ARInvoice.customerID>(invoice,soExt.UsrARCustomer);

                invoice.DocType = ARInvoiceType.DebitMemo;
                invoice.CustomerID = soExt.UsrARCustomer;
                //invoice.CustomerID = Base.Document.Current.CustomerID;
                Location location =
                    PXSelect<Location, Where<Location.bAccountID, Equal<Required<Location.bAccountID>>>>.Select(
                        arInvoiceGraph, soExt.UsrARCustomer);
                if(location!=null)
                       arInvoiceGraph.Caches[typeof(ARInvoice)].SetValue<ARInvoice.customerLocationID>(invoice, location.LocationID);
                arInvoiceGraph.Caches[typeof(ARInvoice)].SetValueExt<ARInvoice.docDate>(invoice, DateTime.Now);
                arInvoiceGraph.Caches[typeof(ARInvoice)].SetValue<ARInvoice.projectID>(invoice,location.CDefProjectID);

                ARInvoice oldInvoice = (ARInvoice)arInvoiceGraph.Caches[typeof(ARInvoice)].CreateCopy(invoice);

                invoice.CuryOrigDocAmt = 0;
                arInvoiceGraph.Caches[typeof(ARInvoice)].RaiseRowUpdated(invoice, oldInvoice);
                arInvoiceGraph.Caches[typeof(ARInvoice)].SetValue<ARInvoice.curyOrigDocAmt>(invoice, invoice.CuryDocBal);
                invoice.RefNoteID = 1;

                arInvoiceGraph.Caches[typeof(ARInvoice)].SetValueExt<ARInvoice.hold>(invoice, false);

                doclist.Add((ARInvoice)arInvoiceGraph.Caches[typeof(ARInvoice)].Current);
                arInvoiceGraph.Save.Press();

            }


        }

}

4

4 に答える 4

0

protected virtual void ARInvoice_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)ベース グラフの内部を見る限り、いくつかのエラー メッセージが表示されます"may not be empty"。RevisionID に関連するコードはありません。ARInvoiceしかし、DAC クラス、フィールドに RevisionID を持つコードがありますBillAddressID, BillContactID。この事実から、ARAddress の正しい ID を入力しARInvoiceているかどうかを確認し、データベース テーブル ARAddress の RevisionID 列に値があるかどうかを確認することをお勧めします。これは、ARAddress クラスの RevisionID が次のように宣言されているために必要です。

    [PXDBInt]
    [PXDefault]
    public virtual int? RevisionID
    {
      get
      {
        return this._RevisionID;
      }
      set
      {
        this._RevisionID = value;
      }
    }
于 2015-03-31T10:20:58.037 に答える