My hope is that someone has some knowledge about how billing accounts are
supposed to work in the system.  Here is our scenario:

a) User creates an order and elects to pay with their billing account.  This
ultimately creates a completed order with an order payment preference of
typing EXT_BILLACT and status "PAYMENT_NOT_RECEIVED".  The status is the
result of logic that checks for payment method types that start with "EXT"
(deeming them external) and remarks that because it is external a
notification of receipt is required.

b) This completed order creates an invoice with the total amount due for the
customer.

c) Using the BillingAccountWorker one can invoke the
"getBillingAccountBalance" which effectively takes the account limit
subtracts any order payment preferences (to billing account, not
cancelled/rejected, payment not settled, receivd, declined, cancelled) and
adds any payment applications to the billing account that are not specific
tied to an invoice.

Ok so things look pretty good ... you have an outstanding order payment
perference which is reducing the available amount on the billing account and
the dude has an invoice to pay.

NOW -- here is the fun part ...

a) I go and create a payment and apply it to my invoice.  Invoice goes into
PAID status.
b) Money is not freed up under the billing account.  The chief reason here
is that the status on the order payment preference is still NOT_RECEIVED --
nothing goes to change this status.

QUESTION --

It seems to me the proper thing to do is when payments are applied to the
invoice (from an order under the billing account) that (if the full amount
is paid on the invoice) the order payment preference should be moved to
PAYMENT_RECEIVED status.  If only a partial is applied, then the order
payment preference should be split into two order payment preferences by the
amount being applied and the applied order payment perference should be
PAYMENT_RECEIVED with the other portion still awaiting ...

The other three options that I can come up with are ...

a) Change the billing account worker calculation to no longer exclude
billing account applications to invoices (this would add the applied amount
to the account balance, effectly netting out the amount subtracted from the
order).

b) Change the billing account worker to exclude completed orders from the
calculation and start including the outstanding amount on invoices tied to
the billing account.

c) Putting an exclude in for billing accounts so that their order payment
preferences are immediately marked as RECEIVED (but remain as is for all
other EXT* payment method types).

Does anyone have any knowledge around billing accounts and perhaps point me
in the proper direction.  For our internal project I am going to apply the
initial solution I suggested.  I am more than happy to contribute this back
if it makes sense, but if the business rules or my assumptions are incorrect
I would be more than happy to do something else.
-- 
View this message in context: 
http://n4.nabble.com/Paying-off-invoices-under-a-billing-account-tp1592863p1592863.html
Sent from the OFBiz - Dev mailing list archive at Nabble.com.

Reply via email to