Just to verify this, I cleaned everything out to start from scratch. I used the Order-Order Entry module to make a sale for $100 + shipping and tax and quick shipped it. This was to a billing account.
I now have a single entry for OrderPaymentPreference of $100++ and paymentMethodId=EXT_BILLACT and statusId = PAYMENT_RECEIVED I have a single entry for PaymentApplication where amountApplied = $100++ and a billingAccountId and invoiceId. I call the service getBillingAccountBalance() in BillingAccountWorker and get returned $5000 when the account limit is $5000. It should have been $4900--. I added some logging to getBillingAccountBalance() and discovered that the OrderPaymentPreference was not subtracted because it was status PAYMENT_RECEIVED. PaymentApplication was also ignored because invoiceId != null. As expected, when I recorded a payment of $100++ on the account, I now have a $5100++ balance. Did I miss a step or is this logic in getBillingAccountBalance() wrong or should the order application have made a second posting to OrderPaymentPreferences. Maybe these billing accounts are not intended for Customer sales? Is OrderPaymentPreference maybe mis-named and should be OrderPayments? Any help understanding these issues would be appreciated. I am writing a real A/R application with aging and the like and want to keep it as clean and compatible with Ofbiz core code as possible. Skip
