Modified: ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?rev=708113&r1=708112&r2=708113&view=diff ============================================================================== --- ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java (original) +++ ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java Mon Oct 27 01:58:56 2008 @@ -434,8 +434,8 @@ createInvoiceItemContext.put("invoiceItemSeqId", invoiceItemSeqId); createInvoiceItemContext.put("invoiceItemTypeId", getInvoiceItemType(delegator, (orderItem == null ? null : orderItem.getString("orderItemTypeId")), (product == null ? null : product.getString("productTypeId")), invoiceType, "INV_FPROD_ITEM")); createInvoiceItemContext.put("description", orderItem.get("itemDescription")); - createInvoiceItemContext.put("quantity", new Double(billingQuantity.doubleValue())); - createInvoiceItemContext.put("amount", new Double(billingAmount.doubleValue())); + createInvoiceItemContext.put("quantity", billingQuantity); + createInvoiceItemContext.put("amount", billingAmount); createInvoiceItemContext.put("productId", orderItem.get("productId")); createInvoiceItemContext.put("productFeatureId", orderItem.get("productFeatureId")); createInvoiceItemContext.put("overrideGlAccountId", orderItem.get("overrideGlAccountId")); @@ -478,8 +478,8 @@ createOrderItemBillingContext.put("orderId", orderItem.get("orderId")); createOrderItemBillingContext.put("orderItemSeqId", orderItem.get("orderItemSeqId")); createOrderItemBillingContext.put("itemIssuanceId", itemIssuanceId); - createOrderItemBillingContext.put("quantity", new Double(billingQuantity.doubleValue())); - createOrderItemBillingContext.put("amount", new Double(billingAmount.doubleValue())); + createOrderItemBillingContext.put("quantity", billingQuantity); + createOrderItemBillingContext.put("amount", billingAmount); createOrderItemBillingContext.put("userLogin", userLogin); if ((shipmentReceipt != null) && (shipmentReceipt.getString("receiptId") != null)) { createOrderItemBillingContext.put("shipmentReceiptId", shipmentReceipt.getString("receiptId")); @@ -560,8 +560,8 @@ createInvoiceItemAdjContext.put("invoiceId", invoiceId); createInvoiceItemAdjContext.put("invoiceItemSeqId", invoiceItemSeqId); createInvoiceItemAdjContext.put("invoiceItemTypeId", getInvoiceItemType(delegator, adj.getString("orderAdjustmentTypeId"), null, invoiceType, "INVOICE_ITM_ADJ")); - createInvoiceItemAdjContext.put("quantity", new Double(1)); - createInvoiceItemAdjContext.put("amount", new Double(amount.doubleValue())); + createInvoiceItemAdjContext.put("quantity", BigDecimal.ONE); + createInvoiceItemAdjContext.put("amount", amount); createInvoiceItemAdjContext.put("productId", orderItem.get("productId")); createInvoiceItemAdjContext.put("productFeatureId", orderItem.get("productFeatureId")); createInvoiceItemAdjContext.put("overrideGlAccountId", adj.get("overrideGlAccountId")); @@ -608,7 +608,7 @@ createOrderAdjustmentBillingContext.put("orderAdjustmentId", adj.getString("orderAdjustmentId")); createOrderAdjustmentBillingContext.put("invoiceId", invoiceId); createOrderAdjustmentBillingContext.put("invoiceItemSeqId", invoiceItemSeqId); - createOrderAdjustmentBillingContext.put("amount", new Double(amount.doubleValue())); + createOrderAdjustmentBillingContext.put("amount", amount); createOrderAdjustmentBillingContext.put("userLogin", userLogin); Map createOrderAdjustmentBillingResult = dispatcher.runSync("createOrderAdjustmentBilling", createOrderAdjustmentBillingContext); @@ -617,7 +617,7 @@ } // this adjustment amount - BigDecimal thisAdjAmount = new BigDecimal(amount.doubleValue()); + BigDecimal thisAdjAmount = amount; // adjustments only apply to totals when they are not tax or shipping adjustments if (!"SALES_TAX".equals(adj.getString("orderAdjustmentTypeId")) && @@ -840,7 +840,7 @@ String invoiceIdIn = (String) context.get("invoiceId"); String invoiceItemSeqIdIn = (String) context.get("invoiceItemSeqId"); - BigDecimal amountTotal = InvoiceWorker.getInvoiceTotalBd(delegator, invoiceIdIn); + BigDecimal amountTotal = InvoiceWorker.getInvoiceTotal(delegator, invoiceIdIn); // never use equals for BigDecimal - use either signum or compareTo if (amountTotal.signum() == 0) { Debug.logWarning("Invoice [" + invoiceIdIn + "] has an amount total of [" + amountTotal + "], so no commission invoice will be created", module); @@ -849,7 +849,7 @@ try { // Change this when amountApplied is BigDecimal, 18 digit scale to keep all the precision - BigDecimal appliedFraction = new BigDecimal(((Double)context.get("amountApplied")).doubleValue()).divide(amountTotal, 12, rounding); + BigDecimal appliedFraction = ((BigDecimal)context.get("amountApplied")).divide(amountTotal, 12, rounding); Map inMap = UtilMisc.toMap("invoiceId", invoiceIdIn); GenericValue invoice = delegator.findByPrimaryKey("Invoice", inMap); String invoiceTypeId = invoice.getString("invoiceTypeId"); @@ -985,7 +985,7 @@ "invoiceId", invoiceId, "productId", elem.get("productId"), "invoiceItemTypeId", "COMM_INV_ITEM", - "amount", new Double(elemAmount.doubleValue()), + "amount", elemAmount, "userLogin", userLogin)); if (ServiceUtil.isError(resMap)) { return ServiceUtil.returnError(UtilProperties.getMessage(resource,"AccountingInvoiceCommissionErrorItem",locale), null, null, resMap); @@ -1247,7 +1247,7 @@ // Override the issueQty with the quantity from the purchase order item GenericValue orderItemAssoc = EntityUtil.getFirst(EntityUtil.filterByAnd(orderItemAssocs, UtilMisc.toMap("orderId", issue.getString("orderId"), "orderItemSeqId", issue.getString("orderItemSeqId")))); GenericValue purchaseOrderItem = orderItemAssoc.getRelatedOne("ToOrderItem"); - orderItem.set("quantity", purchaseOrderItem.getDouble("quantity")); + orderItem.set("quantity", purchaseOrderItem.getBigDecimal("quantity")); issueQty = purchaseOrderItem.getBigDecimal("quantity"); } @@ -1279,9 +1279,9 @@ // no available means we cannot bill anymore if (billAvail != null && billAvail.signum() == 1) { // this checks if billAvail is a positive non-zero number - if (issueQty != null && issueQty.doubleValue() > billAvail.doubleValue()) { + if (issueQty != null && issueQty.compareTo(billAvail) > 0) { // can only bill some of the issuance; others have been billed already - issue.set("quantity", new Double(billAvail.doubleValue())); + issue.set("quantity", billAvail); billAvail = ZERO; } else { // now have been billed @@ -1378,7 +1378,7 @@ } createOrderAdjustmentContext.put("description", addtlChargeDescription); createOrderAdjustmentContext.put("sourceReferenceId", shipmentId); - createOrderAdjustmentContext.put("amount", new Double(additionalShippingCharge.doubleValue())); + createOrderAdjustmentContext.put("amount", additionalShippingCharge); createOrderAdjustmentContext.put("userLogin", context.get("userLogin")); String shippingOrderAdjustmentId = null; try { @@ -1470,7 +1470,7 @@ // Release all outstanding (not settled or cancelled) authorizations, while keeping a running // total of their amounts so that the total plus the additional shipping charges can be authorized again // all at once. - BigDecimal totalNewAuthAmount = new BigDecimal(totalAdditionalShippingCharges.doubleValue()).setScale(decimals, rounding); + BigDecimal totalNewAuthAmount = totalAdditionalShippingCharges.setScale(decimals, rounding); Iterator oppit = orderPaymentPreferences.iterator(); while (oppit.hasNext()) { GenericValue orderPaymentPreference = (GenericValue) oppit.next(); @@ -1517,7 +1517,7 @@ try { // Use an overrideAmount because the maxAmount wasn't set on the OrderPaymentPreference - authResult = dispatcher.runSync("authOrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId, "overrideAmount", new Double(totalNewAuthAmount.doubleValue()), "userLogin", context.get("userLogin"))); + authResult = dispatcher.runSync("authOrderPaymentPreference", UtilMisc.toMap("orderPaymentPreferenceId", orderPaymentPreferenceId, "overrideAmount", totalNewAuthAmount, "userLogin", context.get("userLogin"))); } catch (GenericServiceException e) { String errMsg = UtilProperties.getMessage(resource, "AccountingTroubleCallingAuthOrderPaymentPreferenceService", locale); Debug.logError(e, errMsg, module); @@ -1758,17 +1758,17 @@ if (invoiceItemTypeId == null) { return ServiceUtil.returnError(errorMsg + UtilProperties.getMessage(resource, "AccountingNoKnownInvoiceItemTypeReturnItemType",UtilMisc.toMap("returnItemTypeId",returnItem.getString("returnItemTypeId")),locale)); } - double quantity = 0.0; + BigDecimal quantity = BigDecimal.ZERO; if (shipmentReceiptFound) { - quantity = item.getDouble("quantityAccepted"); + quantity = item.getBigDecimal("quantityAccepted"); } else if (itemIssuanceFound) { - quantity = item.getDouble("quantity"); + quantity = item.getBigDecimal("quantity"); } // create the invoice item for this shipment receipt - input = UtilMisc.toMap("invoiceId", invoiceId, "invoiceItemTypeId", invoiceItemTypeId, "quantity", Double.valueOf(quantity)); + input = UtilMisc.toMap("invoiceId", invoiceId, "invoiceItemTypeId", invoiceItemTypeId, "quantity", quantity); input.put("invoiceItemSeqId", "" + invoiceItemSeqId); // turn the int into a string with ("" + int) hack - input.put("amount", returnItem.get("returnPrice")); // this service requires Double + input.put("amount", returnItem.get("returnPrice")); input.put("productId", returnItem.get("productId")); input.put("taxableFlag", product.get("taxable")); input.put("description", returnItem.get("description")); @@ -1783,8 +1783,8 @@ input = UtilMisc.toMap("returnId", returnId, "returnItemSeqId", returnItem.get("returnItemSeqId"), "invoiceId", invoiceId); input.put("invoiceItemSeqId", "" + invoiceItemSeqId); // turn the int into a string with ("" + int) hack - input.put("quantity", Double.valueOf(quantity)); - input.put("amount", returnItem.get("returnPrice")); // this service requires Double + input.put("quantity", quantity); + input.put("amount", returnItem.get("returnPrice")); input.put("userLogin", userLogin); if (shipmentReceiptFound) { input.put("shipmentReceiptId", item.get("receiptId")); @@ -1811,8 +1811,8 @@ cancelQuantity = item.getBigDecimal("cancelQuantity"); } if (cancelQuantity == null) {cancelQuantity = ZERO;}; - BigDecimal actualAmount = returnPrice.multiply(BigDecimal.valueOf(quantity)).setScale(decimals, rounding); - BigDecimal promisedAmount = returnPrice.multiply(BigDecimal.valueOf(quantity).add(cancelQuantity)).setScale(decimals, rounding); + BigDecimal actualAmount = returnPrice.multiply(quantity).setScale(decimals, rounding); + BigDecimal promisedAmount = returnPrice.multiply(quantity.add(cancelQuantity)).setScale(decimals, rounding); invoiceTotal = invoiceTotal.add(actualAmount).setScale(decimals, rounding); promisedTotal = promisedTotal.add(promisedAmount).setScale(decimals, rounding); @@ -1834,7 +1834,7 @@ } // prorate the adjustment amount by the returned amount; do not round ratio - BigDecimal ratio = BigDecimal.valueOf(quantity).divide(returnItem.getBigDecimal("returnQuantity"), 100, rounding); + BigDecimal ratio = quantity.divide(returnItem.getBigDecimal("returnQuantity"), 100, rounding); BigDecimal amount = adjustment.getBigDecimal("amount"); amount = amount.multiply(ratio).setScale(decimals, rounding); if (Debug.verboseOn()) { @@ -1843,8 +1843,8 @@ } // prepare invoice item data for this adjustment - input = UtilMisc.toMap("invoiceId", invoiceId, "invoiceItemTypeId", invoiceItemTypeId, "quantity", new Double(1.0)); - input.put("amount", new Double(amount.doubleValue())); + input = UtilMisc.toMap("invoiceId", invoiceId, "invoiceItemTypeId", invoiceItemTypeId, "quantity", BigDecimal.ONE); + input.put("amount", amount); input.put("invoiceItemSeqId", "" + invoiceItemSeqId); // turn the int into a string with ("" + int) hack input.put("productId", returnItem.get("productId")); input.put("description", adjustment.get("description")); @@ -1903,8 +1903,8 @@ } // prepare the invoice item for the return-wide adjustment - input = UtilMisc.toMap("invoiceId", invoiceId, "invoiceItemTypeId", invoiceItemTypeId, "quantity", new Double(1.0)); - input.put("amount", new Double(amount.doubleValue())); + input = UtilMisc.toMap("invoiceId", invoiceId, "invoiceItemTypeId", invoiceItemTypeId, "quantity", BigDecimal.ONE); + input.put("amount", amount); input.put("invoiceItemSeqId", "" + invoiceItemSeqId); // turn the int into a string with ("" + int) hack input.put("description", adjustment.get("description")); input.put("overrideGlAccountId", adjustment.get("overrideGlAccountId")); @@ -2019,7 +2019,7 @@ } if (totalPayments.signum() == 1) { - BigDecimal invoiceTotal = InvoiceWorker.getInvoiceTotalBd(delegator, invoiceId); + BigDecimal invoiceTotal = InvoiceWorker.getInvoiceTotal(delegator, invoiceId); if (Debug.verboseOn()) { Debug.logVerbose("Invoice #" + invoiceId + " total: " + invoiceTotal, module); Debug.logVerbose("Total payments : " + totalPayments, module); @@ -2061,8 +2061,8 @@ createInvoiceItemContext.put("invoiceItemSeqId", invoiceItemSeqId); createInvoiceItemContext.put("invoiceItemTypeId", getInvoiceItemType(delegator, adj.getString("orderAdjustmentTypeId"), null, invoiceTypeId, "INVOICE_ADJ")); createInvoiceItemContext.put("description", adj.get("description")); - createInvoiceItemContext.put("quantity", new Double(1)); - createInvoiceItemContext.put("amount", new Double(amount.doubleValue())); + createInvoiceItemContext.put("quantity", BigDecimal.ONE); + createInvoiceItemContext.put("amount", amount); createInvoiceItemContext.put("overrideGlAccountId", adj.get("overrideGlAccountId")); //createInvoiceItemContext.put("productId", orderItem.get("productId")); //createInvoiceItemContext.put("productFeatureId", orderItem.get("productFeatureId")); @@ -2090,7 +2090,7 @@ createOrderAdjustmentBillingContext.put("orderAdjustmentId", adj.getString("orderAdjustmentId")); createOrderAdjustmentBillingContext.put("invoiceId", invoiceId); createOrderAdjustmentBillingContext.put("invoiceItemSeqId", invoiceItemSeqId); - createOrderAdjustmentBillingContext.put("amount", new Double(amount.doubleValue())); + createOrderAdjustmentBillingContext.put("amount", amount); createOrderAdjustmentBillingContext.put("userLogin", userLogin); try { @@ -2119,8 +2119,8 @@ createInvoiceItemContext.put("invoiceItemSeqId", invoiceItemSeqId); createInvoiceItemContext.put("invoiceItemTypeId", getInvoiceItemType(delegator, adj.getString("orderAdjustmentTypeId"), null, invoiceTypeId, "INVOICE_ADJ")); createInvoiceItemContext.put("description", adj.get("description")); - createInvoiceItemContext.put("quantity", new Double(1)); - createInvoiceItemContext.put("amount", new Double(amount.doubleValue())); + createInvoiceItemContext.put("quantity", BigDecimal.ONE); + createInvoiceItemContext.put("amount", amount); createInvoiceItemContext.put("overrideGlAccountId", adj.get("overrideGlAccountId")); //createInvoiceItemContext.put("productId", orderItem.get("productId")); //createInvoiceItemContext.put("productFeatureId", orderItem.get("productFeatureId")); @@ -2148,7 +2148,7 @@ createOrderAdjustmentBillingContext.put("orderAdjustmentId", adj.getString("orderAdjustmentId")); createOrderAdjustmentBillingContext.put("invoiceId", invoiceId); createOrderAdjustmentBillingContext.put("invoiceItemSeqId", invoiceItemSeqId); - createOrderAdjustmentBillingContext.put("amount", new Double(amount.doubleValue())); + createOrderAdjustmentBillingContext.put("amount", amount); createOrderAdjustmentBillingContext.put("userLogin", userLogin); try { @@ -2210,16 +2210,18 @@ * it works on the invoice item level. */ public static Map updatePaymentApplication(DispatchContext dctx, Map context) { - Double amountApplied = (Double) context.get("amountApplied"); + if (!context.containsKey("useHighestAmount")) { + context.put("useHighestAmount","N"); + } + BigDecimal amountApplied = (BigDecimal) context.get("amountApplied"); if (amountApplied != null) { - BigDecimal amountAppliedBd = new BigDecimal(amountApplied.toString()); - context.put("amountApplied", amountAppliedBd); + context.put("amountApplied", amountApplied); } else { - BigDecimal amountAppliedBd = ZERO; - context.put("amountApplied", amountAppliedBd); + amountApplied = ZERO; + context.put("amountApplied", ZERO); } - return updatePaymentApplicationBd(dctx, context); + return updatePaymentApplicationDefBd(dctx, context); } /** @@ -2234,23 +2236,7 @@ if (!context.containsKey("useHighestAmount")) { context.put("useHighestAmount","Y"); } - Double amountApplied = (Double) context.get("amountApplied"); - if (amountApplied != null) { - BigDecimal amountAppliedBd = new BigDecimal(amountApplied.toString()); - context.put("amountApplied", amountAppliedBd); - } else { - BigDecimal amountAppliedBd = ZERO; - context.put("amountApplied", amountAppliedBd); - } - - return updatePaymentApplicationBd(dctx, context); - } - - public static Map updatePaymentApplicationBd(DispatchContext dctx, Map context) { - if (!context.containsKey("useHighestAmount")) { - context.put("useHighestAmount","N"); - } - return updatePaymentApplicationDefBd(dctx, context); + return updatePaymentApplication(dctx, context); } private static String successMessage = null; @@ -2356,7 +2342,7 @@ if (payment == null) { errorMessageList.add(UtilProperties.getMessage(resource, "AccountingPaymentRecordNotFound",UtilMisc.toMap("paymentId",paymentId),locale)); } - paymentApplyAvailable = payment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentAppliedBd(payment)).setScale(decimals,rounding); + paymentApplyAvailable = payment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentApplied(payment)).setScale(decimals,rounding); if (payment.getString("statusId").equals("PMNT_CANCELLED")) { errorMessageList.add(UtilProperties.getMessage(resource, "AccountingPaymentCancelled", UtilMisc.toMap("paymentId",paymentId), locale)); @@ -2387,7 +2373,7 @@ if (toPayment == null) { errorMessageList.add(UtilProperties.getMessage(resource, "AccountingPaymentRecordNotFound",UtilMisc.toMap("paymentId",toPaymentId),locale)); } - toPaymentApplyAvailable = toPayment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentAppliedBd(toPayment)).setScale(decimals,rounding); + toPaymentApplyAvailable = toPayment.getBigDecimal("amount").subtract(PaymentWorker.getPaymentApplied(toPayment)).setScale(decimals,rounding); if (toPayment.getString("statusId").equals("PMNT_CANCELLED")) { errorMessageList.add(UtilProperties.getMessage(resource, "AccountingPaymentCancelled", UtilMisc.toMap("paymentId",paymentId), locale)); @@ -2504,14 +2490,14 @@ errorMessageList.add("actual currency on payment (" + currencyUomId + ") not the same as original invoice currency (" + invoice.getString("currencyUomId") + ")"); } } - paymentApplyAvailable = payment.getBigDecimal("actualCurrencyAmount").subtract(PaymentWorker.getPaymentAppliedBd(payment)).setScale(decimals,rounding); + paymentApplyAvailable = payment.getBigDecimal("actualCurrencyAmount").subtract(PaymentWorker.getPaymentApplied(payment)).setScale(decimals,rounding); if (amountApplied.signum() == 0) { amountAppliedMax = paymentApplyAvailable; } } // check if the invoice already covered by payments - BigDecimal invoiceTotal = InvoiceWorker.getInvoiceTotalBd(invoice); + BigDecimal invoiceTotal = InvoiceWorker.getInvoiceTotal(invoice); invoiceApplyAvailable = InvoiceWorker.getInvoiceNotApplied(invoice); // adjust the amountAppliedMax value if required.... @@ -2568,7 +2554,7 @@ } else { quantity = invoiceItem.getBigDecimal("quantity").setScale(decimals,rounding); } - invoiceItemApplyAvailable = invoiceItem.getBigDecimal("amount").multiply(quantity).setScale(decimals,rounding).subtract(InvoiceWorker.getInvoiceItemAppliedBd(invoiceItem)); + invoiceItemApplyAvailable = invoiceItem.getBigDecimal("amount").multiply(quantity).setScale(decimals,rounding).subtract(InvoiceWorker.getInvoiceItemApplied(invoiceItem)); // check here for too much application if a new record is added // (paymentApplicationId == null) if (paymentApplicationId == null && amountApplied.compareTo(invoiceItemApplyAvailable) > 0) { @@ -2796,7 +2782,7 @@ paymentApplication.set("invoiceItemSeqId", invoiceItemSeqId); paymentApplication.set("paymentId", paymentId); paymentApplication.set("toPaymentId", toPaymentId); - paymentApplication.set("amountApplied", new Double(amountApplied.doubleValue())); + paymentApplication.set("amountApplied", amountApplied); paymentApplication.set("billingAccountId", billingAccountId); paymentApplication.set("taxAuthGeoId", taxAuthGeoId); return storePaymentApplication(delegator, paymentApplication,locale); @@ -2814,7 +2800,7 @@ paymentApplication.set("invoiceId", invoiceId); paymentApplication.set("invoiceItemSeqId", null); paymentApplication.set("toPaymentId", null); - paymentApplication.set("amountApplied", new Double(amountApplied.doubleValue())); + paymentApplication.set("amountApplied", amountApplied); paymentApplication.set("billingAccountId", billingAccountId); paymentApplication.set("taxAuthGeoId", null); if (debug) Debug.logInfo("creating new paymentapplication", module); @@ -2896,7 +2882,7 @@ paymentApplication.set("invoiceItemSeqId", invoiceItem.getString("invoiceItemSeqId")); paymentApplication.set("paymentId", paymentId); paymentApplication.set("toPaymentId", toPaymentId); - paymentApplication.set("amountApplied", new Double( tobeApplied.doubleValue())); + paymentApplication.set("amountApplied", tobeApplied); paymentApplication.set("billingAccountId", billingAccountId); paymentApplication.set("taxAuthGeoId", taxAuthGeoId); storePaymentApplication(delegator, paymentApplication,locale); @@ -2907,7 +2893,7 @@ // which triggers the ledger routines.... /* * if - * (InvoiceWorker.getInvoiceTotalBd(invoice).equals(InvoiceWorker.getInvoiceAppliedBd(invoice))) { + * (InvoiceWorker.getInvoiceTotal(invoice).equals(InvoiceWorker.getInvoiceApplied(invoice))) { * try { dispatcher.runSync("setInvoiceStatus", * UtilMisc.toMap("invoiceId",invoiceId,"statusId","INVOICE_PAID")); } * catch (GenericServiceException e1) { @@ -2915,7 +2901,7 @@ * module); } } * * if - * (payment.getBigDecimal("amount").equals(PaymentWorker.getPaymentAppliedBd(payment))) { + * (payment.getBigDecimal("amount").equals(PaymentWorker.getPaymentApplied(payment))) { * GenericValue appliedPayment = (GenericValue) * delegator.makeValue("Payment", * UtilMisc.toMap("paymentId",paymentId,"statusId","INVOICE_PAID")); @@ -2947,7 +2933,7 @@ paymentApplication.set("invoiceItemSeqId", invoiceItemSeqId); paymentApplication.set("paymentId", paymentId); paymentApplication.set("toPaymentId", toPaymentId); - paymentApplication.set("amountApplied", new Double(amountApplied.doubleValue())); + paymentApplication.set("amountApplied", amountApplied); paymentApplication.set("billingAccountId", billingAccountId); paymentApplication.set("taxAuthGeoId", taxAuthGeoId); return storePaymentApplication(delegator, paymentApplication,locale); @@ -2959,7 +2945,7 @@ return ServiceUtil.returnError(errorMessageList); } - public static Map calculateInvoicedAdjustmentTotalBd(DispatchContext dctx, Map context) { + public static Map calculateInvoicedAdjustmentTotal(DispatchContext dctx, Map context) { GenericDelegator delegator = dctx.getDelegator(); Locale locale = (Locale) context.get("locale"); GenericValue orderAdjustment = (GenericValue) context.get("orderAdjustment"); @@ -3020,8 +3006,8 @@ // if new record add to the already existing one. if ( paymentApplication.get("paymentApplicationId") == null) { // add 2 amounts together - checkAppl.set("amountApplied", new Double(paymentApplication.getBigDecimal("amountApplied"). - add(checkAppl.getBigDecimal("amountApplied")).setScale(decimals,rounding).doubleValue())); + checkAppl.set("amountApplied", paymentApplication.getBigDecimal("amountApplied"). + add(checkAppl.getBigDecimal("amountApplied")).setScale(decimals,rounding)); if (debug) Debug.logInfo("Update paymentApplication record: " + checkAppl.getString("paymentApplicationId") + " with appliedAmount:" + checkAppl.getBigDecimal("amountApplied"), module); try { checkAppl.store(); @@ -3030,7 +3016,7 @@ } } else if (paymentApplication.getString("paymentApplicationId").equals(checkAppl.getString("paymentApplicationId"))) { // update existing record inplace - checkAppl.set("amountApplied", new Double(paymentApplication.getBigDecimal("amountApplied").doubleValue())); + checkAppl.set("amountApplied", paymentApplication.getBigDecimal("amountApplied")); if (debug) Debug.logInfo("Update paymentApplication record: " + checkAppl.getString("paymentApplicationId") + " with appliedAmount:" + checkAppl.getBigDecimal("amountApplied"), module); try { checkAppl.store(); @@ -3039,8 +3025,8 @@ } } else { // two existing records, an updated one added to the existing one // add 2 amounts together - checkAppl.set("amountApplied", new Double(paymentApplication.getBigDecimal("amountApplied"). - add(checkAppl.getBigDecimal("amountApplied")).setScale(decimals,rounding).doubleValue())); + checkAppl.set("amountApplied", paymentApplication.getBigDecimal("amountApplied"). + add(checkAppl.getBigDecimal("amountApplied")).setScale(decimals,rounding)); // delete paymentApplication record and update the checkAppls one. if (debug) Debug.logInfo("Delete paymentApplication record: " + paymentApplication.getString("paymentApplicationId") + " with appliedAmount:" + paymentApplication.getBigDecimal("amountApplied"), module); try { Modified: ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java?rev=708113&r1=708112&r2=708113&view=diff ============================================================================== --- ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java (original) +++ ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java Mon Oct 27 01:58:56 2008 @@ -53,13 +53,9 @@ /** * Method to return the total amount of an invoice * @param invoice GenericValue object of the Invoice - * @return the invoice total as double + * @return the invoice total as BigDecimal */ - public static double getInvoiceTotal(GenericDelegator delegator, String invoiceId) { - return getInvoiceTotalBd(delegator, invoiceId).doubleValue(); - } - - public static BigDecimal getInvoiceTotalBd(GenericDelegator delegator, String invoiceId) { + public static BigDecimal getInvoiceTotal(GenericDelegator delegator, String invoiceId) { if (delegator == null) { throw new IllegalArgumentException("Null delegator is not allowed in this method"); } @@ -75,7 +71,20 @@ throw new IllegalArgumentException("The invoiceId passed does not match an existing invoice"); } - return getInvoiceTotalBd(invoice); + return getInvoiceTotal(invoice); + } + + /** + * Method to return the total amount of an invoice item i.e. quantity * amount + * @param invoice GenericValue object of the Invoice + * @return the invoice total as BigDecimal + */ + public static BigDecimal getInvoiceItemTotal(GenericValue invoiceItem) { + BigDecimal quantity = invoiceItem.getBigDecimal("quantity"); + if (quantity == null) { + quantity = BigDecimal.ONE; + } + return quantity.multiply(invoiceItem.getBigDecimal("amount")).setScale(decimals, rounding); } /** Method to get the taxable invoice item types as a List of invoiceItemTypeIds. These are identified in Enumeration with enumTypeId TAXABLE_INV_ITM_TY. */ @@ -89,10 +98,7 @@ return typeIds; } - public static double getInvoiceTaxTotal(GenericValue invoice) { - return getInvoiceTaxTotalBd(invoice).doubleValue(); - } - public static BigDecimal getInvoiceTaxTotalBd(GenericValue invoice) { + public static BigDecimal getInvoiceTaxTotal(GenericValue invoice) { BigDecimal invoiceTaxTotal = ZERO; BigDecimal ONE = BigDecimal.ONE; @@ -126,23 +132,16 @@ } - public static double getInvoiceNoTaxTotal(GenericValue invoice) { - return getInvoiceTotalBd(invoice).doubleValue() - getInvoiceTaxTotal(invoice); - } - public static BigDecimal getInvoiceNoTaxTotalBd(GenericValue invoice) { - return getInvoiceTotalBd(invoice).subtract(getInvoiceTaxTotalBd(invoice)); + public static BigDecimal getInvoiceNoTaxTotal(GenericValue invoice) { + return getInvoiceTotal(invoice).subtract(getInvoiceTaxTotal(invoice)); } /** * Method to return the total amount of an invoice * @param invoice GenericValue object of the Invoice - * @return the invoice total as double + * @return the invoice total as BigDecimal */ - public static double getInvoiceTotal(GenericValue invoice) { - return getInvoiceTotalBd(invoice).doubleValue(); - } - - public static BigDecimal getInvoiceTotalBd(GenericValue invoice) { + public static BigDecimal getInvoiceTotal(GenericValue invoice) { BigDecimal invoiceTotal = ZERO; BigDecimal invoiceTaxTotal = ZERO; List invoiceItems = null; @@ -363,13 +362,13 @@ /** * Method to return the total amount of an invoice which is not yet applied to a payment * @param invoice GenericValue object of the Invoice - * @return the invoice total as double + * @return the invoice total as BigDecimal */ public static BigDecimal getInvoiceNotApplied(GenericDelegator delegator, String invoiceId) { - return InvoiceWorker.getInvoiceTotalBd(delegator, invoiceId).subtract(getInvoiceAppliedBd(delegator, invoiceId)); + return InvoiceWorker.getInvoiceTotal(delegator, invoiceId).subtract(getInvoiceApplied(delegator, invoiceId)); } public static BigDecimal getInvoiceNotApplied(GenericValue invoice) { - return InvoiceWorker.getInvoiceTotalBd(invoice).subtract(getInvoiceAppliedBd(invoice)); + return InvoiceWorker.getInvoiceTotal(invoice).subtract(getInvoiceApplied(invoice)); } /** * Returns amount not applied (ie, still outstanding) of an invoice at an asOfDate, based on Payment.effectiveDate <= asOfDateTime @@ -379,21 +378,17 @@ * @return */ public static BigDecimal getInvoiceNotApplied(GenericValue invoice, Timestamp asOfDateTime) { - return InvoiceWorker.getInvoiceTotalBd(invoice).subtract(getInvoiceAppliedBd(invoice, asOfDateTime)); + return InvoiceWorker.getInvoiceTotal(invoice).subtract(getInvoiceApplied(invoice, asOfDateTime)); } /** * Method to return the total amount of an invoice which is applied to a payment * @param invoice GenericValue object of the Invoice - * @return the invoice total as double + * @return the invoice total as BigDecimal */ - public static double getInvoiceApplied(GenericDelegator delegator, String invoiceId) { - return getInvoiceAppliedBd(delegator, invoiceId).doubleValue(); - } - - public static BigDecimal getInvoiceAppliedBd(GenericDelegator delegator, String invoiceId) { - return getInvoiceAppliedBd(delegator, invoiceId, UtilDateTime.nowTimestamp()); + public static BigDecimal getInvoiceApplied(GenericDelegator delegator, String invoiceId) { + return getInvoiceApplied(delegator, invoiceId, UtilDateTime.nowTimestamp()); } /** @@ -404,7 +399,7 @@ * @param asOfDateTime - a Timestamp * @return */ - public static BigDecimal getInvoiceAppliedBd(GenericDelegator delegator, String invoiceId, Timestamp asOfDateTime) { + public static BigDecimal getInvoiceApplied(GenericDelegator delegator, String invoiceId, Timestamp asOfDateTime) { if (delegator == null) { throw new IllegalArgumentException("Null delegator is not allowed in this method"); } @@ -438,44 +433,27 @@ /** * Method to return the total amount of an invoice which is applied to a payment * @param invoice GenericValue object of the Invoice - * @return the applied total as double + * @return the applied total as BigDecimal */ - public static double getInvoiceApplied(GenericValue invoice) { - return getInvoiceAppliedBd(invoice).doubleValue(); + public static BigDecimal getInvoiceApplied(GenericValue invoice) { + return getInvoiceApplied(invoice, UtilDateTime.nowTimestamp()); } + /** - * Big decimal version of getInvoiceApplied - * * @param delegator * @param invoiceId * @param invoiceItemSeqId * @return */ - public static BigDecimal getInvoiceAppliedBd(GenericValue invoice, Timestamp asOfDateTime) { - return getInvoiceAppliedBd(invoice.getDelegator(), invoice.getString("invoiceId"), asOfDateTime); - } - public static BigDecimal getInvoiceAppliedBd(GenericValue invoice) { - return getInvoiceAppliedBd(invoice, UtilDateTime.nowTimestamp()); + public static BigDecimal getInvoiceApplied(GenericValue invoice, Timestamp asOfDateTime) { + return getInvoiceApplied(invoice.getDelegator(), invoice.getString("invoiceId"), asOfDateTime); } - /** * Method to return the amount of an invoiceItem which is applied to a payment * @param invoice GenericValue object of the Invoice - * @return the invoice total as double + * @return the invoice total as BigDecimal */ - public static double getInvoiceItemApplied(GenericDelegator delegator, String invoiceId, String invoiceItemSeqId) { - return getInvoiceItemAppliedBd(delegator, invoiceId, invoiceItemSeqId).doubleValue(); - } - - /** - * Big decimal version of getInvoiceApplied - * - * @param delegator - * @param invoiceId - * @param invoiceItemSeqId - * @return - */ - public static BigDecimal getInvoiceItemAppliedBd(GenericDelegator delegator, String invoiceId, String invoiceItemSeqId) { + public static BigDecimal getInvoiceItemApplied(GenericDelegator delegator, String invoiceId, String invoiceItemSeqId) { if (delegator == null) { throw new IllegalArgumentException("Null delegator is not allowed in this method"); } @@ -491,18 +469,15 @@ throw new IllegalArgumentException("The invoiceId/itemSeqId passed does not match an existing invoiceItem"); } - return getInvoiceItemAppliedBd(invoiceItem); + return getInvoiceItemApplied(invoiceItem); } /** * Method to return the total amount of an invoiceItem which is applied to a payment * @param invoice GenericValue object of the Invoice - * @return the applied total as double + * @return the applied total as BigDecimal */ - public static double getInvoiceItemApplied(GenericValue invoiceItem) { - return getInvoiceItemAppliedBd(invoiceItem).doubleValue(); - } - public static BigDecimal getInvoiceItemAppliedBd(GenericValue invoiceItem) { + public static BigDecimal getInvoiceItemApplied(GenericValue invoiceItem) { BigDecimal invoiceItemApplied = ZERO; List paymentApplications = null; try { Modified: ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java?rev=708113&r1=708112&r2=708113&view=diff ============================================================================== --- ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java (original) +++ ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/payment/BillingAccountWorker.java Mon Oct 27 01:58:56 2008 @@ -83,7 +83,7 @@ billingAccountRoleList = EntityUtil.filterByDate(billingAccountRoleList); if (billingAccountRoleList.size() > 0) { - double totalAvailable = 0.0; + BigDecimal totalAvailable = BigDecimal.ZERO; Iterator billingAcctIter = billingAccountRoleList.iterator(); while (billingAcctIter.hasNext()) { GenericValue billingAccountRole = (GenericValue) billingAcctIter.next(); @@ -94,14 +94,14 @@ if ((thruDate != null) && UtilDateTime.nowTimestamp().after(thruDate)) continue; if (currencyUomId.equals(billingAccountVO.getString("accountCurrencyUomId"))) { - double accountBalance = (BillingAccountWorker.getBillingAccountBalance(billingAccountVO)).doubleValue(); + BigDecimal accountBalance = BillingAccountWorker.getBillingAccountBalance(billingAccountVO); Map billingAccount = new HashMap(billingAccountVO); - double accountLimit = getAccountLimit(billingAccountVO).doubleValue(); + BigDecimal accountLimit = getAccountLimit(billingAccountVO); - billingAccount.put("accountBalance", new Double(accountBalance)); - double accountAvailable = accountLimit - accountBalance; - totalAvailable += accountAvailable; + billingAccount.put("accountBalance", accountBalance); + BigDecimal accountAvailable = accountLimit.subtract(accountBalance); + totalAvailable = totalAvailable.add(accountAvailable); billingAccountList.add(billingAccount); } } @@ -195,8 +195,8 @@ // set the balance to BillingAccount.accountLimit if it is greater. This is necessary because nowhere do we track the amount of BillingAccount // to be charged to an order, such as FinAccountAuth entity does for FinAccount. As a result, we must assume that the system is doing things correctly // and use the accountLimit - BigDecimal accountLimit = new BigDecimal(billingAccount.getDouble("accountLimit").doubleValue()); - if (balance.compareTo(accountLimit) == 1) { + BigDecimal accountLimit = billingAccount.getBigDecimal("accountLimit"); + if (balance.compareTo(accountLimit) > 0) { balance = accountLimit; } else { balance = balance.setScale(decimals, rounding); @@ -227,7 +227,7 @@ */ public static BigDecimal getBillingAccountAvailableBalance(GenericValue billingAccount) throws GenericEntityException { if ((billingAccount != null) && (billingAccount.get("accountLimit") != null)) { - BigDecimal accountLimit = new BigDecimal(billingAccount.getDouble("accountLimit").doubleValue()); + BigDecimal accountLimit = billingAccount.getBigDecimal("accountLimit"); BigDecimal availableBalance = accountLimit.subtract(getBillingAccountBalance(billingAccount)).setScale(decimals, rounding); return availableBalance; } else { @@ -280,7 +280,7 @@ */ public static BigDecimal availableToCapture(GenericValue billingAccount) throws GenericEntityException { BigDecimal netBalance = getBillingAccountNetBalance(billingAccount.getDelegator(), billingAccount.getString("billingAccountId")); - BigDecimal accountLimit = new BigDecimal(billingAccount.getDouble("accountLimit").doubleValue()); + BigDecimal accountLimit = billingAccount.getBigDecimal("accountLimit"); return accountLimit.subtract(netBalance).setScale(decimals, rounding); } @@ -297,10 +297,10 @@ } result.put("billingAccount", billingAccount); - result.put("accountBalance", new Double((getBillingAccountBalance(delegator, billingAccountId)).doubleValue())); - result.put("netAccountBalance", new Double((getBillingAccountNetBalance(delegator, billingAccountId)).doubleValue())); - result.put("availableBalance", new Double(getBillingAccountAvailableBalance(billingAccount).doubleValue())); - result.put("availableToCapture", new Double(availableToCapture(billingAccount).doubleValue())); + result.put("accountBalance", getBillingAccountBalance(delegator, billingAccountId)); + result.put("netAccountBalance", getBillingAccountNetBalance(delegator, billingAccountId)); + result.put("availableBalance", getBillingAccountAvailableBalance(billingAccount)); + result.put("availableToCapture", availableToCapture(billingAccount)); return result; } catch (GenericEntityException e) { @@ -311,7 +311,7 @@ private static class BillingAccountComparator implements Comparator { public int compare(Object billingAccount1, Object billingAccount2) { - return ((Double)((Map)billingAccount1).get("accountBalance")).compareTo((Double)((Map)billingAccount2).get("accountBalance")); + return ((BigDecimal)((Map)billingAccount1).get("accountBalance")).compareTo((BigDecimal)((Map)billingAccount2).get("accountBalance")); } } } Modified: ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java?rev=708113&r1=708112&r2=708113&view=diff ============================================================================== --- ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java (original) +++ ofbiz/branches/typecheckcleanup200810/applications/accounting/src/org/ofbiz/accounting/payment/GiftCertificateServices.java Mon Oct 27 01:58:56 2008 @@ -63,7 +63,7 @@ GenericValue userLogin = (GenericValue) context.get("userLogin"); String productStoreId = (String) context.get("productStoreId"); - Double initialAmount = (Double) context.get("initialAmount"); + BigDecimal initialAmount = (BigDecimal) context.get("initialAmount"); String partyId = (String) context.get("partyId"); if (UtilValidate.isEmpty(partyId)) { @@ -161,7 +161,7 @@ String productStoreId = (String) context.get("productStoreId"); String cardNumber = (String) context.get("cardNumber"); String pinNumber = (String) context.get("pinNumber"); - Double amount = (Double) context.get("amount"); + BigDecimal amount = (BigDecimal) context.get("amount"); String partyId = (String) context.get("partyId"); if (UtilValidate.isEmpty(partyId)) { @@ -224,8 +224,8 @@ } Map result = ServiceUtil.returnSuccess(); - result.put("previousBalance", new Double(previousBalance.doubleValue())); - result.put("balance", new Double(balance.doubleValue())); + result.put("previousBalance", previousBalance); + result.put("balance", balance); result.put("amount", amount); result.put("processResult", Boolean.TRUE); result.put("responseCode", "1"); @@ -243,7 +243,7 @@ String productStoreId = (String) context.get("productStoreId"); String cardNumber = (String) context.get("cardNumber"); String pinNumber = (String) context.get("pinNumber"); - Double amount = (Double) context.get("amount"); + BigDecimal amount = (BigDecimal) context.get("amount"); String partyId = (String) context.get("partyId"); if (UtilValidate.isEmpty(partyId)) { @@ -255,7 +255,7 @@ } // validate the amount - if (amount.doubleValue() < 0.00) { + if (amount.compareTo(BigDecimal.ZERO) < 0) { return ServiceUtil.returnError("Amount should be a positive number."); } @@ -278,17 +278,17 @@ } // check the actual balance (excluding authorized amounts) and create the transaction if it is sufficient - double previousBalance = finAccount.get("actualBalance") == null ? 0.0 : finAccount.getDouble("actualBalance").doubleValue(); + BigDecimal previousBalance = finAccount.get("actualBalance") == null ? BigDecimal.ZERO : finAccount.getBigDecimal("actualBalance"); - double balance = 0.00; + BigDecimal balance = BigDecimal.ZERO; String refNum = null; Boolean procResult; - if (previousBalance >= amount.doubleValue()) { + if (previousBalance.compareTo(amount) >= 0) { try { refNum = GiftCertificateServices.createTransaction(delegator, dispatcher, userLogin, amount, productStoreId, partyId, currencyUom, withdrawl, cardNumber); finAccount.refresh(); - balance = finAccount.get("availableBalance") == null ? 0.0 : finAccount.getDouble("availableBalance").doubleValue(); + balance = finAccount.get("availableBalance") == null ? BigDecimal.ZERO : finAccount.getBigDecimal("availableBalance"); procResult = Boolean.TRUE; } catch (GeneralException e) { Debug.logError(e, module); @@ -301,8 +301,8 @@ } Map result = ServiceUtil.returnSuccess(); - result.put("previousBalance", new Double(previousBalance)); - result.put("balance", new Double(balance)); + result.put("previousBalance", previousBalance); + result.put("balance", balance); result.put("amount", amount); result.put("processResult", procResult); result.put("responseCode", "2"); @@ -331,10 +331,10 @@ // TODO: get the real currency from context //String currencyUom = UtilProperties.getPropertyValue("general.properties", "currency.uom.id.default", "USD"); // get the balance - double balance = finAccount.get("availableBalance") == null ? 0.0 : finAccount.getDouble("availableBalance").doubleValue(); + BigDecimal balance = finAccount.get("availableBalance") == null ? BigDecimal.ZERO : finAccount.getBigDecimal("availableBalance"); Map result = ServiceUtil.returnSuccess(); - result.put("balance", new Double(balance)); + result.put("balance", balance); Debug.log("GC Balance Result - " + result, module); return result; } @@ -345,7 +345,7 @@ GenericDelegator delegator = dctx.getDelegator(); GenericValue userLogin = (GenericValue) context.get("userLogin"); - Double amount = (Double) context.get("processAmount"); + BigDecimal amount = (BigDecimal) context.get("processAmount"); String currency = (String) context.get("currency"); // make sure we have a currency if (currency == null) { @@ -431,7 +431,7 @@ GenericValue giftCard = (GenericValue) context.get("giftCard"); String currency = (String) context.get("currency"); String orderId = (String) context.get("orderId"); - Double amount = (Double) context.get("processAmount"); + BigDecimal amount = (BigDecimal) context.get("processAmount"); // make sure we have a currency if (currency == null) { @@ -479,11 +479,11 @@ String refNum = null; Map result = ServiceUtil.returnSuccess(); - // turn amount into a big decimal, making sure to round and scale it to the same as availableBalance - BigDecimal amountBd = (new BigDecimal(amount.doubleValue())).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding); + // make sure to round and scale it to the same as availableBalance + amount = amount.setScale(FinAccountHelper.decimals, FinAccountHelper.rounding); // if availableBalance equal to or greater than amount, then auth - if (UtilValidate.isNotEmpty(availableBalance) && availableBalance.compareTo(amountBd) > -1) { + if (UtilValidate.isNotEmpty(availableBalance) && availableBalance.compareTo(amount) >= 0) { Timestamp thruDate = null; if (giftCertSettings.getLong("authValidDays") != null) { thruDate = UtilDateTime.getDayEnd(UtilDateTime.nowTimestamp(), giftCertSettings.getLong("authValidDays")); @@ -524,7 +524,7 @@ GenericValue userLogin = (GenericValue) context.get("userLogin"); GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference"); String currency = (String) context.get("currency"); - Double amount = (Double) context.get("refundAmount"); + BigDecimal amount = (BigDecimal) context.get("refundAmount"); return giftCertificateRestore(dctx, userLogin, paymentPref, amount, currency, "refund"); } @@ -546,7 +546,7 @@ Map result = ServiceUtil.returnSuccess(); result.put("releaseRefNum", authTransaction.getString("referenceNum")); - result.put("releaseAmount", authTransaction.getDouble("amount")); + result.put("releaseAmount", authTransaction.getBigDecimal("amount")); result.put("releaseResult", Boolean.TRUE); // if there's an error, don't release @@ -561,7 +561,7 @@ } } - private static Map giftCertificateRestore(DispatchContext dctx, GenericValue userLogin, GenericValue paymentPref, Double amount, String currency, String resultPrefix) { + private static Map giftCertificateRestore(DispatchContext dctx, GenericValue userLogin, GenericValue paymentPref, BigDecimal amount, String currency, String resultPrefix) { LocalDispatcher dispatcher = dctx.getDispatcher(); GenericDelegator delegator = dctx.getDelegator(); @@ -677,8 +677,8 @@ } // amount/quantity of the gift card(s) - Double amount = orderItem.getDouble("unitPrice"); - Double quantity = orderItem.getDouble("quantity"); + BigDecimal amount = orderItem.getBigDecimal("unitPrice"); + BigDecimal quantity = orderItem.getBigDecimal("quantity"); // the product entity needed for information GenericValue product = null; @@ -924,7 +924,7 @@ } // amount of the gift card reload - Double amount = orderItem.getDouble("unitPrice"); + BigDecimal amount = orderItem.getBigDecimal("unitPrice"); // survey information String surveyId = UtilProperties.getPropertyValue(paymentConfig, "payment.giftcert.reload.surveyId"); @@ -1141,8 +1141,8 @@ } if (returnableInfo != null) { - Double returnableQuantity = (Double) returnableInfo.get("returnableQuantity"); - Double returnablePrice = (Double) returnableInfo.get("returnablePrice"); + BigDecimal returnableQuantity = (BigDecimal) returnableInfo.get("returnableQuantity"); + BigDecimal returnablePrice = (BigDecimal) returnableInfo.get("returnablePrice"); Debug.logInfo("Returnable INFO : " + returnableQuantity + " @ " + returnablePrice + " :: " + orderItem, module); // create the return header @@ -1265,7 +1265,7 @@ return false; } - private static String createTransaction(GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue userLogin, Double amount, + private static String createTransaction(GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue userLogin, BigDecimal amount, String productStoreId, String partyId, String currencyUom, String txType, String finAccountId) throws GeneralException { final String coParty = getPayToPartyId(delegator, productStoreId); final String paymentMethodType = "GIFT_CERTIFICATE"; |
Free forum by Nabble | Edit this page |