📄 listnotappliedinvoices.bsh
字号:
/* * $Id: $ * * Copyright 2001-2006 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. * *@author Hans Bakker h.bakker@antwebsystems.com */ import java.util.*;import org.ofbiz.entity.*;import org.ofbiz.base.util.*;import org.ofbiz.base.util.collections.*;import org.ofbiz.accounting.invoice.*;import org.ofbiz.accounting.payment.*;import org.ofbiz.accounting.util.UtilAccounting;import java.math.*;paymentId = parameters.get("paymentId");payment = delegator.findByPrimaryKey("Payment", UtilMisc.toMap("paymentId", paymentId));int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");// retrieve invoices for the related parties which have not been (fully) applied yetList invoices = delegator.findByAnd("Invoice", UtilMisc.toMap("partyId", payment.getString("partyIdFrom"), "partyIdFrom", payment.getString("partyIdTo")), UtilMisc.toList("invoiceDate")); if (invoices != null && invoices.size() > 0) { ArrayList invoicesList = new ArrayList(); // to pass back to the screeen list of unapplied invoices BigDecimal paymentApplied = PaymentWorker.getPaymentAppliedBd(payment); BigDecimal paymentToApply = payment.getBigDecimal("amount").setScale(decimals,rounding).subtract(paymentApplied); Iterator p = invoices.iterator(); while(p.hasNext()) { invoice = p.next(); BigDecimal invoiceAmount = InvoiceWorker.getInvoiceTotalBd(invoice).setScale(decimals,rounding); BigDecimal invoiceApplied = InvoiceWorker.getInvoiceAppliedBd(invoice).setScale(decimals,rounding); if (!invoiceAmount.equals(invoiceApplied) && !invoice.getString("statusId").equals("INVOICE_CANCELLED") && !invoice.getString("statusId").equals("INVOICE_IN_PROCESS")) { // put in the map BigDecimal invoiceToApply = invoiceAmount.subtract(invoiceApplied); Map invoiceMap = new HashMap(); invoiceMap.put("invoiceId",invoice.getString("invoiceId")); invoiceMap.put("amount",invoiceAmount); invoiceMap.put("invoiceDate", invoice.getString("invoiceDate").substring(0,10)); // display only YYYY-MM-DD invoiceMap.put("amountAlreadyApplied", invoiceApplied); if (paymentToApply.compareTo(invoiceToApply) < 0 ) { invoiceMap.put("amountToApply",paymentToApply); } else { invoiceMap.put("amountToApply", invoiceToApply); } invoicesList.add(invoiceMap); } } context.put("invoices",invoicesList);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -