Converting Estimates into Invoices using a report action - Calculating Subtotals

Converting Estimates into Invoices using a report action - Calculating Subtotals

I am trying to create a report action or button to convert my estimate into an invoice.  I have everything working up it will not calculate the subtotal and grand total after it is converted.  Any help or suggestions would be appreciated!

Here is what I have so far...

invoice_id = insert into Create_Invoice
[
Added_User=zoho.loginuser
Grand_Total=input.Grand_Total
Deal_Number=input.Deal_Number
Contact=input.Contact
Deal_Name=input.Deal_Name
Phone=input.Phone
Email=input.Email
Installation_Address=input.Installation_Address
Account=input.Account
];
for each  estimate_row in input.Items
{
insert into Invoice_Line_Items_Subform
[
Added_User=zoho.loginuser
Invoice_Number=invoice_id
Price=estimate_row.Price
Item_Name=estimate_row.Item_Name
Unit=estimate_row.Unit
Quantity=estimate_row.Quantity
Amount=estimate_row.Amount
]
}
openUrl("#Report:All_Invoice_Report","same window");

Everything works to this point but it will not complete the calculation,

totalAmount = 0.0;
for each  item in Invoice_Line_Items_Subform
{
totalAmount = totalAmount + ifnull(item.Amount,0.0);
}
input.Sub_Total = totalAmount;
taxAmount = input.Tax / 100 * input.Sub_Total;
input.Grand_Total = input.Sub_Total + input.Tax_Amount - input.Discount1;
input.Tax_Amount = taxAmount;

    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方