📄 findpayment.bsh
字号:
/* * Copyright (C) 2006 Open Source Strategies, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */import java.util.*; import com.opensourcestrategies.financials.accounts.AccountsHelper;import org.ofbiz.base.util.*;import org.ofbiz.entity.*;import org.ofbiz.entity.condition.*;import org.ofbiz.accounting.util.*;import org.ofbiz.entity.util.*;parameters.put("headerItem","receivables");boolean findDisbursement = false;findPaymentTypeId = request.getParameter("findPaymentTypeId");if (findPaymentTypeId != null && findPaymentTypeId.equals("DISBURSEMENT")) { findDisbursement = true; parameters.put("headerItem","payables");}context.put("findDisbursement",findDisbursement);organizationPartyId = context.get("organizationPartyId");context.put("organizationPartyId",organizationPartyId);organizationParty = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", organizationPartyId));//get the list of paymentMethods, PaymentMethodTypes, paymentTypessupportedPaymentTypes = null;if (findDisbursement) { parameters.put("headerItem","payables"); paymentMethodList = organizationParty.getRelated("PaymentMethod", UtilMisc.toList("paymentMethodTypeId")); context.put("paymentMethodList",paymentMethodList); supportedPaymentTypes = UtilMisc.toList("CUSTOMER_REFUND", "VENDOR_PAYMENT", "VENDOR_PREPAY", "SALES_TAX_PAYMENT", "INCOME_TAX_PAYMENT", "PAYROLL_TAX_PAYMENT");} else { parameters.put("headerItem","receivables"); paymentMethodTypeList = delegator.findAllCache("PaymentMethodType", UtilMisc.toList("description")); context.put("paymentMethodTypeList",paymentMethodTypeList); supportedPaymentTypes = UtilMisc.toList("CUSTOMER_PAYMENT", "CUSTOMER_DEPOSIT");}paymentTypeList = delegator.findByAnd("PaymentType", UtilMisc.toList(new EntityExpr("paymentTypeId", EntityOperator.IN, supportedPaymentTypes))); // no _Cache version availablecontext.put("paymentTypeList", paymentTypeList);statusList = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", "PMNT_STATUS"));context.put("statusList", statusList);//possible fields we're searching bypartyIdFrom = parameters.get("partyIdFrom");partyIdTo = parameters.get("partyIdTo");paymentTypeId = parameters.get("paymentTypeId");paymentMethodId = parameters.get("paymentMethodId");paymentMethodTypeId = parameters.get("paymentMethodTypeId");paymentRefNum= parameters.get("paymentRefNum");statusId = parameters.get("statusId");fromDate = parameters.get("fromDate");thruDate = parameters.get("thruDate");paymentId = parameters.get("paymentId");if (paymentId != null && !paymentId.equals("")) { paymentValue = delegator.findByPrimaryKey("Payment",UtilMisc.toMap("paymentId",paymentId)); if (paymentValue != null) { context.put("payments",UtilMisc.toList(paymentValue)); return; } }//construct search conditionssearchConditions = new ArrayList();if (partyIdFrom != null && !partyIdFrom.equals("")) { searchConditions.add(new EntityExpr("partyIdFrom", EntityOperator.EQUALS, partyIdFrom));}if (partyIdTo != null && !partyIdTo.equals("")) { searchConditions.add(new EntityExpr("partyIdTo", EntityOperator.EQUALS, partyIdTo));}if (paymentTypeId != null && !paymentTypeId.equals("")) { searchConditions.add(new EntityExpr("paymentTypeId", EntityOperator.EQUALS, paymentTypeId));}if (findDisbursement) { if (paymentMethodId !=null && !paymentMethodId.equals("")) { searchConditions.add(new EntityExpr("paymentMethodId", EntityOperator.EQUALS, paymentMethodId)); }} else { if (paymentMethodTypeId !=null && !paymentMethodTypeId.equals("")) { searchConditions.add(new EntityExpr("paymentMethodTypeId", EntityOperator.EQUALS, paymentMethodTypeId)); }}if (paymentRefNum != null && !paymentRefNum.equals("")) { // make sure the look up is case insensitive searchConditions.add(new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("paymentRefNum")), EntityOperator.LIKE, paymentRefNum.toUpperCase() + "%"));}if (statusId != null && !statusId.equals("")) { searchConditions.add(new EntityExpr("statusId", EntityOperator.EQUALS, statusId));}if (!UtilValidate.isEmpty(fromDate)) { searchConditions.add(new EntityExpr("effectiveDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));}if (!UtilValidate.isEmpty(thruDate)) { searchConditions.add(new EntityExpr("effectiveDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate));}if (searchConditions.size() > 0){ entityConditionList = new EntityConditionList(searchConditions, EntityOperator.AND); List payments = delegator.findByCondition("Payment", entityConditionList, null, null); // payment list to use in form-widgets context.put("payments", payments);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -