[
https://issues.apache.org/jira/browse/OFBIZ-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12469577
]
Si Chen commented on OFBIZ-682:
-------------------------------
I think the problem would arise here:
Let's say you have an order for $50, $20 to be paid by billing account, $30 by
credit card.
When you create an invoice for $50, you wil have these records created:
- Invoice 10000 for $50
- Payment 10000, paymentMethodTypeId=BillingAccount,
- PaymentApplication for paymentId 10000, billingAccountId 10000, invoiceId
10000, amount $20
This is all good, but when you create a Payment to capture to the credit card,
you may end up with this:
- Payment 10001, paymentMethodTypeId=Credit Card
- PaymentApplication for paymentId 10001, invoiceId 10000, amount $30
This would be right, but if the PaymentApplication also had billingAccountId
10000, then that PaymentApplication would be counted as a use of the billing
account. Take a look at BillingAccountWorker methods for billing account
balances and you'll see what I mean.
If the code I mentioned is called then this would happen and it would be a bug.
I just verified a use case and this is indeed happening and causing a bug.
I also think the pattern of billingAccountId on OrderHeader and Invoice is
probably old and may be better to be replaced by a billingAccountId in
OrderPaymentPreference. It is not necessarily the case that an order and an
ivnoice must be associated with one and only one billing account. It would be
nice if a customer can use multiple store credits on an order, for example. We
do not have to re-factor this right now, but we should not be too strictly held
to it.
> Possibly dangerous code in createPaymentApplication for billingAccount
> ----------------------------------------------------------------------
>
> Key: OFBIZ-682
> URL: https://issues.apache.org/jira/browse/OFBIZ-682
> Project: OFBiz (The Open for Business Project)
> Issue Type: Bug
> Components: accounting
> Reporter: Si Chen
>
> This code is back in createPaymentApplication and could be potentially
> dangerous:
> <if-not-empty field-name="invoice.billingAccountId">
> <set field="paymentAppl.billingAccountId"
> from-field="invoice.billingAccountId"/>
> </if-not-empty>
> there could be problems with balance calculations when billing accounts and
> other methods are used to pay for orders.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.