AyaNova service management & work order software
AyaNova Support Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Field Calculations Expand / Collapse
Author
Message
Posted 8/6/2009 3:49:07 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior 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

     

  Post Attachments 
NRBC Purchase Order2.zip (1 view, 7.04 KB)

Post #4748
Posted 8/6/2009 9:51:29 AM
AyaNova Sales & Support

AyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & Support

Group: Administrators
Last Login: Yesterday @ 7:34:22 AM
Posts: 2,190, Visits: 5,029
Hi Ian

What you will want to do is keep a running total of the Net so that you can add it to the shipping and multiple it by 15%; and add the running total of the Net to the shipping as well as to the vat to get your PO total.

There are a number of running total examples:
http://forum.ayanova.com/FindPost4170.aspx
http://forum.ayanova.com/Topic3821-103-1.aspx?Highlight=running+total
http://forum.ayanova.com/FindPost2842.aspx
etc

I'll post again later with examples using a copy of your report template too

- Joyce

AyaNova Sales & Technical Support
http://www.ayanova.com
Post #4749
Posted 8/6/2009 3:52:53 PM
AyaNova Sales & Support

AyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova 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


  Post Attachments 
Copy of NRBC Purchase Order2.zip (3 views, 8.28 KB)
Post #4750
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: AyaNova Sales & Support

Permissions Expand / Collapse

All times are GMT -8:00, Time now is 9:34am

Powered by InstantForum.NET v4.1.4 © 2010
Execution: 0.031. 10 queries. Compression Disabled.