Revision 7117 was reverted by Revision: 7419 by mistake. Putting back.

Armen can you help me to review this ?

BF [ 2314749 ] MatchPO not considering currency PriceMatchDifference
This commit is contained in:
teo_sarca 2008-12-09 07:07:51 +00:00
parent 989962c61c
commit 6860eb3b43
1 changed files with 30 additions and 5 deletions

View File

@ -40,6 +40,10 @@ import org.compiere.util.Env;
*
* @author Bayu Cahya, Sistematika
* <li>BF [ 2240484 ] Re MatchingPO, MMatchPO doesn't contains Invoice info
*
* @author Teo Sarca, www.arhipac.ro
* <li>BF [ 2314749 ] MatchPO not considering currency PriceMatchDifference
*
* @author Armen Rizal, Goodwill Consulting
* <li>BF [ 2215840 ] MatchPO Bug Collection
*/
@ -487,10 +491,28 @@ public class MMatchPO extends X_M_MatchPO
} // getOrderLine
/**
* Before Save
* @param newRecord new
* @return true
* Get PriceActual from Invoice and convert it to Order Currency
* @return Price Actual in Order Currency
*/
public BigDecimal getInvoicePriceActual()
{
MInvoiceLine iLine = getInvoiceLine();
MInvoice invoice = iLine.getParent();
MOrder order = getOrderLine().getParent();
BigDecimal priceActual = iLine.getPriceActual();
int invoiceCurrency_ID = invoice.getC_Currency_ID();
int orderCurrency_ID = order.getC_Currency_ID();
if (invoiceCurrency_ID != orderCurrency_ID)
{
priceActual = MConversionRate.convert(getCtx(), priceActual, invoiceCurrency_ID, orderCurrency_ID,
invoice.getDateInvoiced(), invoice.getC_ConversionType_ID(),
getAD_Client_ID(), getAD_Org_ID());
}
return priceActual;
}
@Override
protected boolean beforeSave (boolean newRecord)
{
// Set Trx Date
@ -561,7 +583,7 @@ public class MMatchPO extends X_M_MatchPO
is_ValueChanged("C_OrderLine_ID") || is_ValueChanged("C_InvoiceLine_ID")))
{
BigDecimal poPrice = getOrderLine().getPriceActual();
BigDecimal invPrice = getInvoiceLine().getPriceActual();
BigDecimal invPrice = getInvoicePriceActual();
BigDecimal difference = poPrice.subtract(invPrice);
if (difference.signum() != 0)
{
@ -611,6 +633,7 @@ public class MMatchPO extends X_M_MatchPO
* @param success success
* @return success
*/
@Override
protected boolean afterSave (boolean newRecord, boolean success)
{
// Purchase Order Delivered/Invoiced
@ -693,6 +716,7 @@ public class MMatchPO extends X_M_MatchPO
* Before Delete
* @return true if acct was deleted
*/
@Override
protected boolean beforeDelete ()
{
if (isPosted())
@ -711,6 +735,7 @@ public class MMatchPO extends X_M_MatchPO
* @param success success
* @return success
*/
@Override
protected boolean afterDelete (boolean success)
{
// Order Delivered/Invoiced
@ -883,7 +908,7 @@ public class MMatchPO extends X_M_MatchPO
MOrder order = oLine.getParent();
Timestamp dateAcct = order.getDateAcct();
//get costing method for product
MProduct product = new MProduct(getCtx(), getM_Product_ID(), get_TrxName());
MProduct product = MProduct.get(getCtx(), getM_Product_ID());
String costingMethod = product.getCostingMethod(as);
if (MAcctSchema.COSTINGMETHOD_AveragePO.equals(costingMethod) ||
MAcctSchema.COSTINGMETHOD_LastPOPrice.equals(costingMethod) )