I am still new to Servoy. I am trying to write an Invoicing & Inventory System in multiuser environment using Servoy/MySql 5.0. Is there any sample up there that shown how to do updating transaction using Servoy method.
For examle
I have Invoice Header link to Invice Line Item thru unique invoice no.
After key in the master/details using portal, when user click the POST
button, I need to execute a mehtod that will update the followings:
Begin Transaction:-
Invoice Header Amount update to Customer Balance Amount.
Create a new ledager transction in Customer_Leader file.
Looping thru Invoice Line Item and updathe the follwing :
For each line item :
Search for Inventory Master File based on line item stock code
Update Inventory stock balance quantity.
Generate a new ledger transaction in Inventory_Ledager file
Loop
Update Invoice Header.status to POSTED.
CommitTransaction.
The Servoy CRM sample only show creating of Order/Order Detail but
not updating to diffrent files. Do I need to create form for every
transaction file and go to :-
Customer Form to update customer balance
Customer_Ledger Form to update Customer ledger transaction
Invenetory Master Form to update inventroy balance.
Inventory_Ledger Form to update inventory ledger transction.
and how to do it and the best way of doing it.
This is my first project in Servoy, I urgently need it to prove to my boss
thant Servoy is right tools to use intead of MS Visual Studio & FMP thant
the other team of programmer is using it.
There’s not really a need for “physically” going to every from to update fields.
Invoice Header Amount update to Customer Balance Amount.
Assuming your invoice has a customer_id, you can build a relation
orders_to_customers and do an update in a script attached to the invoice form
orders_to_customers.CustomerBalanceAmount = InvoiceHeaderAmount
(or += instead of =. >> not sure what the exact meaning is of these fields)
Update Inventory stock balance quantity.
Again use a relationship
lineitems_to _inventory(key =stockcode)
Looping thru Invoice Line Item and updathe the follwing :
For each line item :
Search for Inventory Master File based on line item stock code
Update Inventory stock balance quantity.
Generate a new ledger transaction in Inventory_Ledager file
Loop
Thanks in advance.
Well, I do something smiliar:
I have invoice line items that check availability of inventory when the invoice is created, then when it is posted, the inventory is updated. My inventory may come for one on three tables. Inventory values, balances and reorders levels are calculations that are updated by preforming a dave after executing a transaction:
What do is create a few global relationships, based in your product code.
Then as you loop through the invoice line items, populate your global field with the product code of the current line to establish your gloabal relationships.
Use the global realtionships to create records / transactions within your other tables.
There are many ways to do this, but this is one simple way to do it.
Here is another version. The product I deal with is books, 1000s of different titles.
My starting point is the transactions (lines) of the invoice. I create stock-documents (delivery notes) and stock-item records which reduce the stock. This way you can track stock levels historically.
forms.acc_stock_documents.controller.newRecord();
forms.acc_stock_documents.stock_document_acc_document_id = transaction_document_id;
forms.acc_stock_documents.stock_document_client_id = acc_transactions_to_documents.document_customer_id;
forms.acc_stock_documents.stock_document_date = new Date();
forms.acc_stock_documents.controller.saveData();
for ( var i = 1 ; i <= controller.getMaxRecordIndex() ; i++ )
{
var record = foundset.getRecord(i);
if(record.transaction_qty > 0) {
forms.acc_stock_item_list.controller.newRecord();
forms.acc_stock_item_list.stock_item_books_id = transaction_book_id;
forms.acc_stock_item_list.stock_item_document_id = forms.acc_stock_documents.stock_document_id;
forms.acc_stock_item_list.stock_item_qty = -transaction_qty;
forms.acc_stock_item_list.controller.saveData();
}
}
Do I need to to issue the acquireLock and releaseLock inside the
loop or the databaseManager.startTransaction and
databaseManager.commitTransacton is already applied the locking
automatically.