hg merge release-5.1 (merge release5.1 into default)

This commit is contained in:
Carlos Ruiz 2018-01-05 15:17:26 +01:00
commit caf3ca2367
51 changed files with 1062 additions and 209 deletions

View File

@ -0,0 +1,11 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Sep 18, 2017 12:37:19 PM GMT+08:00
-- 1008477 List on Position field in Lead window is blank even if there are position options configured.
UPDATE AD_Val_Rule SET Code='((C_Job.IsEmployee=(SELECT IsEmployee FROM C_BPartner WHERE C_BPartner_ID=@C_BPartner_ID:0@)) OR (C_Job.IsEmployee=''N'' AND @C_BPartner_ID:0@=0))',Updated=TO_DATE('2017-09-18 12:37:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=243
;
SELECT register_migration_script('201709181100_Ticket_1008477.sql') FROM dual
;

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3388
-- Dec 14, 2017 2:58:05 PM CET
UPDATE C_AcctSchema SET CostingMethod='A',Updated=TO_DATE('2017-12-14 14:58:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_AcctSchema_ID=101
;
-- Dec 14, 2017 2:58:14 PM CET
UPDATE M_CostElement SET IsActive='N',Updated=TO_DATE('2017-12-14 14:58:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_CostElement_ID=104
;
SELECT register_migration_script('201712141459_IDEMPIERE-3388.sql') FROM dual
;

View File

@ -0,0 +1,16 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Fix help of form Merge Entities wrongly formatted breaking the wiki manual
-- Dec 15, 2017 1:49:32 PM CET
UPDATE AD_Form SET Help='<i>Dangerous - Please are aware of what you are doing!</i>
All instances of the From entity (e.g. Customer A) are changed to the To entity (e.g. Customer B).
The From entity (e.g. Customer A) is deleted.
<p><b>There is NO undo nor trace ! Please do a backup first</b> Please be aware that you may be changing history records (e.g. invoices, etc.) ! </p>
<p><b>Side effects:</b> Merging Products are likely to distort product costs; Merging Business Partners may result in incorrect open item balance. Check with support on remedies.</p>
<p><b>Restrictions:</b> Accounting and Inventory conflicts are not resolved in this version.</p>',Updated=TO_DATE('2017-12-15 13:49:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Form_ID=112
;
SELECT register_migration_script('201712151351_MinorHelpFix.sql') FROM dual
;

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-1721 Window Position, tab Remuneration, refers to a disabled window
-- Dec 16, 2017 10:04:11 AM CET
UPDATE AD_Window SET IsActive='Y', IsBetaFunctionality='N',Updated=TO_DATE('2017-12-16 10:04:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Window_ID=353
;
-- Dec 16, 2017 10:04:11 AM CET
UPDATE AD_Menu SET Name='Remuneration', Description='Maintain Remuneration', IsActive='Y',Updated=TO_DATE('2017-12-16 10:04:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Menu_ID=532
;
SELECT register_migration_script('201712161006_IDEMPIERE-1721.sql') FROM dual
;

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3358 Dictionary fixes
-- Dec 16, 2017 10:22:29 AM CET
UPDATE AD_Field SET IsReadOnly='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-12-16 10:22:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202750
;
-- Dec 16, 2017 10:22:42 AM CET
UPDATE AD_Field SET IsReadOnly='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-12-16 10:22:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202776
;
SELECT register_migration_script('201712161023_IDEMPIERE-3358.sql') FROM dual
;

View File

@ -0,0 +1,8 @@
-- Sep 18, 2017 12:37:19 PM GMT+08:00
-- 1008477 List on Position field in Lead window is blank even if there are position options configured.
UPDATE AD_Val_Rule SET Code='((C_Job.IsEmployee=(SELECT IsEmployee FROM C_BPartner WHERE C_BPartner_ID=@C_BPartner_ID:0@)) OR (C_Job.IsEmployee=''N'' AND @C_BPartner_ID:0@=0))',Updated=TO_TIMESTAMP('2017-09-18 12:37:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Val_Rule_ID=243
;
SELECT register_migration_script('201709181100_Ticket_1008477.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- IDEMPIERE-3388
-- Dec 14, 2017 2:58:05 PM CET
UPDATE C_AcctSchema SET CostingMethod='A',Updated=TO_TIMESTAMP('2017-12-14 14:58:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_AcctSchema_ID=101
;
-- Dec 14, 2017 2:58:14 PM CET
UPDATE M_CostElement SET IsActive='N',Updated=TO_TIMESTAMP('2017-12-14 14:58:14','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE M_CostElement_ID=104
;
SELECT register_migration_script('201712141459_IDEMPIERE-3388.sql') FROM dual
;

View File

@ -0,0 +1,13 @@
-- Fix help of form Merge Entities wrongly formatted breaking the wiki manual
-- Dec 15, 2017 1:49:32 PM CET
UPDATE AD_Form SET Help='<i>Dangerous - Please are aware of what you are doing!</i>
All instances of the From entity (e.g. Customer A) are changed to the To entity (e.g. Customer B).
The From entity (e.g. Customer A) is deleted.
<p><b>There is NO undo nor trace ! Please do a backup first</b> Please be aware that you may be changing history records (e.g. invoices, etc.) ! </p>
<p><b>Side effects:</b> Merging Products are likely to distort product costs; Merging Business Partners may result in incorrect open item balance. Check with support on remedies.</p>
<p><b>Restrictions:</b> Accounting and Inventory conflicts are not resolved in this version.</p>',Updated=TO_TIMESTAMP('2017-12-15 13:49:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Form_ID=112
;
SELECT register_migration_script('201712151351_MinorHelpFix.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- IDEMPIERE-1721 Window Position, tab Remuneration, refers to a disabled window
-- Dec 16, 2017 10:04:11 AM CET
UPDATE AD_Window SET IsActive='Y', IsBetaFunctionality='N',Updated=TO_TIMESTAMP('2017-12-16 10:04:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Window_ID=353
;
-- Dec 16, 2017 10:04:11 AM CET
UPDATE AD_Menu SET Name='Remuneration', Description='Maintain Remuneration', IsActive='Y',Updated=TO_TIMESTAMP('2017-12-16 10:04:11','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Menu_ID=532
;
SELECT register_migration_script('201712161006_IDEMPIERE-1721.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- IDEMPIERE-3358 Dictionary fixes
-- Dec 16, 2017 10:22:29 AM CET
UPDATE AD_Field SET IsReadOnly='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-12-16 10:22:29','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202750
;
-- Dec 16, 2017 10:22:42 AM CET
UPDATE AD_Field SET IsReadOnly='N', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-12-16 10:22:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=202776
;
SELECT register_migration_script('201712161023_IDEMPIERE-3358.sql') FROM dual
;

View File

@ -20,6 +20,8 @@ package org.adempiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Properties; import java.util.Properties;
import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.compiere.model.CalloutEngine; import org.compiere.model.CalloutEngine;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
@ -30,7 +32,6 @@ import org.compiere.model.MInvoice;
import org.compiere.model.MInvoiceLine; import org.compiere.model.MInvoiceLine;
import org.compiere.model.MOrder; import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine; import org.compiere.model.MOrderLine;
import org.compiere.model.MProductPricing;
import org.compiere.model.MRMA; import org.compiere.model.MRMA;
import org.compiere.model.MRMALine; import org.compiere.model.MRMALine;
import org.compiere.model.Query; import org.compiere.model.Query;
@ -146,7 +147,8 @@ public class CalloutRMA extends CalloutEngine {
return ""; return "";
MRMA rma = new MRMA(ctx, M_RMA_ID, null); MRMA rma = new MRMA(ctx, M_RMA_ID, null);
MProductPricing pp = new MProductPricing(M_Product_ID, rma.getC_BPartner_ID(), Env.ONE, rma.isSOTrx(), null); IProductPricing pp = Core.getProductPricing();
pp.setInitialValues(M_Product_ID, rma.getC_BPartner_ID(), Env.ONE, rma.isSOTrx(), null);
int taxId = 0; int taxId = 0;
int precision = 0; int precision = 0;

View File

@ -24,6 +24,9 @@ import java.sql.Timestamp;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.adempiere.model.GridTabWrapper;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
@ -87,9 +90,9 @@ public class CalloutInvoice extends CalloutEngine
Env.setContext(ctx, WindowNo, "DocBaseType", s); Env.setContext(ctx, WindowNo, "DocBaseType", s);
// AP Check & AR Credit Memo // AP Check & AR Credit Memo
if (s.startsWith("AP")) if (s.startsWith("AP"))
mTab.setValue("PaymentRule", "S"); // Check mTab.setValue("PaymentRule", X_C_Invoice.PAYMENTRULE_Check);
else if (s.endsWith("C")) else if (s.endsWith("C"))
mTab.setValue("PaymentRule", "P"); // OnCredit mTab.setValue("PaymentRule", X_C_Invoice.PAYMENTRULE_OnCredit);
} }
} }
catch (SQLException e) catch (SQLException e)
@ -183,13 +186,9 @@ public class CalloutInvoice extends CalloutEngine
// PaymentRule // PaymentRule
String s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO"); String s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO");
if (s != null && s.length() != 0) if (s != null && s.length() != 0)
{
if (Env.getContext(ctx, WindowNo, "DocBaseType").endsWith("C")) // Credits are Payment Term
s = "P";
else if (IsSOTrx && (s.equals("S") || s.equals("U"))) // No Check/Transfer for SO_Trx
s = "P"; // Payment Term
mTab.setValue("PaymentRule", s); mTab.setValue("PaymentRule", s);
} if (Env.getContext(ctx, WindowNo, "DocBaseType").endsWith("C")) // Credits are Payment Term
s = X_C_Invoice.PAYMENTRULE_OnCredit;
// Payment Term // Payment Term
ii = new Integer(rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID")); ii = new Integer(rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID"));
if (!rs.wasNull()) if (!rs.wasNull())
@ -324,10 +323,9 @@ public class CalloutInvoice extends CalloutEngine
mTab.setValue("M_AttributeSetInstance_ID", null); mTab.setValue("M_AttributeSetInstance_ID", null);
/***** Price Calculation see also qty ****/ /***** Price Calculation see also qty ****/
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); I_C_InvoiceLine invoiceLine = GridTabWrapper.create(mTab, I_C_InvoiceLine.class);
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID"); IProductPricing pp = Core.getProductPricing();
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyInvoiced"); pp.setInvoiceLine(invoiceLine, null);
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
// //
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
@ -350,8 +348,6 @@ public class CalloutInvoice extends CalloutEngine
} }
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
Timestamp date = Env.getContextAsDate(ctx, WindowNo, "DateInvoiced");
pp.setPriceDate(date);
// //
mTab.setValue("PriceList", pp.getPriceList()); mTab.setValue("PriceList", pp.getPriceList());
mTab.setValue("PriceLimit", pp.getPriceLimit()); mTab.setValue("PriceLimit", pp.getPriceLimit());
@ -557,19 +553,18 @@ public class CalloutInvoice extends CalloutEngine
|| mField.getColumnName().equals("M_Product_ID")) || mField.getColumnName().equals("M_Product_ID"))
&& !"N".equals(Env.getContext(ctx, WindowNo, "DiscountSchema"))) && !"N".equals(Env.getContext(ctx, WindowNo, "DiscountSchema")))
{ {
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
if (mField.getColumnName().equals("QtyEntered")) if (mField.getColumnName().equals("QtyEntered"))
QtyInvoiced = MUOMConversion.convertProductFrom (ctx, M_Product_ID, QtyInvoiced = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, QtyEntered); C_UOM_To_ID, QtyEntered);
if (QtyInvoiced == null) if (QtyInvoiced == null)
QtyInvoiced = QtyEntered; QtyInvoiced = QtyEntered;
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); I_C_InvoiceLine invoiceLine = GridTabWrapper.create(mTab, I_C_InvoiceLine.class);
MProductPricing pp = new MProductPricing (M_Product_ID, C_BPartner_ID, QtyInvoiced, IsSOTrx, null); IProductPricing pp = Core.getProductPricing();
pp.setInvoiceLine(invoiceLine, null);
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
pp.setQty(QtyInvoiced);
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID"); int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID");
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
Timestamp date = (Timestamp)mTab.getValue("DateInvoiced");
pp.setPriceDate(date);
// //
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, pp.getPriceStd()); C_UOM_To_ID, pp.getPriceStd());
@ -842,10 +837,9 @@ public class CalloutInvoice extends CalloutEngine
} }
/***** Price Calculation see also qty ****/ /***** Price Calculation see also qty ****/
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID"); I_C_InvoiceLine invoiceLine = GridTabWrapper.create(mTab, I_C_InvoiceLine.class);
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered"); IProductPricing pp = Core.getProductPricing();
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); pp.setInvoiceLine(invoiceLine, null);
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
// //
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
@ -866,7 +860,6 @@ public class CalloutInvoice extends CalloutEngine
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID ); Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
} }
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
pp.setPriceDate(orderDate);
// //
Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N"); Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N");
Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N"); Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");

