Solved

Correct way to programmatically add records to Bill and Adjustment to get totals and taxes to work

  • 11 July 2023
  • 2 replies
  • 121 views

Userlevel 4
Badge

 

Hi,

 

I have spent a few hours trying to work out how to programmatically add lines to Bills and adjustments and get the totals and taxes to correctly calculate on the header.  The below shows a bill where the single line for $150 has been added programmatically.  

 

Note that the totals in the header are all Zero.  The below is what a manually keyed bill looks like with the same record (ie the answer I’m trying to get to)

A few comments on the first screen shot where the line has been programmatically added:

  • The totals in the header appear to be incrementally calculating.  For example if I change the price on the line from $150 to $160, the total shows the net difference from the original line added
  • There is no Tax detail

If I manually add a record here the taxes appear in the header correctly calculated (but the Detail Total and Balance is still incorrect)

I have tried programmatically adding record into APTaxTran before and after APTran but thus far have been unable to get the Bill to function properly.

 

In terms of my code, here is a cut down version of what I’m doing:

I have extended APInvoiceEntry.  Note, that the A,B,C,...G are just place holders for values calculated in my non-cut down version.

The above method is being called from here:

 

Thanks in advance for any help.

JOhn

 

 

 

icon

Best answer by Zoltan Febert 11 July 2023, 21:16

View original

2 replies

Userlevel 6
Badge +3

Hi @JWS539,

 

Please try this method:

        public APInvoice CreateBCTI(ARInvoice source)
{
var result = Base.CurrentDocument.Insert(new APInvoice
{
VendorID = A,
DueDate = B
});

var append = Base.Transactions.Insert(new APTran()
{
InventoryID = C,
Qty = D,
TranDesc = "description",
AccountID = E,
SubID = F,
CuryUnitCost = G
});
Base.Actions.PressSave();

return result;
}

 

Userlevel 4
Badge

Hi Zfebert56,

Thank you so much for taking the time to answer my question.  I can confirm that your solution works perfectly.  Initializing the APInvoice and APTran objects before inserting them is the answer (as opposed to inserting them to get a “blank” records and then setting the data which is how I had things).

 

Thanks for helping me out,

John.

 

 

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved