sum of the Sales Line

dyn45
Member Posts: 67
hi to all,
I have a little problem here...
I am working with a form 42 Sales Order and I would like to add one field in the header which will show me the Invoice Amount (don't need in the table).
When I enter the Sales line, line by line, the new created field should be filled with the sum of all lines.
The field "Amount Including VAT" is not of use to me because it will not show the value until the document is shipped.
What is the best way to do this calculation?
I have a little problem here...
I am working with a form 42 Sales Order and I would like to add one field in the header which will show me the Invoice Amount (don't need in the table).
When I enter the Sales line, line by line, the new created field should be filled with the sum of all lines.
The field "Amount Including VAT" is not of use to me because it will not show the value until the document is shipped.
What is the best way to do this calculation?
0
Answers
-
Put a new field (a global and not a field in the table) on the subform. And in the OnAfterGetCurrentREcord-trigger, calculate the total. BTW : don't use "rec" but use a new variable to do it.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
but probably this will update only , we try to select the record at the header level or refresh it ? {though I have not tried it}
Amount including vat is updated when the document is released./PDR0 -
thanx kriki, pri_1_ranjan...
I need this field just to see that amount as I entering the sales line, without releasing it.
could someone send me an code example with the calculation, still have problems...0 -
pri_1_ranjan wrote:but probably this will update only , we try to select the record at the header level or refresh it ? {though I have not tried it}
the code:recSalesLine.RESET; recSalesLine.SETCURRENTKEY("DOcument Type","Document No.","Line No."); recSalesLine.SETRANGE("Document Type","Document Type"); recSalesLine.SETRANGE("Document No.","Document No."); recSalesLine.CALCSUMS(Amount);
And put recSalesLine.Amount on the subform, but outside the tablebox and make it non-editable.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
yes. That is correct/PDR0
-
-
The fields for Amount and "Amount Including VAT" are 0 until the SIO or SO is posted.
I used something similar to this code after a user is finished doing entry to obtain the TOTAL before posting. We also write some of our orders to an intermediate database for WEB purposes so we needed to be able to obtain the TOTAL before posting. Simply put this in a button on the form, works just about the same as pressing 'F9' key.Sum("Sales Line"."Outstanding Amount (LCY)" WHERE (Document Type=FIELD(Document Type),Document No.=FIELD(No.)))
You might want to add a textbox and/or use it in a trigger in some way.Half-empy or half-full how do you view your database?
Thanks.0 -
emulsified wrote:The fields for Amount and "Amount Including VAT" are 0 until the SIO or SO is posted.
...
Those values are calculated what the Sales Order is released.There are no bugs - only undocumented features.0 -
thank you guys for your help...
emulsified, you were right. I can't use Amount and "Amount Including VAT".
could you explain your code, please, I am not quite sure that I understand it (still newbee). where should I put this code? How should I use this code with a textbox?
I would like not to use any buttons to CALC that field.0 -
click on a sales line->Tools-Designer
Select the table box and drag it up to create just enuf space at the bottom or top to fit a textbox.
View->Globals
-Add a function called CalcRunningTotal (or something)
-Add a Variable: recSalesLine-Record-Sales Line
Add this code to the function
CalcRunningTotal()recSalesLine.RESET; recSalesLine.SETCURRENTKEY("Document Type", "Document No.", "Line No."); recSalesLine.SETRANGE("Document Type", "Document Type"); recSalesLine.SETRANGE("Document No.","Document No."); recSalesLine.CALCSUMS("Line Amount");
Now add a textbox to the space created when moving up the Table Box.
Add to it's sourceExp: recSalesLine."Line Amount"
Make sure the property VertGlue is Bottom
It should look like this:
http://savatage99.googlepages.com/Textb ... bleBox.JPG
finally add
OnAfterGetCurrRecord()CalcRunningTotal;
0 -
Just noticed form 55 (Purch. Invoice Subform) has new functionality in NAV 5.0! 8)
Depending on boolean "Show Totals on Purch. Inv./CM." in the Purchase Setup form 55 shows the total of the lines like you want it in the Sales Order.
Maybe you could take a look how it's made and use same functionality for the sales order?
Tino Ruijs
Microsoft Dynamics NAV specialist0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions