AnsweredAssumed Answered

Updating portal invoice records with new tax rate

Question asked by willrollo on Oct 14, 2013
Latest reply on Oct 15, 2013 by willrollo

Title

Updating portal invoice records with new tax rate

Post

     I have two layouts called Order  and invoice, both  based on the table - Invoicedetails. On this layout is a portal to my line items table, Invoicedetails_INVOICEITEM.

     The layouts look the same and the idea is to create an order by filling out the portal lines. When I convert this order to an Invoice the layout changes to Invoice and an invoice number is created. My questions is how do I add something to my Convert to invoice script that will update the invoice lines' totals is the tax rate changes from the point of order?

     So far I have a global VAT field called tax rate, but only effects newly created records. The Tax rate field on the layout does change but the actual figures in the poirtal do not unless I manually update them by altering the price.

     A copy of my script to convert order to invoice is below...Thank you

      

         
  •           #Has order been confirmed, Yes or No
  •      
  •           Set Variable [ $ORGINVID; Value:INVOICE DETAILS::ID_Invoice_pk ]
  •      
  •           Set Variable [ $DEPOSIT; Value:INVOICE DETAILS::Deposit Amount ]
  •      
  •           Set Variable [ $VAT; Value:invoicedetails_PREF::Tax Rate ]
  •      
  •            
  •      
  •           Show Custom Dialog [ Title: "Create Invoice"; Message: "Convert this order to an invoice? NOTE: This cannot be reversed!!"; Default Button: “Cancel”, Commit: “Yes”; Button 2: “Yes”, Commit: “No” ]
  •      
  •           If [ Get(LastMessageChoice)=1 ]
  •      
  •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Invoice_pk: “$ORGINVID” AND INVOICE DETAILS::Deposit raised: “Yes” ] [ Restore ]
  •      
  •           Go to Layout [ “Order” (INVOICE DETAILS) ]
  •      
  •           Exit Script [ ]
  •      
  •           End If
  •      
  •           #Isolate Record
  •      
  •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Invoice_pk: “$ORGINVID” AND INVOICE DETAILS::Deposit raised: “Yes” ] [ Restore ]
  •      
  •           Go to Layout [ “Invoices” (Invoices) ]
  •      
  •           New Record/Request
  •      
  •           Set Field [ Invoices::fk_Invoice details ID; $OrginvID ]
  •      
  •           Set Variable [ $Invoice Number; Value:Invoices::Invoice Number ]
  •      
  •           Set Variable [ $Invoice date; Value:Invoices::Invoice Date ]
  •      
  •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Invoice_pk: “$OrgInvID” AND INVOICE DETAILS::Type: “Order” ] [ Restore ]
  •      
  •           Go to Layout [ “Invoice” (INVOICE DETAILS) ]
  •      
  •           Set Field [ INVOICE DETAILS::fk_Invoice; Invoices::Invoice Number ]
  •      
  •           Set Field [ INVOICE DETAILS::fk_Invoice Date; Invoices::Invoice Date ]
  •      
  •           Set Field [ INVOICE DETAILS::Type; "Invoice" ]
  •      
  •           Set Field [ INVOICE DETAILS::Schedule Seat; "HAP" ]
  •      
  •           Freeze Window
  •      
  •           Go to Layout [ “Invoice Items” (invoicedetails_INVOICEITEM) ]
  •      
  •           New Record/Request
  •      
  •           Set Field [ invoicedetails_INVOICEITEM::ID_Invoice_fk; $OrginvID ]
  •      
  •           Set Field [ invoicedetails_INVOICEITEM::Item; "Dep" ]
  •      
  •           Set Field [ invoicedetails_INVOICEITEM::Description; "Less Deposit" ]
  •      
  •           Set Field [ invoicedetails_INVOICEITEM::Discountable; "" ]
  •      
  •           Set Field [ invoicedetails_INVOICEITEM::Price; -( 100 / ( 100 + $VAT ) ) * $Deposit ]
  •      
  •           Set Field [ invoicedetails_INVOICEITEM::Report; "Y" ]
  •      
  •           Commit Records/Requests
  •      
  •           Perform Find [ Specified Find Requests: Find Records; Criteria: INVOICE DETAILS::ID_Invoice_pk: “$ORGINVID” AND INVOICE DETAILS::Deposit raised: “Yes” ] [ Restore ]
  •      
  •           Go to Layout [ “Invoice” (INVOICE DETAILS) ]
  •      
  •           Set Field [ INVOICE DETAILS::Type; "Invoice" ]
  •      
  •           End If
  •      
  •           End If

      

Outcomes