January 13,2017
Hello everyone. I have completed the receivables module upgrade for my customer and did the thing I hate most but must do which is check my work. Typically I test my work as I go along but those test work on the norm rather than the exception. We all know in the business world exceptions happen all the time. So final testing try’s every possible scenario to insure total customer satisfaction.
When testing the calculation of total invoices in the list it initially worked fine because each selected invoice was of the same type. This customer has two pricing structures
- Parts
- Shop
In today’s test I selected both types in the invoice list and the calculation failed. If the first invoice in the list was a shop invoice then each successive invoice in the calculation calculated based on Shop cost. If the first invoice was Parts then the same error would occur based on Parts cost. To correct this I removed the calculation and simply added each Balance Due from the browse list of records. Here is the corrected code on the Verify Batch List button.
'Date Created: 12-Jan-2017 12:03:29 PM
'Last Updated: 12-Jan-2017 12:03:29 PM
'Created By : NLaws
'Updated By : NLaws
DIM SHARED records_found as N
records_found = topparent.queryrun("del_quote = .t.","","","No","Sales",.f.)
dim cnt as N
dim cmp as N
cnt = records_found
InvAmt = 0
cmp = 1
xbasic_wait_for_idle()
Sales_Workbook:browse5.Fetch_First()
xnext:
InvAmt = InvAmt + Sales_Workbook:browse5:baldue.value
cmp = cmp + 1
if cmp <= cnt then
Sales_Workbook:browse5.Fetch_Next()
goto xnext
end if
invttl.value = InvAmt
xBalDue = vCkTotal - invttl.value
if xBalDue = -.01 then
xBalDue = 0
end if
parentform.Refresh_Layout()
BalDue is still a calculated field and we still set our variable by adding the calculation for each record fetched. Now regardless of the invoice type the answer is correct.
The other routine I wanted to share with you is the finished batch posting.
'Date Created: 10-Aug-2011 02:39:38 PM
'Last Updated: 12-Jan-2017 12:09:13 PM
'Created By : cdc
'Updated By : NLaws
parentform.commit()
if xBalDue < 0 then
goto nocando
end if
on error goto oops
DIM SHARED records_found as N
records_found = topparent.queryrun("del_quote = .t.","","","No","Sales",.f.)
if records_found = 0 then
goto oops
end if
dim cnt as N
dim cmp as N
cnt = records_found
listSource = ""
InvAmt = 0
cmp = 1
Sales_Workbook:browse5.Fetch_First()
pr = table.open("pament records")
xnext:
if Sales_Workbook:browse5:amount_paid.text = " " then
Sales_Workbook:browse5:amount_paid.value = 0
end if
InvAmt = Sales_Workbook:browse5:baldue.value
Sales_Workbook:browse5:Amount_Paid.value = Sales_Workbook:browse5:amount_paid.value + Sales_Workbook:browse5:baldue.value
pr.enter_begin()
pr.date_paid = Var->xDate
pr.invoice_number = Sales_Workbook:browse5:invoice_no.value
pr.amount_paid = Var->InvAmt
pr.ontimediscount = Var->xDisc
pr.method_of_pay = Var->xMethod
pr.batch_number = Var->xBatchID
pr.check_or_ccd = Var->xCCDType
pr.check_number = Var->xCkNbr
pr.filled = Var->xOC
pr.enter_end(.t.)
cmp = cmp + 1
if cmp <= cnt then
Sales_Workbook:browse5.Fetch_Next()
goto xnext
end if
pr.close()
xbasic_wait_for_idle()
'perform cleanup
Sales_Workbook:browse5.Fetch_First()
xnext2:
Sales_Workbook:browse5:del_quote.value = .f.
Sales_Workbook:browse5:cleared.value = "Yes"
cmp = cmp - 1
if cmp >= 0 then
Sales_Workbook:browse5.Fetch_Next()
goto xnext2
end if
xbasic_wait_for_idle()
end
oops:
topparent.show_all()
ui_msg_box("Sorry", "Something went wrong. Please try again.")
end
nocando:
ui_msg_box("Sorry", "You do not have enough money to pay all selected Invoices. Please try again.")
I have added error checking to insure the records are posted correctly and that partial payments post correctly. Once the payment is posted to the sales table the software builds the detail automatically in the payment record table. Building a batch of fifty invoices to be paid as a test had a process time of less than one minute. Pretty good.
By using the table enter method for each record in the list, adding a new record happens in a nano second. If I would of used a high level append operation the process again would have run against all 80 thousand records and been too slow. If you are facing a similar issue, try this method it should work for you as well.
That’s all for today. If you are a business and need help with an Alpha Software program, contact us. Are rates are reasonable and our work is guaranteed.
Phone:713 417-6831
EMail: NLawson@cdc-takecharge.com
Leave a comment