Implement an automatic GL posting service for sales invoices ------------------------------------------------------------
Key: OFBIZ-1482 URL: https://issues.apache.org/jira/browse/OFBIZ-1482 Project: OFBiz Issue Type: Sub-task Components: accounting Affects Versions: SVN trunk Reporter: Jacopo Cappellato Name of the service: "createAcctgTransForSalesInvoice" or similar Service definition: <service name="createAcctgTransForSalesInvoice" engine="simple" auth="true" location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForSalesInvoice"> <description>Create an accounting transaction for a sales invoice</description> <attribute name="invoiceId" type="String" mode="IN" optional="false"/> <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/> </service> The eca rule will be: <eca service="setInvoiceStatus" event="commit"> <condition field-name="invoiceId" operator="is-not-empty"/> <condition field-name="statusId" operator="equals" value="INVOICE_READY"/> <condition field-name="oldStatusId" operator="not-equals" value="INVOICE_READY"/> <condition field-name="oldStatusId" operator="not-equals" value="INVOICE_PAID"/> <action service="createAcctgTransForSalesInvoice" mode="sync"/> </eca> This is the general description: this service will call the createAcctgTransAndEntries with the following input parameters: a) acctgTransTypeId="SALES_INVOICE" b) partyId = invoice.partyId c) roleTypeId = "BILL_TO_CUSTOMER" d) invoiceId = invoice.invoiceId e) acctgTransEntries: a list composed by the following AcctgTransEntry elements: e1) one element for each of the InvoiceItems; here is the content of each of these elements: -- debitCreditFlag = C -- organizationPartyId = invoice.partyIdFrom -- productId = invoiceItem.productId -- glAccountTypeId = invoiceItem.invoiceItemTypeId -- glAccountId = invoiceItem.overrideGlAccountId -- origAmount = invoiceItem.quantity * invoiceItem.amount (NOTE: if quantity is not set, then default to 1) -- origCurrencyUomId = invoice.currencyUomId -- if invoiceItem.taxAuthPartyId is-not-empty then {partyId = invoiceItem.taxAuthPartyId and roleTypeId = "TAX_AUTHORITY"} f) one element for the invoice total (the sum of all the items' amount*quantity): -- debitCreditFlag = D -- organizationPartyId = invoice.partyIdFrom -- glAccountTypeId = ACCOUNTS_RECEIVABLE -- origAmount = the sum of all the items' amount*quantity -- origCurrencyUomId = invoice.currencyUomId -- partyId = invoice.partyId -- roleTypeId = "BILL_TO_CUSTOMER" Some more details about the logic: 1) get the Invoice record 2) if Invoice.invoiceTypeId != SALES_INVOICE return 3) get the InvoiceItems and iterate over them to create the entries (e) and compute the total for the entry for the total (f) 4) call the createAcctgTransAndEntries service Add information on the wiki page: http://docs.ofbiz.org/x/Qw0 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.