|
Hi all,
I am currently using a git copy of Ofbiz. But upon testing the accounting AR, I encountered an error. I tested both the existing payment and my own created payment. I changed the status to Received. Then upon after changing status with 'Confirmed', I see error "Status cannot be set to 'Confirmed', the payment is not fully applied!" As I debug, I logged that setPaymentStatus Minilang method. I noticed that to change the status to confirmed needs to have invoice ID for the payment_application table. Meaning it seems that the checker assert that a payment needs to be filling the invoice amount. But what if I am creating a payment that is cash and not derived from an invoice. This is were I encounter the error. Please see below where the error is catched: <if-compare field="parameters.statusId" operator="equals" value="PMNT_CONFIRMED"> <log level="info" message="Logging inside status if PMNT_CONFIRMED ----->>>"/> <set field="notYetApplied" value="${groovy:org.apache.ofbiz.accounting.payment.PaymentWorker.getPaymentNotApplied(payment)}"/> <if-compare field="notYetApplied" operator="greater" value="0.00" type="BigDecimal"> <add-error> <fail-property resource="AccountingUiLabels" property="AccountingPSNotConfirmedNotFullyApplied"/> </add-error> <log level="error" message="See ${notYetApplied}... Cannot change from ${payment.statusId} to ${parameters.statusId}, payment not fully applied: ${notYetapplied}"/> <check-errors/> </if-compare> </if-compare> I traced the method being called: /** * Method to return the total amount of a payment which is applied to a payment * @param payment GenericValue object of the Payment * @param actual false for currency of the payment, true for the actual currency * @return the applied total as BigDecimal in the currency of the payment */ public static BigDecimal getPaymentApplied(GenericValue payment, Boolean actual) { BigDecimal paymentApplied = BigDecimal.ZERO; List<GenericValue> paymentApplications = null; try { List<EntityExpr> cond = UtilMisc.toList( EntityCondition.makeCondition("paymentId", EntityOperator.EQUALS, payment.getString("paymentId")), EntityCondition.makeCondition("toPaymentId", EntityOperator.EQUALS, payment.getString("paymentId")) ); EntityCondition partyCond = EntityCondition.makeCondition(cond, EntityOperator.OR); paymentApplications = payment.getDelegator().findList("PaymentApplication", partyCond, null, UtilMisc.toList("invoiceId", "billingAccountId"), null, false); if (UtilValidate.isNotEmpty(paymentApplications)) { for (GenericValue paymentApplication : paymentApplications) { BigDecimal amountApplied = paymentApplication.getBigDecimal("amountApplied"); // check currency invoice and if different convert amount applied for display if (actual.equals(Boolean.FALSE) && paymentApplication.get("invoiceId") != null && payment.get("actualCurrencyAmount") != null && payment.get("actualCurrencyUomId") != null) { GenericValue invoice = paymentApplication.getRelatedOne("Invoice", false); if (payment.getString("actualCurrencyUomId").equals(invoice.getString("currencyUomId"))) { amountApplied = amountApplied.multiply(payment.getBigDecimal("amount")).divide(payment.getBigDecimal("actualCurrencyAmount"),new MathContext(100)); } } paymentApplied = paymentApplied.add(amountApplied).setScale(decimals,rounding); } } } catch (GenericEntityException e) { Debug.logError(e, "Trouble getting entities", module); } return paymentApplied; } |
|
Sorry I found out also the answer. Clicking the 'Confirmed' item throws error because it's needing the invoice ID or the payment ID which can be set in the 'APPLICATIONS' item or tab first. There I should specify the invoice ID or the payment ID. Once specified, I can now click 'Status to CONFIRMED'.
If you have a OFBiz Accounting Demo video link, then it's better to know first because I am trying to learn more on the workflow. So this issue is close. |
| Free forum by Nabble | Edit this page |
