⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createapplicationlist.bsh

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 BSH
字号:
/* * $Id: $ * * Copyright 2005-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 java.text.DateFormat;import java.text.*; delegator = request.getAttribute("delegator");invoiceId = request.getParameter("invoiceId");if (invoiceId == null)  invoiceId = context.get("invoiceId");if (invoiceId == null)  invoiceId = "null_in_createApplList.bsh";invoice = delegator.findByPrimaryKey("Invoice", UtilMisc.toMap("invoiceId", invoiceId));tabButtonItem = context.get("tabButtonItem");// find existing itemsArrayList invoiceItems = new ArrayList();  // to pass back to the screeen with payment applications addeddouble invoiceAmount = 0.00;double notAppliedAmount = 0.00;double appliedAmount = 0.00; // is the amoun the invoice is covered by a paymentif (invoice != null) {        // retrieve related applications with null itemnumber    invoiceAppl = null;                        // to retrieve items from database    invoiceAppls = delegator.findByAnd("PaymentApplication",         UtilMisc.toMap("invoiceId", invoiceId,"invoiceItemSeqId",null));    Iterator q = invoiceAppls.iterator();    while (q.hasNext())    {        invoiceAppl = q.next();        Map itemmap = new HashMap();        itemmap.put("invoiceId",invoiceId);        itemmap.put("invoiceItemSeqId",invoiceAppl.getString("invoiceItemSeqId"));        itemmap.put("total",InvoiceWorker.getInvoiceTotal(invoice));        itemmap.put("paymentApplicationId",invoiceAppl.getString("paymentApplicationId"));        itemmap.put("paymentId",invoiceAppl.getString("paymentId"));        itemmap.put("billingAccountId",invoiceAppl.getString("billingAccountId"));        itemmap.put("taxAuthGeoId",invoiceAppl.getString("taxAuthGeoId"));        itemmap.put("amountApplied",invoiceAppl.getDouble("amountApplied").doubleValue());        invoiceItems.add(itemmap);        appliedAmount += invoiceAppl.getDouble("amountApplied").doubleValue();    }    invoiceItemsDb = null;                        // to retrieve items from database    invoiceItemsDb = invoice.getRelated("InvoiceItem");    // create totals    Iterator i = invoiceItemsDb.iterator();    while (i.hasNext()) {        item = i.next();          double itemTotal = 0.00;          if (item.get("amount") != null) {              if (item.get("quantity") == null || item.getDouble("quantity").doubleValue() == 0.00) {                  itemTotal = item.getDouble("amount").doubleValue();              }              else {                  itemTotal = item.getDouble("amount").doubleValue() * item.getDouble("quantity").doubleValue();              }          }          invoiceAmount += itemTotal;                     // get relation payment applications for every item(can be more than 1 per item number)          paymentApplications = item.getRelated("PaymentApplication");          double applied = 0.00;          if (paymentApplications != null && paymentApplications.size() > 0)    {              Iterator p = paymentApplications.iterator();              while (p.hasNext())  {                  paymentApplication = p.next();                  Map itemmap = new HashMap();                  itemmap.putAll(item);                  itemmap.put("total",itemTotal);                  itemmap.put("paymentApplicationId",paymentApplication.getString("paymentApplicationId"));                  itemmap.put("paymentId",paymentApplication.getString("paymentId"));                  itemmap.put("amountApplied",paymentApplication.getDouble("amountApplied"));                  itemmap.put("billingAccountId",paymentApplication.getString("billingAccountId"));                  itemmap.put("taxAuthGeoId",paymentApplication.getString("taxAuthGeoId"));                  invoiceItems.add(itemmap);                  applied += paymentApplication.getDouble("amountApplied").doubleValue(); // to check if fully applied              }              appliedAmount += applied;          }          // create an extra line for input when not completely applied but not in the overview           if (tabButtonItem.equals("invoiceOverview") != true &&                       (paymentApplications == null || paymentApplications.size() == 0                       || (applied < itemTotal && appliedAmount < invoiceAmount)))    {                  Map itemmap = new HashMap();                  itemmap.putAll(item);                  itemmap.put("total",itemTotal);                  itemmap.put("paymentApplicationId","");                  itemmap.put("paymentId","");                  itemmap.put("amountApplied", NumberFormat.getInstance().format(itemTotal - applied));                  itemmap.put("billingAccountId","");                  itemmap.put("taxAuthGeoId","");                  invoiceItems.add(itemmap);          }          notAppliedAmount += itemTotal - applied; // subtract itemrelated applications    }    notAppliedAmount = invoiceAmount - appliedAmount; // subtract invoice related applications.}context.put("invoiceApplications",invoiceItems);context.put("invoice",invoice);context.put("invoiceId",invoiceId);context.put("invoiceAmount",NumberFormat.getInstance().format(invoiceAmount));context.put("appliedAmount",NumberFormat.getInstance().format(appliedAmount));context.put("notAppliedAmount",NumberFormat.getInstance().format(notAppliedAmount));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -