Author: lektran
Date: Sun May 20 02:58:23 2007
New Revision: 539852
URL: http://svn.apache.org/viewvc?view=rev&rev=539852
Log:
Applied fix from trunk for revision: 535415
Modified:
ofbiz/branches/release4.0/applications/accounting/entitydef/entitymodel.xml
ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
Modified:
ofbiz/branches/release4.0/applications/accounting/entitydef/entitymodel.xml
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/accounting/entitydef/entitymodel.xml?view=diff&rev=539852&r1=539851&r2=539852
==============================================================================
--- ofbiz/branches/release4.0/applications/accounting/entitydef/entitymodel.xml
(original)
+++ ofbiz/branches/release4.0/applications/accounting/entitydef/entitymodel.xml
Sun May 20 02:58:23 2007
@@ -1031,7 +1031,7 @@
<field name="uomId" type="id"></field>
<field name="taxableFlag" type="indicator"></field>
<field name="quantity" type="floating-point"></field>
- <field name="amount" type="currency-amount"></field>
+ <field name="amount" type="currency-precise"></field>
<field name="description" type="description"></field>
<field name="taxAuthPartyId" type="id-ne"/>
<field name="taxAuthGeoId" type="id-ne"/>
Modified:
ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?view=diff&rev=539852&r1=539851&r2=539852
==============================================================================
---
ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
(original)
+++
ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
Sun May 20 02:58:23 2007
@@ -104,7 +104,7 @@
private static int decimals =
UtilNumber.getBigDecimalScale("invoice.decimals");
private static int rounding =
UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
private static int taxDecimals =
UtilNumber.getBigDecimalScale("salestax.calc.decimals");
- private static int taxRounding =
UtilNumber.getBigDecimalScale("salestax.rounding");
+ private static int taxRounding =
UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
public static final int taxCalcScale =
UtilNumber.getBigDecimalScale("salestax.calc.decimals");
private static final int INVOICE_ITEM_SEQUENCE_ID_DIGITS = 5; // this is
the number of digits used for invoiceItemSeqId: 00001, 00002...
@@ -510,7 +510,12 @@
// set decimals = 100 means we don't round this
intermediate value, which is very important
amount =
adj.getBigDecimal("amount").divide(originalOrderItem.getBigDecimal("quantity"),
100, rounding);
amount = amount.multiply(billingQuantity);
- amount = amount.setScale(decimals, rounding);
+ // Tax needs to be rounded differently from other
order adjustments
+ if
(adj.getString("orderAdjustmentTypeId").equals("SALES_TAX")) {
+ amount = amount.setScale(taxDecimals,
taxRounding);
+ } else {
+ amount = amount.setScale(decimals, rounding);
+ }
}
else if (adj.get("sourcePercentage") != null) {
// pro-rate the amount
@@ -566,7 +571,7 @@
}
// this adjustment amount
- BigDecimal thisAdjAmount = new
BigDecimal(amount.doubleValue()).setScale(decimals, rounding);
+ BigDecimal thisAdjAmount = new
BigDecimal(amount.doubleValue());
// adjustments only apply to totals when they are
not tax or shipping adjustments
if
(!"SALES_TAX".equals(adj.getString("orderAdjustmentTypeId")) &&
Modified:
ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java?view=diff&rev=539852&r1=539851&r2=539852
==============================================================================
---
ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
(original)
+++
ofbiz/branches/release4.0/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java
Sun May 20 02:58:23 2007
@@ -45,6 +45,8 @@
private static BigDecimal ZERO = new BigDecimal("0");
private static int decimals =
UtilNumber.getBigDecimalScale("invoice.decimals");
private static int rounding =
UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+ private static int taxDecimals =
UtilNumber.getBigDecimalScale("salestax.calc.decimals");
+ private static int taxRounding =
UtilNumber.getBigDecimalRoundingMode("salestax.rounding");
/**
* Method to return the total amount of an invoice
@@ -134,6 +136,7 @@
public static BigDecimal getInvoiceTotalBd(GenericValue invoice) {
BigDecimal invoiceTotal = ZERO;
+ BigDecimal invoiceTaxTotal = ZERO;
List invoiceItems = null;
try {
invoiceItems = invoice.getRelated("InvoiceItem");
@@ -150,10 +153,14 @@
amount = ZERO;
if (quantity == null)
quantity = new BigDecimal("1");
- invoiceTotal = invoiceTotal.add(
amount.multiply(quantity)).setScale(decimals,rounding);
+ if
("ITM_SALES_TAX".equals(invoiceItem.get("invoiceItemTypeId"))) {
+ invoiceTaxTotal = invoiceTaxTotal.add(
amount.multiply(quantity)).setScale(taxDecimals, taxRounding);
+ } else {
+ invoiceTotal = invoiceTotal.add(
amount.multiply(quantity)).setScale(decimals,rounding);
+ }
}
}
- return invoiceTotal;
+ return invoiceTotal.add(invoiceTaxTotal).setScale(decimals, rounding);
}
/**
Modified:
ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?view=diff&rev=539852&r1=539851&r2=539852
==============================================================================
---
ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
(original)
+++
ofbiz/branches/release4.0/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
Sun May 20 02:58:23 2007
@@ -2612,7 +2612,7 @@
Iterator itemIter = UtilMisc.toIterator(orderItems);
while (itemIter != null && itemIter.hasNext()) {
- result = result.add(getOrderItemTotalBd((GenericValue)
itemIter.next(), adjustments)).setScale(scale, rounding);
+ result = result.add(getOrderItemTotalBd((GenericValue)
itemIter.next(), adjustments));
}
return result.setScale(scale, rounding);
}
@@ -2624,7 +2624,7 @@
public static BigDecimal getOrderItemTotalBd(GenericValue orderItem, List
adjustments) {
// add tax and shipping to subtotal
- return getOrderItemSubTotalBd(orderItem,
adjustments).add(getOrderItemAdjustmentsTotalBd(orderItem, adjustments, false,
true, true)).setScale(scale, rounding);
+ return getOrderItemSubTotalBd(orderItem,
adjustments).add(getOrderItemAdjustmentsTotalBd(orderItem, adjustments, false,
true, true));
}
/** @deprecated */
@@ -2675,7 +2675,7 @@
Iterator itemIter = UtilMisc.toIterator(orderItems);
while (itemIter != null && itemIter.hasNext()) {
- result = result.add(getOrderItemAdjustmentsTotalBd((GenericValue)
itemIter.next(), adjustments, includeOther, includeTax,
includeShipping)).setScale(scale, rounding);
+ result = result.add(getOrderItemAdjustmentsTotalBd((GenericValue)
itemIter.next(), adjustments, includeOther, includeTax, includeShipping));
}
return result;
}
@@ -2728,7 +2728,7 @@
while (adjIt.hasNext()) {
GenericValue orderAdjustment = (GenericValue) adjIt.next();
- adjTotal =
adjTotal.add(OrderReadHelper.calcItemAdjustmentBd(orderAdjustment, quantity,
unitPrice)).setScale(scale, rounding);
+ adjTotal =
adjTotal.add(OrderReadHelper.calcItemAdjustmentBd(orderAdjustment, quantity,
unitPrice));
}
}
return adjTotal;
@@ -2773,7 +2773,7 @@
adjustment =
adjustment.add(setScaleByType("SALES_TAX".equals(itemAdjustment.get("orderAdjustmentTypeId")),
itemAdjustment.getBigDecimal("sourcePercentage").multiply(quantity).multiply(unitPrice).multiply(percentage)));
}
if (Debug.verboseOn()) Debug.logVerbose("calcItemAdjustment: " +
itemAdjustment + ", quantity=" + quantity + ", unitPrice=" + unitPrice + ",
adjustment=" + adjustment, module);
- return adjustment.setScale(scale, rounding);
+ return adjustment;
}
public static BigDecimal calcItemAdjustmentRecurringBd(GenericValue
itemAdjustment, BigDecimal quantity, BigDecimal unitPrice) {