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

Jacopo Cappellato commented on OFBIZ-1144:
------------------------------------------

Rashko,

in my opinion, we can safely remove all the following code from 
InvoiceServices.updatePaymentApplicationDefBd  line 2381

if (paymentApplicationId == null) { 
    // when creating a new PaymentApplication, check if there is sufficient 
balance in the billing account, but only if the invoiceId is not null
    // If you create a PaymentApplication with both billingAccountId and 
invoiceId, then you're applying a billing account towards an invoice
    // If you create a PaymentApplication just with billingAccountId and no 
invoiceId, then you're adding value to billing account, so it should not matter
    // what the previous available balance is
    if (invoiceId != null) {
        if (billingAccountAvailableBalance.signum() < 0)  {
            errorMessageList.add(UtilProperties.getMessage(resource, 
"AccountingBillingAccountBalanceProblem",UtilMisc.toMap("billingAccountId",billingAccountId,
 "billingAccountAvailableBalance", billingAccountAvailableBalance, 
"isoCode",billingAccount.getString("accountCurrencyUomId")), locale));
        } else {
            // check here for too much application if a new record is
            // added (paymentApplicationId == null)
            if (amountApplied.compareTo(billingAccountApplyAvailable) == 1) {
                errorMessageList.add(UtilProperties.getMessage(resource, 
"AccountingBillingAccountLessRequested",
                                        
UtilMisc.toMap("billingAccountId",billingAccountId, 
                                            
"billingAccountApplyAvailable",billingAccountApplyAvailable,
                                            
"amountApplied",amountApplied,"isoCode",billingAccount.getString("accountCurrencyUomId")),locale));
            }
        }
    }
}


There is no reason to look at the billing account balance when we apply a 
payment to an invoice: it should always be possible with any balance.


> Payment applications problems
> -----------------------------
>
>                 Key: OFBIZ-1144
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1144
>             Project: OFBiz
>          Issue Type: Bug
>          Components: accounting
>            Reporter: Rashko Rejmer
>            Assignee: Jacopo Cappellato
>            Priority: Minor
>         Attachments: payment_applications.patch, payment_applications.patch
>
>
> Due to http://www.nabble.com/Question-about-Billing-Accounts-tf4056081.html
> Problems that occur:
>  1. When we apply payment to another payment there is a worng checking if the 
> sender of the one payment is
>       the same as the receiver of the other one.
>  2. Wnen we try to assign a payment to an invoice that is assigned to the 
> billing account, the payment application is not automatically assigned to the 
> billing account.
>  3. When the payment is assigned to billing account wrong available amount 
> method is invocated.
>  4. When the amount of the payment to the billing account is changed  - the 
> new unassigned amount is calculated wrongly. 
>  
> This patch should fix the problem.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to