View File

@ -105,13 +105,9 @@ public class CalloutInvoiceBatch extends CalloutEngine
// PaymentRule // PaymentRule
String s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO"); String s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO");
if (s != null && s.length() != 0) if (s != null && s.length() != 0)
{ mTab.setValue("PaymentRule", s);
if (Env.getContext(ctx, WindowNo, "DocBaseType").endsWith("C")) // Credits are Payment Term if (Env.getContext(ctx, WindowNo, "DocBaseType").endsWith("C")) // Credits are Payment Term
s = "P"; s = X_C_Invoice.PAYMENTRULE_OnCredit;
else if (IsSOTrx && (s.equals("S") || s.equals("U"))) // No Check/Transfer for SO_Trx
s = "P"; // Payment Term
// mTab.setValue("PaymentRule", s);
}
// Payment Term // Payment Term
Integer ii = new Integer(rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID")); Integer ii = new Integer(rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID"));
if (!rs.wasNull()) if (!rs.wasNull())

View File

@ -24,6 +24,9 @@ import java.sql.Timestamp;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.adempiere.model.GridTabWrapper;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
@ -181,13 +184,7 @@ public class CalloutOrder extends CalloutEngine
// PaymentRule // PaymentRule
String s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO"); String s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO");
if (s != null && s.length() != 0) if (s != null && s.length() != 0)
{
if (IsSOTrx && (s.equals("B") || s.equals("S") || s.equals("U"))) // No Cash/Check/Transfer for SO_Trx
s = "P"; // Payment Term
if (!IsSOTrx && (s.equals("B"))) // No Cash for PO_Trx
s = "P"; // Payment Term
mTab.setValue("PaymentRule", s); mTab.setValue("PaymentRule", s);
}
// Payment Term // Payment Term
Integer ii =new Integer(rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID")); Integer ii =new Integer(rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID"));
if (!rs.wasNull()) if (!rs.wasNull())
@ -401,13 +398,7 @@ public class CalloutOrder extends CalloutEngine
// PaymentRule // PaymentRule
s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO"); s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO");
if (s != null && s.length() != 0) if (s != null && s.length() != 0)
{
if (s.equals("B")) // No Cache in Non POS
s = "P";
if (IsSOTrx && (s.equals("S") || s.equals("U"))) // No Check/Transfer for SO_Trx
s = "P"; // Payment Term
mTab.setValue("PaymentRule", s); mTab.setValue("PaymentRule", s);
}
// Payment Term // Payment Term
ii = new Integer(rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID")); ii = new Integer(rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID"));
if (!rs.wasNull()) if (!rs.wasNull())
@ -589,13 +580,7 @@ public class CalloutOrder extends CalloutEngine
// PaymentRule // PaymentRule
s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO"); s = rs.getString(IsSOTrx ? "PaymentRule" : "PaymentRulePO");
if (s != null && s.length() != 0) if (s != null && s.length() != 0)
{
if (s.equals("B")) // No Cache in Non POS
s = "P";
if (IsSOTrx && (s.equals("S") || s.equals("U"))) // No Check/Transfer for SO_Trx
s = "P"; // Payment Term
mTab.setValue("PaymentRule", s); mTab.setValue("PaymentRule", s);
}
// Payment Term // Payment Term
ii = new Integer(rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID")); ii = new Integer(rs.getInt(IsSOTrx ? "C_PaymentTerm_ID" : "PO_PaymentTerm_ID"));
if (!rs.wasNull()) if (!rs.wasNull())
@ -797,10 +782,9 @@ public class CalloutOrder extends CalloutEngine
mTab.setValue("M_AttributeSetInstance_ID", null); mTab.setValue("M_AttributeSetInstance_ID", null);
/***** Price Calculation see also qty ****/ /***** Price Calculation see also qty ****/
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID"); I_C_OrderLine orderLine = GridTabWrapper.create(mTab, I_C_OrderLine.class);
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered"); IProductPricing pp = Core.getProductPricing();
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); pp.setOrderLine(orderLine, null);
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
// //
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
@ -821,7 +805,6 @@ public class CalloutOrder extends CalloutEngine
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID ); Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
} }
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
pp.setPriceDate(orderDate);
// //
mTab.setValue("PriceList", pp.getPriceList()); mTab.setValue("PriceList", pp.getPriceList());
mTab.setValue("PriceLimit", pp.getPriceLimit()); mTab.setValue("PriceLimit", pp.getPriceLimit());
@ -1089,19 +1072,18 @@ public class CalloutOrder extends CalloutEngine
|| mField.getColumnName().equals("M_Product_ID")) || mField.getColumnName().equals("M_Product_ID"))
&& !"N".equals(Env.getContext(ctx, WindowNo, "DiscountSchema"))) && !"N".equals(Env.getContext(ctx, WindowNo, "DiscountSchema")))
{ {
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID");
if (mField.getColumnName().equals("QtyEntered")) if (mField.getColumnName().equals("QtyEntered"))
QtyOrdered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, QtyOrdered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, QtyEntered); C_UOM_To_ID, QtyEntered);
if (QtyOrdered == null) if (QtyOrdered == null)
QtyOrdered = QtyEntered; QtyOrdered = QtyEntered;
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); I_C_OrderLine orderLine = GridTabWrapper.create(mTab, I_C_OrderLine.class);
MProductPricing pp = new MProductPricing (M_Product_ID, C_BPartner_ID, QtyOrdered, IsSOTrx, null); IProductPricing pp = Core.getProductPricing();
pp.setOrderLine(orderLine, null);
pp.setQty(QtyOrdered);
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID"); int M_PriceList_Version_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_Version_ID");
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
Timestamp date = (Timestamp)mTab.getValue("DateOrdered");
pp.setPriceDate(date);
// //
PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID, PriceEntered = MUOMConversion.convertProductFrom (ctx, M_Product_ID,
C_UOM_To_ID, pp.getPriceStd()); C_UOM_To_ID, pp.getPriceStd());
@ -1422,10 +1404,9 @@ public class CalloutOrder extends CalloutEngine
} }
/***** Price Calculation see also qty ****/ /***** Price Calculation see also qty ****/
int C_BPartner_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_ID"); I_C_OrderLine orderLine = GridTabWrapper.create(mTab, I_C_OrderLine.class);
BigDecimal Qty = (BigDecimal)mTab.getValue("QtyOrdered"); IProductPricing pp = Core.getProductPricing();
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); pp.setOrderLine(orderLine, null);
MProductPricing pp = new MProductPricing (M_Product_ID.intValue(), C_BPartner_ID, Qty, IsSOTrx, null);
// //
int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID"); int M_PriceList_ID = Env.getContextAsInt(ctx, WindowNo, "M_PriceList_ID");
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
@ -1446,7 +1427,6 @@ public class CalloutOrder extends CalloutEngine
Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID ); Env.setContext(ctx, WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID );
} }
pp.setM_PriceList_Version_ID(M_PriceList_Version_ID); pp.setM_PriceList_Version_ID(M_PriceList_Version_ID);
pp.setPriceDate(orderDate);
// //
Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N"); Env.setContext(ctx, WindowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit() ? "Y" : "N");
Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N"); Env.setContext(ctx, WindowNo, "DiscountSchema", pp.isDiscountSchema() ? "Y" : "N");

View File

