|
|
|
Junior Member
      
Group: Forum Members
Last Login: 1/4/2010 6:50:57 AM
Posts: 10,
Visits: 33
|
|
| Hi again..... I am so close to finishing my last report but can not get a simple calculation going. I have been experimenting with the beforeprint scripts etc but I am either missing something obvious or I just need to stop thinking that I know how to script. My dilemma is to provide accounts a printable purchase order, as per the attachment I have edited the report right to the point in which the totals are calculated. Your help would be gratefully appreciated. 1. The Parts Net Total and Shipping Totals are appearing ok. 2. I then need VAT to be calculated on (Parts Net Total & Shipping) and showed as a value 3. Subsequently all three (Parts Net+Shipping+VAT) would present a Grand Total Hopefully this makes sense.... VAT = (Parts Net Total + Shipping) x 15% xrLabel30 = (xrLabel16 + xrLabel31) x 15% Any assistance in getting into the right direction will be appreciated
|
|
|
|
|
AyaNova Sales & Support
      
Group: Administrators
Last Login: Yesterday @ 7:34:22 AM
Posts: 2,190,
Visits: 5,029
|
|
|
|
|
|
AyaNova Sales & Support
      
Group: Administrators
Last Login: Yesterday @ 7:34:22 AM
Posts: 2,190,
Visits: 5,029
|
|
| Hi again Ian I've attached a copy of your report template with the following: In reportHeaderBand1 OnBeforePrint to set the totals we will be using in this report: decimal NetTotal = 0; decimal CarriageTotal = 0; double dVATTotal = 0; decimal POTotal = 0;
In Detail1 band's OnBefore Print have the following: private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { //obtain what the Net is for this record decimal NetPrice = Convert.ToDecimal(Convert.ToDouble(DetailReport1.GetCurrentColumnValue("LT_UI_Label_NetValue"))); //Add that Net to the running NetTotal NetTotal += (NetPrice); }
In the xrLabel30 VAT data field OnBeforePrint: private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { //obtain the amount for shipping (in the event the custom field doesn't have anything, have to parse it out) decimal d = 0; decimal.TryParse(DetailReport.GetCurrentColumnValue("LT_PurchaseOrder_Label_Custom0").ToString(), out d); CarriageTotal = d; //Add this amount to the running total for the PO POTotal += CarriageTotal; //add the shipping to NetTotal decimal nt = (CarriageTotal + NetTotal); //declare the VAT % decimal vtp = Convert.ToDecimal(0.15); //obtain the VAT total and show it in the field and add it to the running POTotal dVATTotal = decimal.Multiply(nt, vtp); xrLabel30.Text = string.Format("{0:n2}", dVATTotal); POTotal += Convert.ToDecimal(dVATTotal); }
In the Total for the PO field's OnBeforePrint private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { //display the final running total for the PO xrLabel32.Text = string.Format("{0:c}", (POTotal + NetTotal)); }
And then finally to zero out for the next report in the event you are printing multiple PO's, the AfterPrint script: private void OnAfterPrint(object sender, System.EventArgs e) { NetTotal = 0; CarriageTotal = 0; dVATTotal = 0; POTotal = 0; }
I've attached a copy of the custom report template showing this for your benefit, as well as for others that may want to do something similar. Have a good weekend. - Joyce
- AyaNova Sales & Technical Support
- http://www.ayanova.com
|
|
|
|