Author: ashish
Date: Thu Dec 20 14:52:11 2007 New Revision: 606046 URL: http://svn.apache.org/viewvc?rev=606046&view=rev Log: Applied patch from JIRA Issue # OFBIZ-1482. Thanks to Shubham Goyal for your patch. Thanks Mridul Pathak for understanding requirements in the right way and helping shubham in correcting it by useful comments. Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml?rev=606046&r1=606045&r2=606046&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml (original) +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml Thu Dec 20 14:52:11 2007 @@ -1618,4 +1618,70 @@ </if-compare> </simple-method> + <simple-method method-name="createAcctgTransForSalesInvoice" short-description="Create an accounting transaction for a sales invoice"> + <!-- retrieve ledger rounding properties --> + <property-to-field resource="arithmetic" property="ledger.decimals" field-name="ledgerDecimals"/> + <property-to-field resource="arithmetic" property="ledger.rounding" field-name="roundingMode"/> + <log level="info" message="Using ledger decimals [${ledgerDecimals}] and rounding [${roundingMode}]"/> + <set field="totalOrigAmount" value="0"/> + + <entity-one entity-name="Invoice" value-name="invoice"/> + <if-compare field-name="invoice.invoiceTypeId" value="SALES_INVOICE" operator="equals"> + <entity-and entity-name="InvoiceItem" list-name="invoiceItems"> + <field-map field-name="invoiceId" env-name="parameters.invoiceId" /> + </entity-and> + <iterate list-name="invoiceItems" entry-name="invoiceItem"> + <!-- TODO: handle serialized inventory --> + <if-empty field-name="invoiceItem.quantity"> + <set field="invoiceItem.quantity" value="1"/> + </if-empty> + <calculate field-name="origAmount" type="BigDecimal" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}"> + <calcop operator="multiply"> + <calcop operator="get" field-name="invoiceItem.quantity"/> + <calcop operator="get" field-name="invoiceItem.amount"/> + </calcop> + </calculate> + <calculate field-name="totalOrigAmount" type="BigDecimal" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}"> + <calcop operator="add"> + <calcop operator="get" field-name="totalOrigAmount"/> + <calcop operator="get" field-name="origAmount"/> + </calcop> + </calculate> + <!-- Credit --> + <make-value entity-name="AcctgTransEntry" value-name="creditEntry"/> + <set field="creditEntry.debitCreditFlag" value="C"/> + <set field="creditEntry.glAccountTypeId" from-field="invoiceItem.invoiceItemTypeId"/> + <set field="creditEntry.organizationPartyId" from-field="invoice.partyIdFrom"/> + <set field="creditEntry.productId" from-field="invoiceItem.productId"/> + <set field="creditEntry.origAmount" from-field="origAmount"/> + <set field="creditEntry.origCurrencyUomId" from-field="invoice.currencyUomId "/> + <set field="creditEntry.glAccountId" from-field="invoiceItem.overrideGlAccountId"/> + <if-not-empty field-name="invoiceItem.taxAuthPartyId"> + <set field="creditEntry.partyId" from-field="invoiceItem.taxAuthPartyId"/> + <set field="creditEntry.roleTypeId" value="TAX_AUTHORITY"/> + </if-not-empty> + </iterate> + + <!-- Debit --> + <make-value entity-name="AcctgTransEntry" value-name="debitEntry"/> + <set field="debitEntry.debitCreditFlag" value="D"/> + <set field="debitEntry.glAccountTypeId" value="ACCOUNTS_RECEIVABLE"/> + <set field="debitEntry.organizationPartyId" from-field="invoice.partyIdFrom"/> + <set field="debitEntry.origAmount" from-field="totalOrigAmount"/> + <set field="debitEntry.origCurrencyUomId" from-field="invoice.currencyUomId"/> + <set field="debitEntry.partyId" from-field="invoice.partyId"/> + <set field="debitEntry.roleTypeId" value="BILL_TO_CUSTOMER"/> + <set field="acctgTransEntries[]" from-field="creditEntry" type="Object"/> + <set field="acctgTransEntries[]" from-field="debitEntry" type="Object"/> + <set field="createAcctgTransAndEntriesInMap.glFiscalTypeId" value="ACTUAL"/> + <set field="createAcctgTransAndEntriesInMap.acctgTransTypeId" value="SALES_INVOICE"/> + <!--set field="createAcctgTransAndEntriesInMap.invoiceId" from-field="parameters.invoiceId"/--> + <set field="createAcctgTransAndEntriesInMap.acctgTransEntries" from-field="acctgTransEntries"/> + <call-service service-name="createAcctgTransAndEntries" in-map-name="createAcctgTransAndEntriesInMap"> + <result-to-field result-name="acctgTransId"/> + </call-service> + <field-to-result field-name="acctgTransId" result-name="acctgTransId"/> + </if-compare> + </simple-method> + </simple-methods> Modified: ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml?rev=606046&r1=606045&r2=606046&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml Thu Dec 20 14:52:11 2007 @@ -97,5 +97,14 @@ <condition field-name="oldStatusId" operator="not-equals" value="INVOICE_PAID"/> <action service="createAcctgTransForPurchaseInvoice" mode="sync"/> </eca> + + <!-- attemp to create AcctgTrans for Sales Invoice --> + <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> </service-eca> Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=606046&r1=606045&r2=606046&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Thu Dec 20 14:52:11 2007 @@ -453,4 +453,12 @@ <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/> </service> + <!-- An automatic GL Posting for Sales Invoice--> + <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> + </services> |
Free forum by Nabble | Edit this page |