[ 
http://issues.apache.org/jira/browse/OFBIZ-93?page=comments#action_12457698 ] 
            
Jacopo Cappellato commented on OFBIZ-93:
----------------------------------------

Please ignore my previous comment.
I think that the bast way to go is this (from a message I sent today to the dev 
list):

Right now the billingAccountId is stored in the OrderHeader, then propagated to 
the Invoice header and finally (with my last patch) to the PaymentApplications 
applied to the invoice.
However, in my opinion we can remove the billingAccountId field from the 
PaymentApplication entity because it is superfluous. We should instead add it 
to the Payment entity, in order to implement the ability to accept payments and 
associate them to a  billing account (before the invoices are created, for 
example).
Right now, if we need to store a payment before the invoice is created and we 
want to associate it to a billing account we do the following:
1) we create a Payment
2) we create a PaymentApplication (for the same amount) and associate it to the 
billing account
In my opinion this is not completely correct, because we are not really 
applying a payment to something real like an invoice (we just need to associate 
it to the billing account); in fact, for example, the same payment could be 
used later to pay two different invoives associated to the billing account and 
so the original PaymentApplication entry would be wrong.

To summarize, here is what I propose:

a) remove the field PaymentApplication.billingAccountId
b) add the field Payment.billingAccountId
c) add the following constraint: a payment and an invoice associated to two 
different billing accounts cannot be matched; the application of a payment with 
null billingAccountId to an invoice associated to a billing account is ok
d) in the balance of a billing account we should simply consider:
d1) all the open amount of the invoices associated to the billing account (-)
d2) the unapplied amount of all the payments associated to the billing account



> Support BillingAcct + PaymentMethod for Payment
> -----------------------------------------------
>
>                 Key: OFBIZ-93
>                 URL: http://issues.apache.org/jira/browse/OFBIZ-93
>             Project: OFBiz (The Open for Business Project)
>          Issue Type: Improvement
>          Components: accounting
>            Reporter: Si Chen
>         Assigned To: Si Chen
>         Attachments: ofbiz-93.patch
>
>
> The requirement is that a customer be able to use a billing account plus 
> another form of payment, such as a credit card, for payment on an order.  The 
> billing account is to be used first.
> This would require the following changes:
> 1.  In PaymentGatewayServices.java captureOrderPayments method, if the 
> billing account has a positive balance, then first create a Payment of the 
> EXT_BILL_ACT type, then a PaymentApplication of amountApplied = min(billing 
> account balance, amount to capture.)  This PaymentApplication MUST have an 
> invoiceId which is already supplied as a parameter of the service.  
> (Otherwise, the billing account balance will go down by the 
> PaymentApplication.amountApplied)  If there is an amount left over to 
> capture, then amountToCapture = amountToCapture - billingAccountBalance.  We 
> can then loop through the OrderPaymentPreference to try to capture the 
> remaining amount.
> 2.   In BillingAccountWorker.getBillingAccountBalance, we need to replace 
> current code which just loops through all invoices which are not PAID or 
> CANCELLED and adds up their unpaid balances with new code which would find 
> all PaymentApplication for which there is a billingAccountId and add up the 
> amountApplied.  This must be done because otherwise, once an invoice has been 
> marked PAID, there would be no way to record that a portion of the billing 
> account has been used to pay that invoice and hence permanently decrease its 
> amount.
> On the mailing list we had discussed making the order of payment capture 
> configurable.  I can't think of an easy way to do this, however, with the 
> current data model.  I propose that for now we have PaymentGatewayServices 
> basically capture billing account first, then other payment methods, which is 
> a standard B2C process.  If you have a B2B customer who wants to pay with a 
> credit card, then use the accounting module to record a Credit Card payment 
> and apply it to the Billing Account to bring down its balance.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to