Hi. I'm not a developer, but work on Navision for my company. I understand that the Amount field on the Sales Header is not calculated until after the document is released from reading this forum.
I need to use this value prior to a document being released. I created a new flowfield on the Sales Header table and named it BookingsAmount. I then entered a calcformula to sum the Amount field from the Sales Line table. Unfortunately, I still do not get this value calculated when the doc status = Open. It is behaving exactly like the native Amount field as far as I can tell.
Thinking I had set up something incorrectly, I changed the calcformula to sum the outstanding amount (LCY) field instead, and that worked. Unfortunately, I do not want to use the Outstanding Amount (LCY) field because it is carrying tax amounts in it. I just want to quickly sum the line amount without tax and then copy that value to a bookings table we are using.
I watched the entire release process through debugger and failed to see any magic moment where the Amount field suddenly got calculated. In fact, at all points in the process, I verified that Amount was still showing "0."
a. What could I be doing wrong?
b. Is there anyway to get this to work?
kind of fell into this...
0
Comments
It does not require release.
http://www.BiloBeauty.com
http://www.autismspeaks.org
What you need to have done, is add two fields, "Calc. Line Amount" and "Calc. Amt. Inc. TAX", then take the code in codeunit 414 Release Sales Document, and fill these fields by using a tempSalesLine record looping through and calculating the values and copy them to your new fields in the live sales lines, without changing the way the base system works.
Codeunit 414 deals with Calc. Invoice Discount and Sales TAX.
You should use your reseller to achive what you want to do, as it involves some complicated coding and you have to commit the current sales line before the code would work properly.
David
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
Thanks for the advice!
On a side note, how is that flowfield structured so that it can only be calculated when the order is released? The field itself seems to be set up like any other flowfield that a properly placed CALCFIELD will work on...
The "Amount Including Tax" isn't calculated until release either that's why it's behaving the same.
It's adding a bunch of zeros.
You might try using the "Line Amount" field but you might have to set up another key using Line Amount as a sum index - I haven' tried it myself.
Try it in a test database - you should be able to do this. Let us know how it goes.
http://www.BiloBeauty.com
http://www.autismspeaks.org
I just had a look at the Line Amount field in version 4 W1
This would be ok to use providing you do not use the Invoice Discount functions, and non of your orders are marked as Prices Inc: VAT, the Invoice discount is only calculated on release.
Now comes the sting in the tail
1 - To add a flowfield to the header, you will have to add the Field to the Index SumIndexfield list.
2 - the line amount Includes VAT if the sales Header is flagged Prices Inc: VAT
So to be safe you do need 2 new Fields, "Calc. Line Amount", one added to the sales line and included as a sumIndexfield, the other your header flowfield, looking at the "Line Amount" Code, once you have added a new field, copy the code below.
Add this code in case the field was to be dropped on the form
Calc. Line Amount - OnValidate()
VALIDATE("Line Amount","Calc. Line amount");
Then look for the sales line function.
UpdateAmounts()
Add the code between
IF "Line Amount" <> xRec."Line Amount" THEN
"VAT Difference" := 0;
IF "Line Amount" <> ROUND(Quantity * "Unit Price",Currency."Amount Rounding Precision") - "Line Discount Amount" THEN BEGIN
"Line Amount" := ROUND(Quantity * "Unit Price",Currency."Amount Rounding Precision") - "Line Discount Amount";
"VAT Difference" := 0;
END;
// MOD REF - INITIALS - DATE
// + Sets the amount before Vat is Added
"Calc Line Amount" := "Line Amount";
// -
IF SalesHeader.Status = SalesHeader.Status::Released THEN
UpdateVATAmounts;
Thats All you need, but if you are using Invoice discounts then it is not to be used..... remember the flowfield editable = NO
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com
we decided to have our reseller put some code in that mimics the statistics form in calculating the amount of the order so that it can be written to the bookings table sans any taxes.
Thanks for the heads up about the VAT and invoice discount components of the sale. I will make sure i test that out thoroughly when our reseller gets back with the modifications to the codeunit that will take care of this for us.
David, I can get into table design but not the code. I can add fields and whatnot, but i can't get to the triggers behind the tables. That's what the developers are for!