[ 1583825 ] No tax recalculation after line changes

This commit is contained in:
deathmeat 2007-03-21 17:55:40 +00:00
parent 8da50e3567
commit 0b426b1aad
2 changed files with 59 additions and 41 deletions

View File

@ -835,6 +835,15 @@ public class MInvoiceLine extends X_C_InvoiceLine
return false;
}
// deathmeat: [ 1583825 ] No tax recalculation after line changes
if((MInvoiceTax.get(this, getPrecision(),
true, get_TrxName()).getTaxAmt().doubleValue() == 0.0D))
{
// Tax line total is zero, delete the line
MInvoiceTax.get(this, getPrecision(),
true, get_TrxName()).delete(true, get_TrxName());
}
// Update Invoice Header
String sql = "UPDATE C_Invoice i"
+ " SET TotalLines="

View File

@ -1,8 +1,8 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. 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. *
@ -768,42 +768,42 @@ public class MOrderLine extends X_C_OrderLine
&& getM_AttributeSetInstance_ID() != 0
&& (newRecord || is_ValueChanged("M_Product_ID")
|| is_ValueChanged("M_AttributeSetInstance_ID")
|| is_ValueChanged("M_Warehouse_ID")))
{
MProduct product = getProduct();
if (product.isStocked())
{
int M_AttributeSet_ID = product.getM_AttributeSet_ID();
boolean isInstance = M_AttributeSet_ID != 0;
if (isInstance)
{
MAttributeSet mas = MAttributeSet.get(getCtx(), M_AttributeSet_ID);
isInstance = mas.isInstanceAttribute();
}
// Max
if (isInstance)
{
MStorage[] storages = MStorage.getWarehouse(getCtx(),
getM_Warehouse_ID(), getM_Product_ID(), getM_AttributeSetInstance_ID(),
M_AttributeSet_ID, false, null, true, get_TrxName());
BigDecimal qty = Env.ZERO;
for (int i = 0; i < storages.length; i++)
{
if (storages[i].getM_AttributeSetInstance_ID() == getM_AttributeSetInstance_ID())
qty = qty.add(storages[i].getQtyOnHand());
}
if (getQtyOrdered().compareTo(qty) > 0)
{
log.warning("Qty - Stock=" + qty + ", Ordered=" + getQtyOrdered());
log.saveError("QtyInsufficient", "=" + qty);
return false;
}
}
} // stocked
} // SO instance
// FreightAmt Not used
if (Env.ZERO.compareTo(getFreightAmt()) != 0)
|| is_ValueChanged("M_Warehouse_ID")))
{
MProduct product = getProduct();
if (product.isStocked())
{
int M_AttributeSet_ID = product.getM_AttributeSet_ID();
boolean isInstance = M_AttributeSet_ID != 0;
if (isInstance)
{
MAttributeSet mas = MAttributeSet.get(getCtx(), M_AttributeSet_ID);
isInstance = mas.isInstanceAttribute();
}
// Max
if (isInstance)
{
MStorage[] storages = MStorage.getWarehouse(getCtx(),
getM_Warehouse_ID(), getM_Product_ID(), getM_AttributeSetInstance_ID(),
M_AttributeSet_ID, false, null, true, get_TrxName());
BigDecimal qty = Env.ZERO;
for (int i = 0; i < storages.length; i++)
{
if (storages[i].getM_AttributeSetInstance_ID() == getM_AttributeSetInstance_ID())
qty = qty.add(storages[i].getQtyOnHand());
}
if (getQtyOrdered().compareTo(qty) > 0)
{
log.warning("Qty - Stock=" + qty + ", Ordered=" + getQtyOrdered());
log.saveError("QtyInsufficient", "=" + qty);
return false;
}
}
} // stocked
} // SO instance
// FreightAmt Not used
if (Env.ZERO.compareTo(getFreightAmt()) != 0)
setFreightAmt(Env.ZERO);
// Set Tax
@ -911,6 +911,15 @@ public class MOrderLine extends X_C_OrderLine
if (!tax.save(get_TrxName()))
return false;
// deathmeat: [ 1583825 ] No tax recalculation after line changes
if((MOrderTax.get(this, getPrecision(),
true, get_TrxName()).getTaxAmt().doubleValue() == 0.0D))
{
// Tax line total is zero, delete the line
MOrderTax.get(this, getPrecision(),
true, get_TrxName()).delete(true, get_TrxName());
}
// Update Order Header
String sql = "UPDATE C_Order i"
+ " SET TotalLines="