@ -21,12 +21,13 @@ import java.sql.Timestamp;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.adempiere.model.GridTabWrapper; import org.adempiere.model.GridTabWrapper;
import org.compiere.util.Env; import org.compiere.util.Env;
/** /**
* Requisition Callouts * Requisition Callouts
*
* @author Jorg Janke * @author Jorg Janke
* @version $Id: CalloutRequisition.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $ * @version $Id: CalloutRequisition.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $
*/ */
@ -47,7 +48,7 @@ public class CalloutRequisition extends CalloutEngine
Integer M_Product_ID = (Integer)value; Integer M_Product_ID = (Integer)value;
if (M_Product_ID == null || M_Product_ID.intValue() == 0) if (M_Product_ID == null || M_Product_ID.intValue() == 0)
return ""; return "";
final I_M_Requisition req = GridTabWrapper.create(mTab, I_M_Requisition.class); final I_M_Requisition req = GridTabWrapper.create(mTab.getParentTab(), I_M_Requisition.class);
final I_M_RequisitionLine line = GridTabWrapper.create(mTab, I_M_RequisitionLine.class); final I_M_RequisitionLine line = GridTabWrapper.create(mTab, I_M_RequisitionLine.class);
setPrice(ctx, WindowNo, req, line); setPrice(ctx, WindowNo, req, line);
MProduct product = MProduct.get(ctx, M_Product_ID); MProduct product = MProduct.get(ctx, M_Product_ID);
@ -71,7 +72,7 @@ public class CalloutRequisition extends CalloutEngine
if (isCalloutActive() || value == null) if (isCalloutActive() || value == null)
return ""; return "";
final I_M_Requisition req = GridTabWrapper.create(mTab, I_M_Requisition.class); final I_M_Requisition req = GridTabWrapper.create(mTab.getParentTab(), I_M_Requisition.class);
final I_M_RequisitionLine line = GridTabWrapper.create(mTab, I_M_RequisitionLine.class); final I_M_RequisitionLine line = GridTabWrapper.create(mTab, I_M_RequisitionLine.class);
// Qty changed - recalc price // Qty changed - recalc price
if (mField.getColumnName().equals(I_M_RequisitionLine.COLUMNNAME_Qty) if (mField.getColumnName().equals(I_M_RequisitionLine.COLUMNNAME_Qty)
@ -100,7 +101,8 @@ public class CalloutRequisition extends CalloutEngine
int C_BPartner_ID = line.getC_BPartner_ID(); int C_BPartner_ID = line.getC_BPartner_ID();
BigDecimal Qty = line.getQty(); BigDecimal Qty = line.getQty();
boolean isSOTrx = false; boolean isSOTrx = false;
MProductPricing pp = new MProductPricing (line.getM_Product_ID(), C_BPartner_ID, Qty, isSOTrx, null); IProductPricing pp = Core.getProductPricing();
pp.setInitialValues(line.getM_Product_ID(), C_BPartner_ID, Qty, isSOTrx, null);
// //
int M_PriceList_ID = req.getM_PriceList_ID(); int M_PriceList_ID = req.getM_PriceList_ID();
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);

View File

@ -127,7 +127,7 @@ public class AcceptCtxHelpSuggestion extends SvrProcess {
} else { } else {
StringBuilder insert = new StringBuilder("Insert Into AD_CtxHelpMsg_Trl (AD_Client_ID, AD_Org_ID, AD_CtxHelpMsg_ID, IsActive, IsTranslated, AD_Language, MsgText,"); StringBuilder insert = new StringBuilder("Insert Into AD_CtxHelpMsg_Trl (AD_Client_ID, AD_Org_ID, AD_CtxHelpMsg_ID, IsActive, IsTranslated, AD_Language, MsgText,");
insert.append("Created, CreatedBy, Updated, UpdatedBy, AD_CtxHelpMsg_Trl_UU)") insert.append("Created, CreatedBy, Updated, UpdatedBy, AD_CtxHelpMsg_Trl_UU)")
.append(" Values (?, ?, ?, 'Y', 'N', ?, ?, now(), ?, now(), ?, generate_uuid()) "); .append(" Values (?, ?, ?, 'Y', 'N', ?, ?, sysdate, ?, sysdate, ?, generate_uuid()) ");
List<Object> params = new ArrayList<Object>(); List<Object> params = new ArrayList<Object>();
params.add(AD_Client_ID); params.add(AD_Client_ID);
params.add(0); params.add(0);

View File

@ -19,7 +19,8 @@ package org.compiere.process;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.model.MProductPricing; import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.compiere.model.MProject; import org.compiere.model.MProject;
import org.compiere.model.MProjectLine; import org.compiere.model.MProjectLine;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -71,8 +72,9 @@ public class ProjectLinePricing extends SvrProcess
throw new IllegalArgumentException("No PriceList"); throw new IllegalArgumentException("No PriceList");
// //
boolean isSOTrx = true; boolean isSOTrx = true;
MProductPricing pp = new MProductPricing (projectLine.getM_Product_ID(), IProductPricing pp = Core.getProductPricing();
project.getC_BPartner_ID(), projectLine.getPlannedQty(), isSOTrx, get_TrxName()); pp.setInitialValues(projectLine.getM_Product_ID(), project.getC_BPartner_ID(),
projectLine.getPlannedQty(), isSOTrx, get_TrxName());
pp.setM_PriceList_ID(project.getM_PriceList_ID()); pp.setM_PriceList_ID(project.getM_PriceList_ID());
pp.setPriceDate(project.getDateContract()); pp.setPriceDate(project.getDateContract());
// //

View File

@ -101,7 +101,10 @@ Import-Package: com.sun.mail.smtp;version="1.5",
org.osgi.framework, org.osgi.framework,
org.osgi.service.cm;version="1.3.0", org.osgi.service.cm;version="1.3.0",
org.osgi.service.component;version="1.1.0", org.osgi.service.component;version="1.1.0",
org.osgi.service.component.runtime;version="1.3.0",
org.osgi.service.component.runtime.dto;version="1.3.0",
org.osgi.service.event;version="1.2.0", org.osgi.service.event;version="1.2.0",
org.osgi.util.promise;version="1.0.0",
org.osgi.util.tracker;version="1.5.0", org.osgi.util.tracker;version="1.5.0",
org.restlet, org.restlet,
org.restlet.data, org.restlet.data,
@ -118,4 +121,5 @@ Require-Bundle: org.eclipse.equinox.app;bundle-version="0.0.0",
com.itextpdf;bundle-version="0.0.0", com.itextpdf;bundle-version="0.0.0",
net.sf.supercsv.super-csv;bundle-version="0.0.0", net.sf.supercsv.super-csv;bundle-version="0.0.0",
bcprov;bundle-version="1.54.0", bcprov;bundle-version="1.54.0",
groovy-all;bundle-version="[2.4.7,2.5.0)" groovy-all;bundle-version="[2.4.7,2.5.0)",
org.krysalis.barcode4j;bundle-version="2.1.0"

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.base.DefaultProductPricingFactory">
<implementation class="org.adempiere.base.DefaultProductPricingFactory"/>
<service>
<provide interface="org.adempiere.base.IProductPricingFactory"/>
</service>
</scr:component>

View File

@ -22,6 +22,7 @@ bin.includes = META-INF/,\
OSGI-INF/defaultaddressvalidationfactory.xml,\ OSGI-INF/defaultaddressvalidationfactory.xml,\
OSGI-INF/defaulttaxproviderfactory.xml,\ OSGI-INF/defaulttaxproviderfactory.xml,\
OSGI-INF/addressvalidationeventhandler.xml,\ OSGI-INF/addressvalidationeventhandler.xml,\
OSGI-INF/defaultproductpricingfactory.xml\
schema/,\ schema/,\
bsh-2.0b6.jar,\ bsh-2.0b6.jar,\
commons-validator-1.6.jar commons-validator-1.6.jar

View File

@ -0,0 +1,141 @@
/******************************************************************************
* Copyright (C) 2017 Diego Ruiz *
* Copyright (C) 2017 Bx Service GmbH *
* 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. *
* 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., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.base;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.model.I_C_InvoiceLine;
import org.compiere.model.I_C_OrderLine;
import org.compiere.model.I_C_ProjectLine;
import org.compiere.model.I_M_RMALine;
import org.compiere.model.I_M_RequisitionLine;
import org.compiere.util.Env;
public abstract class AbstractProductPricing implements IProductPricing {
protected int m_M_Product_ID;
protected int m_C_BPartner_ID;
protected BigDecimal m_Qty = Env.ONE;
protected boolean m_isSOTrx = true;
protected String trxName = null;
protected int m_M_PriceList_Version_ID = 0;
protected int m_M_PriceList_ID = 0;
protected Timestamp m_PriceDate;
public AbstractProductPricing() {}
@Override
public void setInitialValues(int M_Product_ID, int C_BPartner_ID, BigDecimal qty, boolean isSOTrx, String trxName) {
this.trxName=trxName;
m_M_Product_ID = M_Product_ID;
m_C_BPartner_ID = C_BPartner_ID;
if (qty != null && Env.ZERO.compareTo(qty) != 0)
m_Qty = qty;
m_isSOTrx = isSOTrx;
}
@Override
public int getM_Product_ID() {
return m_M_Product_ID;
}
@Override
public int getM_PriceList_ID() {
return m_M_PriceList_ID;
}
@Override
public void setM_PriceList_ID(int M_PriceList_ID) {
m_M_PriceList_ID = M_PriceList_ID;
}
@Override
public void setM_PriceList_Version_ID(int M_PriceList_Version_ID) {
m_M_PriceList_Version_ID = M_PriceList_Version_ID;
}
@Override
public void setQty(BigDecimal qty) {
m_Qty = qty;
}
@Override
public Timestamp getPriceDate() {
return m_PriceDate;
}
@Override
public void setPriceDate(Timestamp priceDate) {
m_PriceDate = priceDate;
}
@Override
public void setOrderLine(I_C_OrderLine orderLine, String trxName) {
m_M_Product_ID = orderLine.getM_Product_ID();
m_C_BPartner_ID = orderLine.getC_BPartner_ID();
BigDecimal qty = orderLine.getQtyOrdered();
if (qty != null && Env.ZERO.compareTo(qty) != 0)
m_Qty = qty;
m_isSOTrx = orderLine.getC_Order().isSOTrx();
m_PriceDate = orderLine.getDateOrdered();
this.trxName = trxName;
}
@Override
public void setInvoiceLine(I_C_InvoiceLine invoiceLine, String trxName) {
m_M_Product_ID = invoiceLine.getM_Product_ID();
m_C_BPartner_ID = invoiceLine.getC_Invoice().getC_BPartner_ID();
BigDecimal qty = invoiceLine.getQtyInvoiced() != null ?
invoiceLine.getQtyInvoiced() : invoiceLine.getQtyEntered();
if (qty != null && Env.ZERO.compareTo(qty) != 0)
m_Qty = qty;
m_isSOTrx = invoiceLine.getC_Invoice().isSOTrx();
m_PriceDate = invoiceLine.getC_Invoice().getDateInvoiced();
this.trxName = trxName;
}
@Override
public void setProjectLine(I_C_ProjectLine projectLine, String trxName) {
m_M_Product_ID = projectLine.getM_Product_ID();
m_C_BPartner_ID = projectLine.getC_Project().getC_BPartner_ID();
BigDecimal qty = projectLine.getPlannedQty();
if (qty != null && Env.ZERO.compareTo(qty) != 0)
m_Qty = qty;
m_isSOTrx = true;
this.trxName = trxName;
}
@Override
public void setRequisitionLine(I_M_RequisitionLine reqLine, String trxName) {
m_M_Product_ID = reqLine.getM_Product_ID();
m_C_BPartner_ID = reqLine.getC_BPartner_ID();
BigDecimal qty = reqLine.getQty();
if (qty != null && Env.ZERO.compareTo(qty) != 0)
m_Qty = qty;
m_isSOTrx = false;
this.trxName = trxName;
}
@Override
public void setRMALine(I_M_RMALine rmaLine, String trxName) {
m_M_Product_ID = rmaLine.getM_Product_ID();
m_C_BPartner_ID = rmaLine.getM_RMA().getC_BPartner_ID();
m_Qty = Env.ONE;
m_isSOTrx = rmaLine.getM_RMA().isSOTrx();
this.trxName = trxName;
}
}

View File

@ -19,10 +19,9 @@ import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.apache.felix.scr.Component;
import org.apache.felix.scr.ScrService;
import org.compiere.util.Ini; import org.compiere.util.Ini;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
@ -30,6 +29,8 @@ import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentConstants; import org.osgi.service.component.ComponentConstants;
import org.osgi.service.component.runtime.ServiceComponentRuntime;
import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
/** /**
* @author hengsin * @author hengsin
@ -37,11 +38,11 @@ import org.osgi.service.component.ComponentConstants;
*/ */
public class ComponentBlackListService implements ServiceListener { public class ComponentBlackListService implements ServiceListener {
private ScrService scrService = null; private ServiceComponentRuntime scrService = null;
private List<String> blackListComponentNames = null; private List<String> blackListComponentNames = null;
protected ComponentBlackListService(BundleContext context) { protected ComponentBlackListService(BundleContext context) {
ServiceReference<ScrService> ref = context.getServiceReference(ScrService.class); ServiceReference<ServiceComponentRuntime> ref = context.getServiceReference(ServiceComponentRuntime.class);
scrService = context.getService(ref); scrService = context.getService(ref);
blackListComponentNames = new ArrayList<String>(); blackListComponentNames = new ArrayList<String>();
retrieveBlacklistCandidates(); retrieveBlacklistCandidates();
@ -89,20 +90,20 @@ public class ComponentBlackListService implements ServiceListener {
private void disableComponents() private void disableComponents()
{ {
Component[] comps = scrService.getComponents(); Collection<ComponentDescriptionDTO> comps = scrService.getComponentDescriptionDTOs();
for (Component comp : comps) { for (ComponentDescriptionDTO comp : comps) {
if (blackListComponentNames.contains(comp.getName())) { if (blackListComponentNames.contains(comp.name)) {
comp.disable(); scrService.disableComponent(comp);
} }
} }
} }
private void disableComponent(String componentName) private void disableComponent(String componentName)
{ {
Component[] comps = scrService.getComponents(); Collection<ComponentDescriptionDTO> comps = scrService.getComponentDescriptionDTOs();
for (Component comp : comps) { for (ComponentDescriptionDTO comp : comps) {
if (comp.getName().equals(componentName)) { if (comp.name.equals(componentName)) {
comp.disable(); scrService.disableComponent(comp);
break; break;
} }
} }

View File

@ -450,4 +450,26 @@ public class Core {
return myPaymentExporter; return myPaymentExporter;
} }
/**
* get ProductPricing instance
*
* @return instance of the IProductPricing or null
*/
public static IProductPricing getProductPricing() {
List<IProductPricingFactory> factoryList =
Service.locator().list(IProductPricingFactory.class).getServices();
if (factoryList != null) {
for(IProductPricingFactory factory : factoryList) {
IProductPricing myProductPricing = factory.newProductPricingInstance();
if (myProductPricing != null) {
return myProductPricing;
}
}
}
return null;
}
} }

View File

@ -0,0 +1,18 @@
package org.adempiere.base;
import org.compiere.model.MProductPricing;
public class DefaultProductPricingFactory implements IProductPricingFactory {
/**
* default constructor
*/
public DefaultProductPricingFactory() {
}
@Override
public AbstractProductPricing newProductPricingInstance() {
return new MProductPricing();
}
}

View File

@ -0,0 +1,159 @@
/******************************************************************************
* Copyright (C) 2017 Diego Ruiz *
* Copyright (C) 2017 Bx Service GmbH *
* 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. *
* 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., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.base;
import java.math.BigDecimal;
import java.sql.Timestamp;
import org.compiere.model.I_C_InvoiceLine;
import org.compiere.model.I_C_OrderLine;
import org.compiere.model.I_C_ProjectLine;
import org.compiere.model.I_M_RMALine;
import org.compiere.model.I_M_RequisitionLine;
/**
* Product Price Calculations
*/
public interface IProductPricing {
/**
* Set the initial values that the old MProductPricing uses
* for backward compatibility
* @param M_Product_ID
* @param C_BPartner_ID
* @param qty
* @param isSOTrx
* @param trxName
*/
void setInitialValues(int M_Product_ID, int C_BPartner_ID,
BigDecimal qty, boolean isSOTrx, String trxName);
/**
* Calculate Price
* @return true if calculated
*/
boolean calculatePrice();
/**
* Calculate Discount Percentage
* @return Discount
*/
BigDecimal getDiscount();
int getM_Product_ID();
int getM_PriceList_ID();
void setM_PriceList_ID(int M_PriceList_ID);
void setM_PriceList_Version_ID(int M_PriceList_Version_ID);
void setQty(BigDecimal qty);
/**
* Get Price Date
* @return date
*/
Timestamp getPriceDate();
/**
* Set Price Date
* @param priceDate date
*/
void setPriceDate(Timestamp priceDate);
/**
* Get C_UOM_ID
* @return uom
*/
int getC_UOM_ID();
/**
* Get Price List
* @return list
*/
BigDecimal getPriceList();
/**
* Get Price Std
* @return std
*/
BigDecimal getPriceStd();
/**
* Get Price Limit
* @return limit
*/
BigDecimal getPriceLimit();
/**
* Get Price List Currency
* @return currency
*/
int getC_Currency_ID();
/**
* Is Price List enforced?
* @return enforce limit
*/
boolean isEnforcePriceLimit();
/**
* Is a DiscountSchema active?
* @return active Discount Schema
*/
boolean isDiscountSchema();
/**
* Is the Price Calculated (i.e. found)?
* @return calculated
*/
boolean isCalculated();
/**
* Set order line and calculate the parameters from it
* @param orderLine
* @param trxName
*/
void setOrderLine(I_C_OrderLine orderLine, String trxName);
/**
* Set invoice line and calculate the parameters from it
* @param invoiceLine
* @param trxName
*/
void setInvoiceLine(I_C_InvoiceLine invoiceLine, String trxName);
/**
* Set project line and calculate the parameters from it
* @param projectLine
* @param trxName
*/
void setProjectLine(I_C_ProjectLine projectLine, String trxName);
/**
* Set requisition line and calculate the parameters from it
* @param reqLine
* @param trxName
*/
void setRequisitionLine(I_M_RequisitionLine reqLine, String trxName);
/**
* Set rma line and calculate the parameters from it
* @param rmaLine
* @param trxName
*/
void setRMALine(I_M_RMALine rmaLine, String trxName);
}

View File

@ -0,0 +1,20 @@
/******************************************************************************
* Copyright (C) 2017 Diego Ruiz *
* Copyright (C) 2017 Bx Service GmbH *
* 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. *
* 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., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.base;
public interface IProductPricingFactory {
public AbstractProductPricing newProductPricingInstance();
}

View File

@ -15,9 +15,9 @@ package org.adempiere.exceptions;
import java.text.DateFormat; import java.text.DateFormat;
import org.adempiere.base.IProductPricing;
import org.compiere.model.MPriceList; import org.compiere.model.MPriceList;
import org.compiere.model.MProduct; import org.compiere.model.MProduct;
import org.compiere.model.MProductPricing;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -36,12 +36,12 @@ public class ProductNotOnPriceListException extends AdempiereException
public static final String AD_Message = "ProductNotOnPriceList"; public static final String AD_Message = "ProductNotOnPriceList";
public ProductNotOnPriceListException(MProductPricing productPricing, int documentLineNo) public ProductNotOnPriceListException(IProductPricing productPricing, int documentLineNo)
{ {
super(buildMessage(productPricing, documentLineNo)); super(buildMessage(productPricing, documentLineNo));
} }
private static final String buildMessage (MProductPricing pp, int documentLineNo) private static final String buildMessage (IProductPricing pp, int documentLineNo)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (documentLineNo > 0) if (documentLineNo > 0)

View File

@ -1463,8 +1463,6 @@ public class GridTabCSVImporter implements IGridTabImporter
} }
private int resolveForeign(String foreignTable, String foreignColumn, Object value,Trx trx) { private int resolveForeign(String foreignTable, String foreignColumn, Object value,Trx trx) {
int id = -1;
boolean systemAccess = false; boolean systemAccess = false;
if (!"AD_Client".equals(foreignTable)) { if (!"AD_Client".equals(foreignTable)) {
MTable ft = MTable.get(Env.getCtx(), foreignTable); MTable ft = MTable.get(Env.getCtx(), foreignTable);

View File

@ -26,6 +26,7 @@ import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.Core; import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.adempiere.model.ITaxProvider; import org.adempiere.model.ITaxProvider;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -177,7 +178,7 @@ public class MInvoiceLine extends X_C_InvoiceLine
/** Cached Precision */ /** Cached Precision */
private Integer m_precision = null; private Integer m_precision = null;
/** Product Pricing */ /** Product Pricing */
private MProductPricing m_productPricing = null; private IProductPricing m_productPricing = null;
/** Parent */ /** Parent */
private MInvoice m_parent = null; private MInvoice m_parent = null;
@ -378,10 +379,9 @@ public class MInvoiceLine extends X_C_InvoiceLine
return; return;
// //
if (log.isLoggable(Level.FINE)) log.fine("M_PriceList_ID=" + M_PriceList_ID); if (log.isLoggable(Level.FINE)) log.fine("M_PriceList_ID=" + M_PriceList_ID);
m_productPricing = new MProductPricing (getM_Product_ID(), m_productPricing = Core.getProductPricing();
C_BPartner_ID, getQtyInvoiced(), m_IsSOTrx, get_TrxName()); m_productPricing.setInvoiceLine(this, get_TrxName());
m_productPricing.setM_PriceList_ID(M_PriceList_ID); m_productPricing.setM_PriceList_ID(M_PriceList_ID);
m_productPricing.setPriceDate(m_DateInvoiced);
// //
setPriceActual (m_productPricing.getPriceStd()); setPriceActual (m_productPricing.getPriceStd());
setPriceList (m_productPricing.getPriceList()); setPriceList (m_productPricing.getPriceList());

View File

@ -23,6 +23,7 @@ import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.Core; import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.ProductNotOnPriceListException; import org.adempiere.exceptions.ProductNotOnPriceListException;
import org.adempiere.model.ITaxProvider; import org.adempiere.model.ITaxProvider;
@ -196,7 +197,7 @@ public class MOrderLine extends X_C_OrderLine
// //
protected boolean m_IsSOTrx = true; protected boolean m_IsSOTrx = true;
// Product Pricing // Product Pricing
protected MProductPricing m_productPrice = null; protected IProductPricing m_productPrice = null;
/** Tax */ /** Tax */
protected MTax m_tax = null; protected MTax m_tax = null;
@ -321,12 +322,11 @@ public class MOrderLine extends X_C_OrderLine
* @param M_PriceList_ID id * @param M_PriceList_ID id
* @return product pricing * @return product pricing
*/ */
protected MProductPricing getProductPricing (int M_PriceList_ID) protected IProductPricing getProductPricing (int M_PriceList_ID)
{ {
m_productPrice = new MProductPricing (getM_Product_ID(), m_productPrice = Core.getProductPricing();
getC_BPartner_ID(), getQtyOrdered(), m_IsSOTrx, get_TrxName()); m_productPrice.setOrderLine(this, get_TrxName());
m_productPrice.setM_PriceList_ID(M_PriceList_ID); m_productPrice.setM_PriceList_ID(M_PriceList_ID);
m_productPrice.setPriceDate(getDateOrdered());
// //
m_productPrice.calculatePrice(); m_productPrice.calculatePrice();
return m_productPrice; return m_productPrice;

View File

@ -22,6 +22,7 @@ import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.AbstractProductPricing;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -33,13 +34,19 @@ import org.compiere.util.Trace;
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MProductPricing.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $ * @version $Id: MProductPricing.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
*/ */
public class MProductPricing public class MProductPricing extends AbstractProductPricing
{ {
private String trxName=null; private String trxName=null;
/** /**
* Constructor * New constructor to be used with the ProductPriceFactories
*/
public MProductPricing() {}
/**
* Old Constructor to keep backward
* compatibility
* @param M_Product_ID product * @param M_Product_ID product
* @param C_BPartner_ID partner * @param C_BPartner_ID partner
* @param Qty quantity * @param Qty quantity
@ -49,17 +56,7 @@ public class MProductPricing
public MProductPricing (int M_Product_ID, int C_BPartner_ID, public MProductPricing (int M_Product_ID, int C_BPartner_ID,
BigDecimal Qty, boolean isSOTrx, String trxName) BigDecimal Qty, boolean isSOTrx, String trxName)
{ {
this.trxName=trxName; setInitialValues(M_Product_ID, C_BPartner_ID, Qty, isSOTrx, trxName);
m_M_Product_ID = M_Product_ID;
m_C_BPartner_ID = C_BPartner_ID;
if (Qty != null && Env.ZERO.compareTo(Qty) != 0)
m_Qty = Qty;
m_isSOTrx = isSOTrx;
int thereAreVendorBreakRecords = DB.getSQLValue(trxName,
"SELECT count(M_Product_ID) FROM M_ProductPriceVendorBreak WHERE M_Product_ID=? AND (C_BPartner_ID=? OR C_BPartner_ID is NULL)",
m_M_Product_ID, m_C_BPartner_ID);
m_useVendorBreak = thereAreVendorBreakRecords > 0;
} }
@ -77,12 +74,19 @@ public class MProductPricing
this(M_Product_ID,C_BPartner_ID,Qty,isSOTrx,null); this(M_Product_ID,C_BPartner_ID,Qty,isSOTrx,null);
} // MProductPricing } // MProductPricing
private int m_M_Product_ID; @Override
private int m_C_BPartner_ID; public void setInitialValues(int M_Product_ID, int C_BPartner_ID, BigDecimal qty, boolean isSOTrx, String trxName) {
private BigDecimal m_Qty = Env.ONE; super.setInitialValues(M_Product_ID, C_BPartner_ID, qty, isSOTrx, trxName);
private boolean m_isSOTrx = true; checkVendorBreak();
// }
private int m_M_PriceList_ID = 0;
private void checkVendorBreak() {
int thereAreVendorBreakRecords = DB.getSQLValue(trxName,
"SELECT count(M_Product_ID) FROM M_ProductPriceVendorBreak WHERE M_Product_ID=? AND (C_BPartner_ID=? OR C_BPartner_ID is NULL)",
m_M_Product_ID, m_C_BPartner_ID);
m_useVendorBreak = thereAreVendorBreakRecords > 0;
}
private int m_M_PriceList_Version_ID = 0; private int m_M_PriceList_Version_ID = 0;
private Timestamp m_PriceDate; private Timestamp m_PriceDate;
/** Precision -1 = no rounding */ /** Precision -1 = no rounding */
@ -828,32 +832,13 @@ public class MProductPricing
/**************************************************************************
* Get Product ID
* @return id
*/
public int getM_Product_ID()
{
return m_M_Product_ID;
}
/**
* Get PriceList ID
* @return pl
*/
public int getM_PriceList_ID()
{
return m_M_PriceList_ID;
} // getM_PriceList_ID
/** /**
* Set PriceList * Set PriceList
* @param M_PriceList_ID pl * @param M_PriceList_ID pl
*/ */
public void setM_PriceList_ID( int M_PriceList_ID) public void setM_PriceList_ID( int M_PriceList_ID)
{ {
m_M_PriceList_ID = M_PriceList_ID; super.setM_PriceList_ID(M_PriceList_ID);
m_calculated = false; m_calculated = false;
} // setM_PriceList_ID } // setM_PriceList_ID
@ -872,26 +857,17 @@ public class MProductPricing
*/ */
public void setM_PriceList_Version_ID (int M_PriceList_Version_ID) public void setM_PriceList_Version_ID (int M_PriceList_Version_ID)
{ {
m_M_PriceList_Version_ID = M_PriceList_Version_ID; super.setM_PriceList_Version_ID(M_PriceList_Version_ID);
m_calculated = false; m_calculated = false;
} // setM_PriceList_Version_ID } // setM_PriceList_Version_ID
/**
* Get Price Date
* @return date
*/
public Timestamp getPriceDate()
{
return m_PriceDate;
} // getPriceDate
/** /**
* Set Price Date * Set Price Date
* @param priceDate date * @param priceDate date
*/ */
public void setPriceDate(Timestamp priceDate) public void setPriceDate(Timestamp priceDate)
{ {
m_PriceDate = priceDate; super.setPriceDate(priceDate);
m_calculated = false; m_calculated = false;
} // setPriceDate } // setPriceDate
@ -1006,4 +982,34 @@ public class MProductPricing
return m_calculated; return m_calculated;
} // isCalculated } // isCalculated
@Override
public void setOrderLine(I_C_OrderLine orderLine, String trxName) {
super.setOrderLine(orderLine, trxName);
checkVendorBreak();
}
@Override
public void setInvoiceLine(I_C_InvoiceLine invoiceLine, String trxName) {
super.setInvoiceLine(invoiceLine, trxName);
checkVendorBreak();
}
@Override
public void setProjectLine(I_C_ProjectLine projectLine, String trxName) {
super.setProjectLine(projectLine, trxName);
checkVendorBreak();
}
@Override
public void setRequisitionLine(I_M_RequisitionLine reqLine, String trxName) {
super.setRequisitionLine(reqLine, trxName);
checkVendorBreak();
}
@Override
public void setRMALine(I_M_RMALine rmaLine, String trxName) {
super.setRMALine(rmaLine, trxName);
checkVendorBreak();
}
} // MProductPrice } // MProductPrice

View File

@ -21,6 +21,8 @@ import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -146,9 +148,8 @@ public class MProjectLine extends X_C_ProjectLine
return limitPrice; return limitPrice;
if (getProject() == null) if (getProject() == null)
return limitPrice; return limitPrice;
boolean isSOTrx = true; IProductPricing pp = Core.getProductPricing();
MProductPricing pp = new MProductPricing (getM_Product_ID(), pp.setProjectLine(this, get_TrxName());
m_parent.getC_BPartner_ID(), getPlannedQty(), isSOTrx, get_TrxName());
pp.setM_PriceList_ID(m_parent.getM_PriceList_ID()); pp.setM_PriceList_ID(m_parent.getM_PriceList_ID());
if (pp.calculatePrice()) if (pp.calculatePrice())
limitPrice = pp.getPriceLimit(); limitPrice = pp.getPriceLimit();

View File

@ -22,6 +22,7 @@ import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.Core; import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.adempiere.model.ITaxProvider; import org.adempiere.model.ITaxProvider;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -147,7 +148,8 @@ public class MRMALine extends X_M_RMALine
} }
else if (getM_Product_ID() != 0) else if (getM_Product_ID() != 0)
{ {
MProductPricing pp = new MProductPricing (getM_Product_ID(), getParent().getC_BPartner_ID(), Env.ONE, getParent().isSOTrx(), get_TrxName()); IProductPricing pp = Core.getProductPricing();
pp.setRMALine(this, get_TrxName());
MInvoice invoice = getParent().getOriginalInvoice(); MInvoice invoice = getParent().getOriginalInvoice();
if (invoice != null) if (invoice != null)
@ -351,7 +353,7 @@ public class MRMALine extends X_M_RMALine
} }
// Set default amount and qty for product // Set default amount and qty for product
if (this.getM_Product_ID() != 0 && this.getQty().doubleValue() <= 0) if (this.getM_Product_ID() != 0 && this.getQty().doubleValue() <= 0 && !MRMA.DOCACTION_Void.equals(getParent().getDocAction()))
{ {
if (getQty().signum() == 0) if (getQty().signum() == 0)
this.setQty(Env.ONE); this.setQty(Env.ONE);
@ -360,7 +362,7 @@ public class MRMALine extends X_M_RMALine
} }
// Set default amount and qty for charge // Set default amount and qty for charge
if (this.getC_Charge_ID() != 0 && this.getQty().doubleValue() <= 0) if (this.getC_Charge_ID() != 0 && this.getQty().doubleValue() <= 0 && !MRMA.DOCACTION_Void.equals(getParent().getDocAction()))
{ {
if (getQty().signum() == 0) if (getQty().signum() == 0)
this.setQty(Env.ONE); this.setQty(Env.ONE);
@ -369,7 +371,7 @@ public class MRMALine extends X_M_RMALine
} }
// Set amount for products // Set amount for products
if (this.getM_InOutLine_ID() != 0) if (this.getM_InOutLine_ID() != 0 && !MRMA.DOCACTION_Void.equals(getParent().getDocAction()))
{ {
this.setM_Product_ID(m_ioLine.getM_Product_ID()); this.setM_Product_ID(m_ioLine.getM_Product_ID());
this.setC_Charge_ID(m_ioLine.getC_Charge_ID()); this.setC_Charge_ID(m_ioLine.getC_Charge_ID());

View File

@ -23,6 +23,8 @@ import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.Core;
import org.adempiere.base.IProductPricing;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -232,9 +234,8 @@ public class MRequisitionLine extends X_M_RequisitionLine
return; return;
// //
if (log.isLoggable(Level.FINE)) log.fine("M_PriceList_ID=" + M_PriceList_ID); if (log.isLoggable(Level.FINE)) log.fine("M_PriceList_ID=" + M_PriceList_ID);
boolean isSOTrx = false; IProductPricing pp = Core.getProductPricing();
MProductPricing pp = new MProductPricing (getM_Product_ID(), pp.setRequisitionLine(this, get_TrxName());
getC_BPartner_ID(), getQty(), isSOTrx, get_TrxName());
pp.setM_PriceList_ID(M_PriceList_ID); pp.setM_PriceList_ID(M_PriceList_ID);
// pp.setPriceDate(getDateOrdered()); // pp.setPriceDate(getDateOrdered());
// //

View File

@ -621,7 +621,7 @@ public class ModelValidationEngine
return; return;
// //
String propertyName = String propertyName =
m_globalValidators.contains(listener) (listener instanceof ModelValidator && m_globalValidators.contains((ModelValidator)listener))
? tableName + "*" ? tableName + "*"
: tableName + listener.getAD_Client_ID(); : tableName + listener.getAD_Client_ID();
ArrayList<FactsValidator> list = m_factsValidateListeners.get(propertyName); ArrayList<FactsValidator> list = m_factsValidateListeners.get(propertyName);
@ -666,7 +666,7 @@ public class ModelValidationEngine
if (tableName == null || listener == null) if (tableName == null || listener == null)
return; return;
String propertyName = String propertyName =
m_globalValidators.contains(listener) (listener instanceof ModelValidator && m_globalValidators.contains((ModelValidator)listener))
? tableName + "*" ? tableName + "*"
: tableName + listener.getAD_Client_ID(); : tableName + listener.getAD_Client_ID();
ArrayList<FactsValidator> list = m_factsValidateListeners.get(propertyName); ArrayList<FactsValidator> list = m_factsValidateListeners.get(propertyName);
@ -733,7 +733,7 @@ public class ModelValidationEngine
{ {
validator = list.get(i); validator = list.get(i);
if (validator.getAD_Client_ID() == po.getAD_Client_ID() if (validator.getAD_Client_ID() == po.getAD_Client_ID()
|| m_globalValidators.contains(validator)) || (validator instanceof ModelValidator && m_globalValidators.contains((ModelValidator)validator)))
{ {
String error = validator.factsValidate(schema, facts, po); String error = validator.factsValidate(schema, facts, po);
if (error != null && error.length() > 0) if (error != null && error.length() > 0)

View File

@ -0,0 +1,298 @@
/******************************************************************************
* 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. *
* 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., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
* For the text or an alternative of this public license, you may reach us *
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
* or via info@compiere.org or http://www.compiere.org/license.html *
*****************************************************************************/
package org.compiere.util;
import java.math.BigDecimal;
/**
* Amount in Words for Zh_CN (CNY in Simplified Chinese)
* @author z5k1@qq.com
* @version $Id: AmtInWords_ZH.java,v1.0 2017/09/21 00:54:35 $
*
* The class is based on the AmtInWords_EN.java written by jjanke
* The algorithm is based on code named snhongtenzone@foxmail.com
*
* Rule:
* 1. CNY is an currency of 10000-unit scale, dislike dollar with 1000-unit scale.
* 2. CNY currency accuracy is 0.01. And it's under a strict decimal number system.
* 3. Option of add an "zero" after "Yuan" is false. (Line 186)
* Reference: [1997]393 People's Bank of China "the Measures for Payment and Settlement"
* \u53c2\u8003: \u4e2d\u56fd\u4eba\u6c11\u94f6\u884c \u94f6\u53d1[1997]393\u53f7 \u300a\u652f\u4ed8\u7ed3\u7b97\u529e\u6cd5\u300b\u9644\u4ef6\u300a\u6b63\u786e\u586b\u5199\u7968\u636e\u548c\u7ed3\u7b97\u51ed\u8bc1\u7684\u57fa\u672c\u89c4\u5b9a\u300b
*
*
* Results: (Rule 3 = true)
*
* 0.00 \u96f6\u5143\u6574 \uff08\u6d4b\u8bd5\uff1a\u91d1\u989d\u4e3a 0\uff09
* 0.03 \u53c1\u5206 \uff08\u6d4b\u8bd5\uff1a\u89d20\u5206\u975e0\uff0c\u5916\u52a0 \u51430\uff09
* 0.234 \u8d30\u89d2\u53c1\u5206 \uff08\u6d4b\u8bd5\uff1a\u89d2\u975e0\u5206\u975e0\uff0c\u820d4\uff09
* 1.001 \u58f9\u5143\u6574 \uff08\u6d4b\u8bd5\uff1a\u89d20\u52060\uff0c\u52a0 \u201c \u6574 \u201d\uff0c\u820d1\uff09
* 1.035 \u58f9\u5143\u96f6\u8086\u5206 \uff08\u89c4\u52194.4\uff1a\u89d20\u5206\u975e0\uff0c\u52a0\u96f6\uff0c\u51655\uff09
* 1.205 \u58f9\u5143\u8d30\u89d2\u58f9\u5206 \uff08\u6d4b\u8bd5\uff1a\u89d2\u975e0\u52060\uff0c\u51655\u540e\uff0c\u89d2\u975e0\u5206\u975e0\uff09
* 1.3345 \u58f9\u5143\u53c1\u89d2\u53c1\u5206 \uff08\u6d4b\u8bd5\uff1a\u5c0f\u6570\u70b94\u4f4d\uff09
* 10.03 \u58f9\u62fe\u5143\u96f6\u53c1\u5206 \uff08\u89c4\u52194.4\uff1a\u89d20\u5206\u975e0\uff0c\u52a0\u96f6\uff09
* 10.23 \u58f9\u62fe\u5143\u96f6\u8d30\u89d2\u53c1\u5206 \uff08\u89c4\u52194.3\uff1a\u51430\u89d2\u975e0\uff0c\u53ef\u9009\u52a0\u96f6\uff09
* 23.00 \u8d30\u62fe\u53c1\u5143\u6574 \uff08\u89c4\u52192\uff1a\u52a0 \u201c \u6574 \u201d\uff09
* 100.20 \u58f9\u4f70\u5143\u96f6\u8d30\u89d2 \uff08\u89c4\u52194.2 \u591a\u96f6\u5199\u4e00\u96f6\uff0c\u89d2\u975e0\u52060\uff09
* 103.45 \u58f9\u4f70\u96f6\u53c1\u5143\u8086\u89d2\u4f0d\u5206 \uff08\u89c4\u52194.1\uff1a\u67090\u52a0 \u201c \u96f6 \u201d\uff0c\u89d2\u975e0\u5206\u975e0\uff09
* 2,345 \u8d30\u4edf\u53c1\u4f70\u8086\u62fe\u4f0d\u5143\u6574 \uff08\u89c4\u52192\uff1a\u52a0 \u201c \u6574 \u201d\uff09
* 1020.45 \u58f9\u4edf\u96f6\u8d30\u62fe\u5143\u96f6\u8086\u89d2\u4f0d\u5206 \uff08\u89c4\u52194.1+4.3\uff1a\u67090\u52a0 \u201c \u96f6 \u201d\uff1b\u51430\u89d2\u975e0\uff0c\u53ef\u9009\u52a0\u96f6\uff09
* 1,234.56 \u58f9\u4edf\u8d30\u4f70\u53c1\u62fe\u8086\u5143\u4f0d\u89d2\u9646\u5206 \uff08\u6d4b\u8bd5\uff1a\u5343\u5206\u4f4d \u662f\u5426\u6b63\u786e\uff09
* 12345.78 \u58f9\u4e07\u8d30\u4edf\u53c1\u4f70\u8086\u62fe\u4f0d\u5143\u67d2\u89d2\u634c\u5206 \uff08\u6d4b\u8bd5\uff1a\u5343\u5206\u4f4d \u662f\u5426\u6b63\u786e\uff09
* 100457.89 \u58f9\u62fe\u4e07\u96f6\u8086\u4f70\u4f0d\u62fe\u67d2\u5143\u634c\u89d2\u7396\u5206 \uff08\u89c4\u52194.2\uff1a\u591a\u96f6\u5199\u4e00\u96f6\uff09
* 103457.89 \u58f9\u62fe\u4e07\u96f6\u53c1\u4edf\u8086\u4f70\u4f0d\u62fe\u67d2\u5143\u634c\u89d2\u7396\u5206 \uff08\u89c4\u52194.3\uff1a\u4e070\u5343\u975e\u96f6\uff0c\u53ef\u9009\u52a0\u96f6\uff09
* 107000.03 \u58f9\u62fe\u4e07\u96f6\u67d2\u4edf\u5143\u96f6\u53c1\u5206 \uff08\u89c4\u52194.3+4.4\uff1a\u4e070\u51430\u5343\u975e0\uff0c\u4e2d\u95f4\u591a0\uff0c\u89d20\uff0c\u53ef\u9009\u52a0\u96f6\uff09
* 9,000,000.00 \u7396\u4f70\u4e07\u5143\u6574 \uff08\u89c4\u5219: 4\u4f4d\u8fdb\u5236\uff09
* 10,000,000.00 \u58f9\u4edf\u4e07\u5143\u6574 \uff08\u6d4b\u8bd5\uff1a4\u4f4d\u8fdb\u5236\uff09
* 10220134 \u58f9\u4edf\u96f6\u8d30\u62fe\u8d30\u4e07\u96f6\u58f9\u4f70\u53c1\u62fe\u8086\u5143\u6574 \uff08\u6d4b\u8bd5\uff1a\u65e0\u5343\u5206\u4f4d \u201c\u662f\u5426\u6b63\u786e\uff09
* 100,234,578.90 \u58f9\u4ebf\u96f6\u8d30\u62fe\u53c1\u4e07\u8086\u4edf\u4f0d\u4f70\u67d2\u62fe\u634c\u5143\u7396\u89d2 \uff08\u6d4b\u8bd5\uff1a\u4ebf\uff09
* 203010000.56 \u8d30\u4ebf\u96f6\u53c1\u4f70\u96f6\u58f9\u4e07\u5143\u96f6\u4f0d\u89d2\u9646\u5206 \uff08\u6d4b\u8bd5\uff1a\u4ebf\u96f6\uff0c\u4e07\u96f6\uff0c\u5143\uff09
* 103,004,000.90 \u58f9\u4ebf\u96f6\u53c1\u4f70\u4e07\u96f6\u8086\u4edf\u5143\u96f6\u7396\u89d2 \uff08\u89c4\u52194.2+4.3\uff1a\u591a\u96f6\u5199\u4e00\u96f6\uff0c\u4e070\u5343\u975e\u96f6\uff0c\u4e2d\u95f4\u591a0\uff0c\u53ef\u9009\u52a0\u96f6\uff09
* 1,201,034,578.90 \u58f9\u62fe\u8d30\u4ebf\u96f6\u58f9\u4f70\u96f6\u53c1\u4e07\u8086\u4edf\u4f0d\u4f70\u67d2\u62fe\u634c\u5143\u7396\u89d2 \uff08\u6d4b\u8bd5\uff1a\u5341\u4ebf\uff0c3\u4e2a\u5343\u5206\u4f4d \u662f\u5426\u6b63\u786e\uff09
* 90,000,000,000 \u7396\u4f70\u4ebf\u5143\u6574 \uff08\u6d4b\u8bd5\uff1a4\u4f4d\u8fdb\u5236\uff09
* 100,000,000,000 \u58f9\u4edf\u4ebf\u5143\u6574 \uff08\u6d4b\u8bd5\uff1a4\u4f4d\u8fdb\u5236\uff09
* 1,932,110,345,780 \u58f9\u5146\u7396\u4edf\u53c1\u4f70\u8d30\u62fe\u58f9\u4ebf\u58f9\u4edf\u96f6\u53c1\u62fe\u8086\u4e07\u4f0d\u4edf\u67d2\u4f70\u634c\u62fe\u5143\u6574 \uff08\u6d4b\u8bd5\uff1a13\u4f4d\u6574\u6570\uff0c\u5146\uff0c4\u4e2a\u5343\u5206\u4f4d\uff09
* 10,000,000,000,000 \u9519\u8bef \uff08\u6d4b\u8bd5\uff1a\u8d85\u8fc7\u6216\u7b49\u4e8e\u6700\u5927\u4f4d\u657010\u5146\uff0c\u6570\u5b57\u5fc5\u987b\u5c0f\u4e8e14\u4f4d\uff09
* -1220.354 \u8d1f\u58f9\u4edf\u8d30\u4f70\u8d30\u62fe\u5143\u96f6\u53c1\u89d2\u4f0d\u5206 \uff08\u6d4b\u8bd5\uff1a\u8d1f\u6570\uff0c\u56db\u820d\u4e94\u5165\uff09
* 1.222,33 \u9519\u8bef \uff08\u6d4b\u8bd5\uff1a\u975e\u6cd5\u5b57\u7b26\uff09
*
*/
public class AmtInWords_ZH implements AmtInWords
{
/**
* AmtInWords_ZH
*/
public AmtInWords_ZH ()
{
super ();
} // AmtInWords_ZH
/** Currency scales */
private static final String[] scaleNames =
{
"\u5206", // 0 0.01
"\u89d2", // 1 0.1
"\u5143", // 2 1 \uff0810^0\uff09
"\u62fe", // 3 10
"\u4f70", // 4 100
"\u4edf", // 5 1000
"\u4e07", // 6 10000 \uff0810^4\uff09
"\u62fe", // 7 10*10000
"\u4f70", // 8 100*10000
"\u4edf", // 9 1000*10000
"\u4ebf", // 10 100000000 \uff0810^8\uff09 \u4e07\u4e07\u4e3a\u4ebf
"\u62fe", // 11 10*100000000
"\u4f70", // 12 100*100000000
"\u4edf", // 13 1000*100000000
"\u5146", // 14 1000000000000 \uff0810^12\uff09 \u4e07\u4ebf\u4e3a\u5146
};
/** numbers 0 to 9 */
private static final String[] numNames =
{
"\u96f6", // 0
"\u58f9", // 1
"\u8d30", // 2
"\u53c1", // 3
"\u8086", // 4
"\u4f0d", // 5
"\u9646", // 6
"\u67d2", // 7
"\u634c", // 8
"\u7396" // 9
};
private static final String CNY_NEGATIVE = "\u8d1f";
private static final String CNY_FULL = "\u6574";
private static final String CNY_ZEOR_FULL = "\u96f6\u5143\u6574";
/**
* Convert
* @description Convert BigDecimal number to String
* @param number (-5432.135 with no period)
* @return amt (amt in words of CNY)
*/
private String convert (BigDecimal number)
{
StringBuffer sb = new StringBuffer();
int signum = number.signum(); // positive , 0 , negative
int numUnit = 0; // each number character
int numIndex = 0; // each number position
int zeroSize = 0; // sizes of zero
// number = 0
if (signum == 0){
return CNY_ZEOR_FULL; // zero_full
}
// round to 1/100, get long number ,eg -5432.135 = 543214
long lnumber = number.movePointRight(2).setScale(0, BigDecimal.ROUND_HALF_UP).abs().longValue();
// number must less 10000000000000 (10^13)
if (lnumber >= 1000000000000000L) {
return "\u4eb2\uff0c\u91d1\u989d\u8f6c\u6362\u4e0a\u9650\u4e3a10\u5146\uff0810\u4e07\u4ebf\uff09";
}
// get the last 2 number (decimal number) ,eg 543214 = 14
long decamt = lnumber % 100;
boolean getZero = false; // sign of zero
// decimal options\uff1a00 = 0, 01 = 1, 10, 11
// decimal = 00
if (!(decamt > 0)) { // special decimal case 00
numIndex = 2; // 2, begin from "Yuan"
lnumber = lnumber / 100; // eg: 5432.00 = 543200 = 5432
getZero = true;
}
// decimal = 10
if ((decamt > 0) && (!(decamt % 10 > 0))) { // special decimal case 10
numIndex = 1; // 1, begin from "Jiao"
lnumber = lnumber / 10; // eg: 5432.10 = 543210 = 54321
getZero = true;
}
// begin foreach for all cases
while (true) {
if (lnumber <= 0) { // each character done
break;
}
// get the last number each
numUnit = (int) (lnumber % 10);
if (numUnit > 0) { // Character = 1-9 ,insert (number + scale)
if ((numIndex == 9) && (zeroSize >= 3)) { // special 9 (8th), eg: 10,000,000
sb.insert(0, scaleNames[6]); // add "WAN"
}
if ((numIndex == 13) && (zeroSize >= 3)) { // special 13 (11st), eg: 100,000,000,000
sb.insert(0, scaleNames[10]); // add "YI"
}
sb.insert(0, scaleNames[numIndex]); // first insert scale to Chinese
sb.insert(0, numNames[numUnit]); // then insert number to Chinese
getZero = false;
zeroSize = 0;
} else { // Character = 0, insert (scale + 0 )
++zeroSize;
if (!(getZero) & numIndex != 2) { // separated zero and option of "YUAN" suffix
sb.insert(0, numNames[numUnit]); // first insert 0 to Chinese
} //
if (numIndex == 2) { // option1: "YUAN"=0
sb.insert(0, scaleNames[numIndex]); // then insert scale to Chinese
} // option2: "WAN"|"YI"|"ZHAO" =0
else if (((numIndex - 2) % 4 == 0) && (lnumber % 1000 > 0)) { // special 4th,8th, eg: 9,000,000 or 90,000,000,000
sb.insert(0, scaleNames[numIndex]); // then insert scale to Chinese
}
getZero = true; // multi-zero nothing added
}
lnumber = lnumber / 10; // cut the last number off each
++numIndex; // ++ position of number
}
// add suffix of "zheng" when decimal = 00
if (!(decamt > 0)) {
sb.append(CNY_FULL); // add suffix CNY_full
}
// add prefix of "fu" when negative
if (signum == -1) {
sb.insert(0, CNY_NEGATIVE); // add prefix negative
}
return sb.toString(); // return amt string completed
} // convert
/**************************************************************************
* Get Amount in Words
* @param amount numeric amount (352.80)
* @return amount in words
* @throws Exception
*/
public String getAmtInWords (String amount) throws Exception
{
if (amount == null || amount.length() <= 0) // null string
return amount;
//TODO: Check string illegal character
amount = amount.replaceAll (",", ""); // fire period ","
//TODO: 1.234,56 as comma replace period
StringBuilder sb = new StringBuilder ();
BigDecimal cny = new BigDecimal(amount); // convert String to BigDecimal
sb.append (convert (cny)); // get result string from convert
return sb.toString (); // return
}
/**
* Test Print
* @param amt amount
*/
private void print (String amt)
{
try
{
System.out.println(amt + " = " + getAmtInWords(amt));
}
catch (Exception e)
{
e.printStackTrace();
}
} // print
/**
* Test
* @param args ignored
*/
public static void main (String[] args)
{
AmtInWords_ZH aiw = new AmtInWords_ZH();
aiw.print (null);
aiw.print ("");
aiw.print ("0.00");
aiw.print ("0.03");
aiw.print ("0.234");
aiw.print ("1.001");
aiw.print ("1.035");
aiw.print ("1.205");
aiw.print ("1.3345");
aiw.print ("10.03");
aiw.print ("10.23");
aiw.print ("23.00");
aiw.print ("100.20");
aiw.print ("103.45");
aiw.print ("2,345");
aiw.print ("1020.45");
aiw.print ("1,234.56");
aiw.print ("12345.78");
aiw.print ("100457.89");
aiw.print ("103457.89");
aiw.print ("107000.03");
aiw.print ("9,000,000.00"); // Line 189
aiw.print ("10,000,000.00"); // Line 171
aiw.print ("10220134");
aiw.print ("100,234,578.90");
aiw.print ("203010000.56");
aiw.print ("103,004,000.90");
aiw.print ("1,201,034,578.90");
aiw.print ("90,000,000,000"); // Line 189
aiw.print ("100,000,000,000"); // Line 174
aiw.print ("1,932,110,345,780");
aiw.print ("10,000,000,000,000");
aiw.print ("-1220.354");
// aiw.print ("1.234,56"); ERROR
} // main
}

View File

@ -61,6 +61,8 @@ public class ImportInventoryMove extends SvrProcess
private boolean m_IsImportOnlyNoErrors = true; private boolean m_IsImportOnlyNoErrors = true;
private boolean m_ErrorsFound = false;
private String m_docAction = MMovement.DOCACTION_Prepare; private String m_docAction = MMovement.DOCACTION_Prepare;
private boolean isImported = false; private boolean isImported = false;
@ -127,13 +129,18 @@ public class ImportInventoryMove extends SvrProcess
private void importRecords() private void importRecords()
{ {
if (m_IsImportOnlyNoErrors && m_ErrorsFound)
return; // not importing because error were found
isImported = false; isImported = false;
for(X_I_Movement imove : getRecords(false,m_IsImportOnlyNoErrors)) for(X_I_Movement imove : getRecords(false,true))
{ {
MMovement mov = importMInventoryMove(imove); MMovement mov = importMInventoryMove(imove);
if(mov!= null) if(mov!= null)
{ {
imove.setM_Movement_ID(mov.getM_Movement_ID());
imove.saveEx();
isImported = importMInventoryMoveLine(mov,imove); isImported = importMInventoryMoveLine(mov,imove);
} }
else else
@ -143,7 +150,6 @@ public class ImportInventoryMove extends SvrProcess
if(isImported) if(isImported)
{ {
imove.setM_Movement_ID(mov.getM_Movement_ID());
imove.setI_IsImported(true); imove.setI_IsImported(true);
imove.setProcessed(true); imove.setProcessed(true);
imove.saveEx(); imove.saveEx();
@ -156,7 +162,7 @@ public class ImportInventoryMove extends SvrProcess
else else
{ {
imove.setI_IsImported(false); imove.setI_IsImported(false);
imove.setProcessed(true); imove.setProcessed(false);
imove.saveEx(); imove.saveEx();
notimported++; notimported++;
} }
@ -331,15 +337,20 @@ public class ImportInventoryMove extends SvrProcess
*/ */
private void fillIDValues() private void fillIDValues()
{ {
for(X_I_Movement imove : getRecords(false, m_IsImportOnlyNoErrors)) m_ErrorsFound = false;
for(X_I_Movement imove : getRecords(false, false))
{ {
//if(imov.getAD_Org_ID()==0) if(imove.getAD_Org_ID()==0) {
imove.setAD_Org_ID(getID(MOrg.Table_Name,"Value = ?", new Object[]{imove.getOrgValue()})); int orgId = getID(MOrg.Table_Name,"Value = ?", new Object[]{imove.getOrgValue()});
if (orgId >= 0) {
imove.setAD_Org_ID(orgId);
}
}
if(imove.getM_Product_ID()==0) if(imove.getM_Product_ID()==0)
imove.setM_Product_ID(getID(MProduct.Table_Name,"Value = ?", new Object[]{imove.getProductValue()})); imove.setM_Product_ID(getID(MProduct.Table_Name,"Value = ?", new Object[]{imove.getProductValue()}));
//if(imov.getM_Locator_ID()==0) if(imove.getM_Locator_ID()==0)
imove.setM_Locator_ID(getID(MLocator.Table_Name,"Value = ?", new Object[]{imove.getLocatorValue()})); imove.setM_Locator_ID(getID(MLocator.Table_Name,"Value = ?", new Object[]{imove.getLocatorValue()}));
//if(imov.getM_LocatorTo_ID()==0) if(imove.getM_LocatorTo_ID()==0)
imove.setM_LocatorTo_ID(getID(MLocator.Table_Name,"Value = ?", new Object[]{imove.getLocatorToValue()})); imove.setM_LocatorTo_ID(getID(MLocator.Table_Name,"Value = ?", new Object[]{imove.getLocatorToValue()}));
if(imove.getC_DocType_ID()==0) if(imove.getC_DocType_ID()==0)
imove.setC_DocType_ID(getID(MDocType.Table_Name,"Name=?", new Object[]{imove.getDocTypeName()})); imove.setC_DocType_ID(getID(MDocType.Table_Name,"Name=?", new Object[]{imove.getDocTypeName()}));
@ -354,9 +365,6 @@ public class ImportInventoryMove extends SvrProcess
if(imove.getAD_OrgTrx_ID()==0) if(imove.getAD_OrgTrx_ID()==0)
imove.setAD_OrgTrx_ID(getID(MOrg.Table_Name, "Value = ?", new Object[]{imove.getOrgTrxValue()})); imove.setAD_OrgTrx_ID(getID(MOrg.Table_Name, "Value = ?", new Object[]{imove.getOrgTrxValue()}));
imove.saveEx();
StringBuilder err = new StringBuilder(""); StringBuilder err = new StringBuilder("");
if(imove.getAD_Org_ID() <=0) if(imove.getAD_Org_ID() <=0)
err.append(" @AD_Org_ID@ @NotFound@,"); err.append(" @AD_Org_ID@ @NotFound@,");
@ -373,12 +381,17 @@ public class ImportInventoryMove extends SvrProcess
if(imove.getC_DocType_ID()<=0) if(imove.getC_DocType_ID()<=0)
err.append(" @C_DocType_ID@ @NotFound@,"); err.append(" @C_DocType_ID@ @NotFound@,");
if(err.toString()!=null && err.toString().length()>0) if (imove.getMovementQty().signum() == 0)
{ err.append(" @MovementQty@ @NotFound@,");
if(err.toString()!=null && err.toString().length()>0) {
notimported++; notimported++;
m_ErrorsFound = true;
imove.setI_ErrorMsg(Msg.parseTranslation(getCtx(), err.toString())); imove.setI_ErrorMsg(Msg.parseTranslation(getCtx(), err.toString()));
imove.saveEx(); } else {
imove.setI_ErrorMsg(null);
} }
imove.saveEx();
} }
} }
@ -397,17 +410,17 @@ public class ImportInventoryMove extends SvrProcess
/** /**
* get all records in X_I_ProductPlanning table * get all records in X_I_Movement table
* @param imported boolean * @param imported boolean
* @param isWithError boolean * @param isWithoutError boolean
* @return collection of X_I_ProductPlanning records * @return collection of X_I_Movement records
*/ */
private Collection<X_I_Movement> getRecords(boolean imported, boolean isWithError) private Collection<X_I_Movement> getRecords(boolean imported, boolean isWithoutError)
{ {
final StringBuffer whereClause = new StringBuffer(X_I_Movement.COLUMNNAME_I_IsImported) final StringBuffer whereClause = new StringBuffer(X_I_Movement.COLUMNNAME_I_IsImported)
.append("=?"); .append("=?");
if(isWithError) if(isWithoutError)
{ {
whereClause.append(" AND ").append(X_I_Movement.COLUMNNAME_I_ErrorMsg).append(" IS NULL"); whereClause.append(" AND ").append(X_I_Movement.COLUMNNAME_I_ErrorMsg).append(" IS NULL");
} }

View File

@ -2,10 +2,12 @@ package org.adempiere.report.jasper;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import net.sf.jasperreports.engine.JRAbstractSvgRenderer; import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperReportsContext;
import net.sf.jasperreports.renderers.AbstractRenderToImageDataRenderer;
import net.sourceforge.barbecue.Barcode; import net.sourceforge.barbecue.Barcode;
public class Barbecue extends JRAbstractSvgRenderer public class Barbecue extends AbstractRenderToImageDataRenderer
{ {
private static final long serialVersionUID = 5112469398754718739L; private static final long serialVersionUID = 5112469398754718739L;
@ -29,7 +31,8 @@ public class Barbecue extends JRAbstractSvgRenderer
m_barcode.setDrawingText(showDrawingText); m_barcode.setDrawingText(showDrawingText);
} }
public void render(Graphics2D grx, Rectangle2D rectangle) @Override
public void render(JasperReportsContext jasperReportsContext, Graphics2D grx, Rectangle2D rectangle) throws JRException
{ {
try try
{ {

View File

@ -1,5 +1,6 @@
@Echo off @Echo off
CALL utils\myEnvironment.bat Server
@if not "%JAVA_HOME%" == "" goto JAVA_HOME_OK @if not "%JAVA_HOME%" == "" goto JAVA_HOME_OK
@Set JAVA=java @Set JAVA=java
@ -17,8 +18,6 @@ goto START
@Echo Starting iDempiere Server ... @Echo Starting iDempiere Server ...
@Echo ======================================= @Echo =======================================
CALL utils\myEnvironment.bat Server
FOR %%c in (plugins\org.eclipse.equinox.launcher_1.*.jar) DO set JARFILE=%%c FOR %%c in (plugins\org.eclipse.equinox.launcher_1.*.jar) DO set JARFILE=%%c
@Set VMOPTS=-Xbootclasspath/p:alpn-boot.jar @Set VMOPTS=-Xbootclasspath/p:alpn-boot.jar

View File

@ -1,5 +1,8 @@
#!/bin/sh #!/bin/sh
# #
unset DISPLAY
BASE=`dirname $( readlink -f $0 )`
. $BASE/utils/myEnvironment.sh Server
if [ $JAVA_HOME ]; then if [ $JAVA_HOME ]; then
JAVA=$JAVA_HOME/bin/java JAVA=$JAVA_HOME/bin/java
else else
@ -17,9 +20,6 @@ echo ===================================
echo Starting iDempiere Server echo Starting iDempiere Server
echo =================================== echo ===================================
unset DISPLAY
BASE=`dirname $( readlink -f $0 )`
. $BASE/utils/myEnvironment.sh Server
VMOPTS="-Xbootclasspath/p:alpn-boot.jar VMOPTS="-Xbootclasspath/p:alpn-boot.jar
-Dorg.osgi.framework.bootdelegation=sun.security.ssl,org.eclipse.jetty.alpn -Dorg.osgi.framework.bootdelegation=sun.security.ssl,org.eclipse.jetty.alpn

File diff suppressed because one or more lines are too long

View File

@ -465,6 +465,8 @@ public class EMailProcessor
int c; int c;
while ((c = is.read()) != -1) while ((c = is.read()) != -1)
sb.append((char)c); sb.append((char)c);
is.close();
deliveryMessage = sb.toString().trim(); deliveryMessage = sb.toString().trim();
} }
else else
@ -674,6 +676,7 @@ public class EMailProcessor
int c; int c;
while ((c = is.read()) != -1) while ((c = is.read()) != -1)
System.out.write(c); System.out.write(c);
is.close();
} }
else else
{ {

View File

@ -680,7 +680,7 @@ public class ADSortTab extends Panel implements IADTabpanel
.append(" SET ").append(m_ColumnSortName).append("=0"); .append(" SET ").append(m_ColumnSortName).append("=0");
if (m_ColumnYesNoName != null) if (m_ColumnYesNoName != null)
sql.append(",").append(m_ColumnYesNoName).append("='N'"); sql.append(",").append(m_ColumnYesNoName).append("='N'");
sql.append(", Updated=Now(), UpdatedBy=").append(Env.getAD_User_ID(Env.getCtx())); sql.append(", Updated=sysdate, UpdatedBy=").append(Env.getAD_User_ID(Env.getCtx()));
sql.append(" WHERE ").append(m_KeyColumnName).append("=").append(pp.getKey()); sql.append(" WHERE ").append(m_KeyColumnName).append("=").append(pp.getKey());
if (DB.executeUpdate(sql.toString(), null) == 1) { if (DB.executeUpdate(sql.toString(), null) == 1) {
pp.setSortNo(0); pp.setSortNo(0);
@ -710,7 +710,7 @@ public class ADSortTab extends Panel implements IADTabpanel
.append(" SET ").append(m_ColumnSortName).append("=").append(index); .append(" SET ").append(m_ColumnSortName).append("=").append(index);
if (m_ColumnYesNoName != null) if (m_ColumnYesNoName != null)
sql.append(",").append(m_ColumnYesNoName).append("='Y'"); sql.append(",").append(m_ColumnYesNoName).append("='Y'");
sql.append(", Updated=Now(), UpdatedBy=").append(Env.getAD_User_ID(Env.getCtx())); sql.append(", Updated=sysdate, UpdatedBy=").append(Env.getAD_User_ID(Env.getCtx()));
sql.append(" WHERE ").append(m_KeyColumnName).append("=").append(pp.getKey()); sql.append(" WHERE ").append(m_KeyColumnName).append("=").append(pp.getKey());
if (DB.executeUpdate(sql.toString(), null) == 1) { if (DB.executeUpdate(sql.toString(), null) == 1) {
pp.setSortNo(index); pp.setSortNo(index);

View File

@ -587,7 +587,13 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
{ {
this.btnLock.setPressed(locked); this.btnLock.setPressed(locked);
String imgURL = "images/"+ (this.btnLock.isPressed() ? "LockX" : "Lock") + "24.png"; String size = Env.getContext(Env.getCtx(), "#ZK_Toolbar_Button_Size");
String suffix = "24.png";
if (!Util.isEmpty(size))
{
suffix = size + ".png";
}
String imgURL = "images/"+ (this.btnLock.isPressed() ? "LockX" : "Lock") + suffix;
imgURL = ThemeManager.getThemeResource(imgURL); imgURL = ThemeManager.getThemeResource(imgURL);
this.btnLock.setImage(imgURL); this.btnLock.setImage(imgURL);
} }

View File

@ -63,7 +63,7 @@ import org.zkoss.zul.Frozen;
import org.zkoss.zul.Paging; import org.zkoss.zul.Paging;
import org.zkoss.zul.Row; import org.zkoss.zul.Row;
import org.zkoss.zul.Tabpanel; import org.zkoss.zul.Tabpanel;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Vlayout;
import org.zkoss.zul.event.ZulEvents; import org.zkoss.zul.event.ZulEvents;
import org.zkoss.zul.impl.CustomGridDataLoader; import org.zkoss.zul.impl.CustomGridDataLoader;
@ -72,8 +72,9 @@ import org.zkoss.zul.impl.CustomGridDataLoader;
* @author Low Heng Sin * @author Low Heng Sin
* *
*/ */
public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFieldEditorContainer, StateChangeListener public class GridView extends Vlayout implements EventListener<Event>, IdSpace, IFieldEditorContainer, StateChangeListener
{ {
/** /**
* *
*/ */
@ -243,6 +244,9 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace, IFi
setupColumns(); setupColumns();
render(); render();
if (listbox.getFrozen() != null){
listbox.getFrozen().setWidgetOverride("syncScroll", "function (){syncScrollOVR(this);}");
}
updateListIndex(); updateListIndex();

View File

@ -394,7 +394,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
C_BPartner_ID = ((Integer)e.getNewValue()).intValue(); C_BPartner_ID = ((Integer)e.getNewValue()).intValue();
} }
initBPOrderDetails (C_BPartner_ID, true); initBPOrderDetails (C_BPartner_ID, false);
} }
window.tableChanged(null); window.tableChanged(null);
} // vetoableChange } // vetoableChange
@ -464,7 +464,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
orderField.addActionListener(this); orderField.addActionListener(this);
initBPDetails(C_BPartner_ID); initBPDetails(C_BPartner_ID);
} // initBPartnerOIS } // initBPOrderDetails
public void initBPDetails(int C_BPartner_ID) public void initBPDetails(int C_BPartner_ID)
{ {

View File

@ -46,7 +46,7 @@ public class WCtxHelpSuggestion extends Window implements EventListener<Event> {
/** /**
* generated serial id * generated serial id
*/ */
private static final long serialVersionUID = -8110247807841690907L; private static final long serialVersionUID = 2068729997836800852L;
private ConfirmPanel confirmPanel; private ConfirmPanel confirmPanel;
@ -239,7 +239,7 @@ public class WCtxHelpSuggestion extends Window implements EventListener<Event> {
} else { } else {
StringBuilder insert = new StringBuilder("Insert Into AD_CtxHelpMsg_Trl (AD_Client_ID, AD_Org_ID, AD_CtxHelpMsg_ID, IsActive, IsTranslated, AD_Language, MsgText,"); StringBuilder insert = new StringBuilder("Insert Into AD_CtxHelpMsg_Trl (AD_Client_ID, AD_Org_ID, AD_CtxHelpMsg_ID, IsActive, IsTranslated, AD_Language, MsgText,");
insert.append("Created, CreatedBy, Updated, UpdatedBy, AD_CtxHelpMsg_Trl_UU)") insert.append("Created, CreatedBy, Updated, UpdatedBy, AD_CtxHelpMsg_Trl_UU)")
.append(" Values (?, ?, ?, 'Y', 'N', ?, ?, now(), ?, now(), ?, generate_uuid()) "); .append(" Values (?, ?, ?, 'Y', 'N', ?, ?, sysdate, ?, sysdate, ?, generate_uuid()) ");
List<Object> params = new ArrayList<Object>(); List<Object> params = new ArrayList<Object>();
params.add(0); params.add(0);
params.add(0); params.add(0);

View File

@ -252,6 +252,42 @@ Copyright (C) 2007 Ashley G Ramdass.
}); });
}); });
// overload for recalculate width of scroll when has frozen control
function syncScrollOVR (wgt){
var parent = wgt.parent;
if (parent.eheadtbl && parent._nativebar) {
var scroll = wgt.$n('scrollX');
var cells = parent._getFirstRowCells(parent.eheadrows);
var totalcols = cells.length;
var columns = wgt._columns;
var scrollScale = totalcols - columns - 1;
var leftWidth = 0;
var headerWidth = 0;
for (var i = 0; i < columns; i++)
headerWidth += cells[i].offsetWidth;
var bodyWidth = parent.$n('body').offsetWidth;
var extraWidth = parent.$n('body').offsetWidth - headerWidth;
var extraColumnNum = 0;
for (var i = totalcols - 1; i >= columns; i--){
extraWidth -= cells[i].offsetWidth;
if (cells[i].offsetWidth == 0)// when scroll to right, column at left has width = 0
continue;
if (extraWidth >= 0){
extraColumnNum++;
}else{
break;
}
}
scroll.firstChild.style.width = jq.px0(bodyWidth + 50 * (scrollScale - extraColumnNum));
}
wgt.$syncScroll ()
}
]]> ]]>
</script> </script>
<include src="${themePreference}"/> <include src="${themePreference}"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

View File

@ -30,6 +30,7 @@ import org.compiere.model.MInOutLine;
import org.compiere.model.MInvoice; import org.compiere.model.MInvoice;
import org.compiere.model.MInvoiceLine; import org.compiere.model.MInvoiceLine;
import org.compiere.model.MInvoicePaySchedule; import org.compiere.model.MInvoicePaySchedule;
import org.compiere.model.MMatchInv;
import org.compiere.model.MOrder; import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine; import org.compiere.model.MOrderLine;
import org.compiere.model.MOrderPaySchedule; import org.compiere.model.MOrderPaySchedule;
@ -495,7 +496,12 @@ public abstract class CreateFromInvoice extends CreateFrom
for (int j = 0; j < lines.length; j++) for (int j = 0; j < lines.length; j++)
{ {
MInOutLine line = lines[j]; MInOutLine line = lines[j];
if (line.getQtyEntered().compareTo(QtyEntered) == 0) // qty matched
BigDecimal qtyMatched = Env.ZERO;
for (MMatchInv match : MMatchInv.getInOutLine(Env.getCtx(), line.getM_InOutLine_ID(), trxName)) {
qtyMatched = qtyMatched.add(match.getQty());
}
if (line.getQtyEntered().subtract(qtyMatched).compareTo(QtyEntered) == 0)
{ {
inoutLine = line; inoutLine = line;
M_InOutLine_ID = inoutLine.getM_InOutLine_ID(); M_InOutLine_ID = inoutLine.getM_InOutLine_ID();

View File

@ -1,7 +1,7 @@
<project name="zklibrary" basedir="." default="copy"> <project name="zklibrary" basedir="." default="copy">
<target name="copy"> <target name="copy">
<mkdir dir="lib" /> <mkdir dir="lib" />
<get src="${url.maven.zkoss.lib}/maven2/org/zkoss/zkforge/gmapsz/3.0.3/gmapsz-3.0.3.jar" dest="lib/gmapsz.jar" usetimestamp="true" verbose="true" retries="5" /> <get src="${url.maven.zkoss.lib}/maven2/org/zkoss/zkforge/gmapsz/3.0.4/gmapsz-3.0.4.jar" dest="lib/gmapsz.jar" usetimestamp="true" verbose="true" retries="5" />
<get src="${url.maven.zkoss.lib}/maven2/org/zkoss/zkforge/timelinez/2.3.1_50/timelinez-2.3.1_50.jar" dest="lib/timelinez.jar" usetimestamp="true" verbose="true" retries="5" /> <get src="${url.maven.zkoss.lib}/maven2/org/zkoss/zkforge/timelinez/2.3.1_50/timelinez-2.3.1_50.jar" dest="lib/timelinez.jar" usetimestamp="true" verbose="true" retries="5" />
<get src="${url.maven.zkoss.lib}/maven2/org/zkoss/zkforge/timeplotz/1.1_50/timeplotz-1.1_50.jar" dest="lib/timeplotz.jar" usetimestamp="true" verbose="true" retries="5" /> <get src="${url.maven.zkoss.lib}/maven2/org/zkoss/zkforge/timeplotz/1.1_50/timeplotz-1.1_50.jar" dest="lib/timeplotz.jar" usetimestamp="true" verbose="true" retries="5" />
<get src="${url.maven.zkoss.lib}/maven2/org/zkoss/calendar/calendar/2.1.5/calendar-2.1.5.jar" dest="lib/calendar.jar" usetimestamp="true" verbose="true" retries="5" /> <get src="${url.maven.zkoss.lib}/maven2/org/zkoss/calendar/calendar/2.1.5/calendar-2.1.5.jar" dest="lib/calendar.jar" usetimestamp="true" verbose="true" retries="5" />