You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Paul Foxworthy (JIRA)" <ji...@apache.org> on 2018/02/08 22:26:00 UTC

[jira] [Commented] (OFBIZ-6722) Service createAcctgTransForPurchaseInvoice doesn't work as that I expected

    [ https://issues.apache.org/jira/browse/OFBIZ-6722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16357658#comment-16357658 ] 

Paul Foxworthy commented on OFBIZ-6722:
---------------------------------------

Hi [~kongrath] ,

Once again I find you're ahead of me looking into the mysteries of GL transactions in OFBiz. The thread at [http://ofbiz.135035.n4.nabble.com/Invoice-Item-type-copied-into-GL-Account-type-td4702167.html] discussed this issue. It is true that an invoice item type is being copied into a GL account type ([https://github.com/apache/ofbiz-framework/blob/trunk/applications/accounting/minilang/ledger/GeneralLedgerServices.xml#L2174).] 

That is sort-of fixed in getGlAccountFromAccountType:

<field-map field-name="invoiceItemTypeId" from-field="parameters.glAccountTypeId"/>

at [https://github.com/apache/ofbiz-framework/blob/trunk/applications/accounting/minilang/ledger/GeneralLedgerServices.xml#L533|https://github.com/apache/ofbiz-framework/blob/trunk/applications/accounting/minilang/ledger/GeneralLedgerServices.xml#L533,]

So you can think of the glAccountTypeId parameter as being overloaded, or if you like misnamed. For some transactions, it carries a GL account type, but for sales and purchase invoices, it has an invoice item type instead.

The fundamental problem is that the services to create accounting entries are building arrays of AcctgTransEntry records to pass to getGlAccountFromAccountType . getGlAccountFromAccountType needs more inputs, in particular the invoice item type, to make its decisions. Those inputs are not in AcctgTransEntry - its glAccount is set as the result of getGlAccountFromAccountType. So AcctgTransEntry is an output of getGlAccountFromAccountType.

The fix is to broaden the communication to getGlAccountFromAccountType. Possibilities I see are:
 # add an attribute to AcctgTransEntry for the invoice item type. I really don't like this idea. It's redundant, the invoice item type is only one input into getGlAccountFromAccountType's decision making, and many transactions are not sales and purchases and do not have invoice item types
 # Populate and pass a parallel array of additional data beside the AcctgTransEntry array. While other places in OFBiz do this, there's poor cohesion. I don't like this much either
 # Make the array into a simple array of maps, and not AcctgTransEntry GenericValues. Then we can add any extra inputs we like. There are some risks because we won't have the error checking on attribute you normally get from a GenericValue. I still think this is the best option.
 # Make sure getGlAccountFromAccountType can fetch and read the invoice item including its invoice item type, and not pass an invoice item type at all. I haven't investigated this, but it seems feasible and will probably be a smaller change than option 3. There would be a slight performance hit from re-fetching the invoice item.

What does everyone think?

Paul Foxworthy

 

> Service createAcctgTransForPurchaseInvoice doesn't work as that I expected
> --------------------------------------------------------------------------
>
>                 Key: OFBIZ-6722
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-6722
>             Project: OFBiz
>          Issue Type: Bug
>          Components: accounting
>    Affects Versions: Trunk
>            Reporter: Kongrath Suankaewmanee
>            Assignee: Paul Foxworthy
>            Priority: Major
>
> The problem, I want to link the glAccountId to the transaction when the status invoice has set to "Ready to Post" and the transaction will create automatically.
> Can someone help me to check or give the reason about createAcctgTransForPurchaseInvoice service, why we need to use this :
> <set field="debitEntry.glAccountTypeId" from-field="invoiceItem.invoiceItemTypeId"/>
> It looks very strange because glAccountTypeId and invoiceItemTypeId filed didn't link to each other.
> And how we can get the glAccountId for this simple-method?
> <simple-method method-name="getProductGlAccountInline" short-description="Gets ProductGlAccount on the basis of primary key" >
>         <entity-one entity-name="ProductGlAccount" value-field="productGlAccount" use-cache="true"/>
>     </simple-method>



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)