AnsweredAssumed Answered

Variables and looping scripts.

Question asked by TKnTexas on Aug 18, 2009
Latest reply on Aug 19, 2009 by mrvodka


Variables and looping scripts.


I am trying to create yet another work-around to our accounting system.  Except for one "little" quirk which I do not understand it is there. 


In our accounting system invoices with purchase orders are entered in the purchasing order module.  At the end of the session the PO batch is closed and updated.  The invoice batch information is moved to AP as if entered there, as invoices without POs are entered.  At the end of the day, all of the AP batches are posted.  


The reason for my work-around is that the PO invoices are being entered on one of three systems, but the AP process is going to be done on the corporate system.  I am taking the batch report that is printed and cleaning/extracting the data in Filemaker Pro 10 Advanced.


When reading the report every invoice has at least one GL Distribution amount (inventory) some have an additional amount for freight, and there is the possibility of a 3rd line of distribution (rare though it is).  


The report prints the invoice information on two or three lines.  If there is one distribution for the invoice, there is still line 2 as that is where the PO number is printed.  Each invoice is assigned a unique voucher number, which is the first characters of the first line of each invoice listing.  


I have set variables for voucher number, invoice number, invoice date, invoice amount and vendor number.  I go to the next record to set the PO Num variable, returning to the prior record.


In a loop I test is the voucher number = test.voucher number.  It will always test yes for the first record of each invoice.  I set the fields for each of the variables listed above.  Then go to the next record.  The test will fail for voucher number = test.voucher number since it is not listed on the second line of the invoice listing.  So I set all fields from the variables.  If there is a 3 line, it follows the same logic of the loop.  If it exists, line 3 only has a GL number and a distribution amount.


The failing is not in the LOOP, it is in the sub-script SET FIELDS.  InvoAmt is not getting set to anything.  I have put a calculation field to see if the text calculation provides the correct number, it does.  The set field script step is listed, in this step.  I kind of need the invoice amount for the rest of the project to work.


If someone can let me know how I paste the scripts for others to see on here, I will post that information.