IDEMPIERE-3717 Overwrite Date on Complete - problem with currency conversion

This commit is contained in:
Carlos Ruiz 2018-05-22 13:36:44 +02:00
parent caeac16f84
commit 5e14110f5b
10 changed files with 20 additions and 10 deletions

View File

@ -38,6 +38,7 @@ 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;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
/** /**
* Shipment Model * Shipment Model
@ -1780,7 +1781,7 @@ public class MInOut extends X_M_InOut implements DocAction
protected void setDefiniteDocumentNo() { protected void setDefiniteDocumentNo() {
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (dt.isOverwriteDateOnComplete()) { if (dt.isOverwriteDateOnComplete()) {
setMovementDate(new Timestamp (System.currentTimeMillis())); setMovementDate(TimeUtil.getDay(0));
if (getDateAcct().before(getMovementDate())) { if (getDateAcct().before(getMovementDate())) {
setDateAcct(getMovementDate()); setDateAcct(getMovementDate());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());

View File

@ -33,6 +33,7 @@ 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;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
import org.compiere.util.Util; import org.compiere.util.Util;
/** /**
@ -658,7 +659,7 @@ public class MInventory extends X_M_Inventory implements DocAction
private void setDefiniteDocumentNo() { private void setDefiniteDocumentNo() {
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (dt.isOverwriteDateOnComplete()) { if (dt.isOverwriteDateOnComplete()) {
setMovementDate(new Timestamp (System.currentTimeMillis())); setMovementDate(TimeUtil.getDay(0));
MPeriod.testPeriodOpen(getCtx(), getMovementDate(), MDocType.DOCBASETYPE_MaterialPhysicalInventory, getAD_Org_ID()); MPeriod.testPeriodOpen(getCtx(), getMovementDate(), MDocType.DOCBASETYPE_MaterialPhysicalInventory, getAD_Org_ID());
} }
if (dt.isOverwriteSeqOnComplete()) { if (dt.isOverwriteSeqOnComplete()) {

View File

@ -45,6 +45,7 @@ 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;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
/** /**
@ -2152,7 +2153,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return; return;
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (dt.isOverwriteDateOnComplete()) { if (dt.isOverwriteDateOnComplete()) {
setDateInvoiced(new Timestamp (System.currentTimeMillis())); setDateInvoiced(TimeUtil.getDay(0));
if (getDateAcct().before(getDateInvoiced())) { if (getDateAcct().before(getDateInvoiced())) {
setDateAcct(getDateInvoiced()); setDateAcct(getDateInvoiced());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());

View File

@ -29,6 +29,7 @@ import org.compiere.process.DocumentEngine;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
/** /**
* GL Journal Model * GL Journal Model
@ -631,7 +632,7 @@ public class MJournal extends X_GL_Journal implements DocAction
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (dt.isOverwriteDateOnComplete()) { if (dt.isOverwriteDateOnComplete()) {
if (this.getProcessedOn().signum() == 0) { if (this.getProcessedOn().signum() == 0) {
setDateDoc(new Timestamp (System.currentTimeMillis())); setDateDoc(TimeUtil.getDay(0));
if (getDateAcct().before(getDateDoc())) { if (getDateAcct().before(getDateDoc())) {
setDateAcct(getDateDoc()); setDateAcct(getDateDoc());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());

View File

@ -32,6 +32,7 @@ import org.compiere.process.DocumentEngine;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
/** /**
* Journal Batch Model * Journal Batch Model
@ -509,7 +510,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
private void setDefiniteDocumentNo() { private void setDefiniteDocumentNo() {
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (dt.isOverwriteDateOnComplete()) { if (dt.isOverwriteDateOnComplete()) {
setDateDoc(new Timestamp (System.currentTimeMillis())); setDateDoc(TimeUtil.getDay(0));
if (getDateAcct().before(getDateDoc())) { if (getDateAcct().before(getDateDoc())) {
setDateAcct(getDateDoc()); setDateAcct(getDateDoc());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());

View File

@ -32,6 +32,7 @@ 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;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
/** /**
* Inventory Movement Model * Inventory Movement Model
@ -631,7 +632,7 @@ public class MMovement extends X_M_Movement implements DocAction
private void setDefiniteDocumentNo() { private void setDefiniteDocumentNo() {
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (dt.isOverwriteDateOnComplete()) { if (dt.isOverwriteDateOnComplete()) {
setMovementDate(new Timestamp (System.currentTimeMillis())); setMovementDate(TimeUtil.getDay(0));
MPeriod.testPeriodOpen(getCtx(), getMovementDate(), getC_DocType_ID(), getAD_Org_ID()); MPeriod.testPeriodOpen(getCtx(), getMovementDate(), getC_DocType_ID(), getAD_Org_ID());
} }
if (dt.isOverwriteSeqOnComplete()) { if (dt.isOverwriteSeqOnComplete()) {

View File

@ -43,6 +43,7 @@ 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;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
import org.compiere.util.Util; import org.compiere.util.Util;
@ -2125,7 +2126,7 @@ public class MOrder extends X_C_Order implements DocAction
if (dt.isOverwriteDateOnComplete()) { if (dt.isOverwriteDateOnComplete()) {
/* a42niem - BF IDEMPIERE-63 - check if document has been completed before */ /* a42niem - BF IDEMPIERE-63 - check if document has been completed before */
if (this.getProcessedOn().signum() == 0) { if (this.getProcessedOn().signum() == 0) {
setDateOrdered(new Timestamp (System.currentTimeMillis())); setDateOrdered(TimeUtil.getDay(0));
if (getDateAcct().before(getDateOrdered())) { if (getDateAcct().before(getDateOrdered())) {
setDateAcct(getDateOrdered()); setDateAcct(getDateOrdered());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());

View File

@ -40,6 +40,7 @@ import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.IBAN; import org.compiere.util.IBAN;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
import org.compiere.util.Trx; import org.compiere.util.Trx;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.compiere.util.ValueNamePair; import org.compiere.util.ValueNamePair;
@ -2117,7 +2118,7 @@ public class MPayment extends X_C_Payment
private void setDefiniteDocumentNo() { private void setDefiniteDocumentNo() {
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (dt.isOverwriteDateOnComplete()) { if (dt.isOverwriteDateOnComplete()) {
setDateTrx(new Timestamp (System.currentTimeMillis())); setDateTrx(TimeUtil.getDay(0));
if (getDateAcct().before(getDateTrx())) { if (getDateAcct().before(getDateTrx())) {
setDateAcct(getDateTrx()); setDateAcct(getDateTrx());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());

View File

@ -30,6 +30,7 @@ import org.compiere.process.DocumentEngine;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
/** /**
* Requisition Model * Requisition Model
@ -364,7 +365,7 @@ public class MRequisition extends X_M_Requisition implements DocAction
private void setDefiniteDocumentNo() { private void setDefiniteDocumentNo() {
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (dt.isOverwriteDateOnComplete()) { if (dt.isOverwriteDateOnComplete()) {
setDateDoc(new Timestamp (System.currentTimeMillis())); setDateDoc(TimeUtil.getDay(0));
MPeriod.testPeriodOpen(getCtx(), getDateDoc(), MDocType.DOCBASETYPE_PurchaseRequisition, getAD_Org_ID()); MPeriod.testPeriodOpen(getCtx(), getDateDoc(), MDocType.DOCBASETYPE_PurchaseRequisition, getAD_Org_ID());
} }
if (dt.isOverwriteSeqOnComplete()) { if (dt.isOverwriteSeqOnComplete()) {

View File

@ -26,6 +26,7 @@ import org.compiere.model.ModelValidationEngine;
import org.compiere.model.ModelValidator; import org.compiere.model.ModelValidator;
import org.compiere.model.PO; import org.compiere.model.PO;
import org.compiere.model.POInfo; import org.compiere.model.POInfo;
import org.compiere.util.TimeUtil;
/** /**
* Template for DocAction * Template for DocAction
@ -248,7 +249,7 @@ public class DocActionTemplate extends PO implements DocAction
private void setDefiniteDocumentNo() { private void setDefiniteDocumentNo() {
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
if (dt.isOverwriteDateOnComplete()) { if (dt.isOverwriteDateOnComplete()) {
setDateInvoiced(new Timestamp (System.currentTimeMillis())); setDateInvoiced(TimeUtil.getDay(0));
if (getDateAcct().before(getDateInvoiced())) { if (getDateAcct().before(getDateInvoiced())) {
setDateAcct(getDateInvoiced()); setDateAcct(getDateInvoiced());
MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID()); MPeriod.testPeriodOpen(getCtx(), getDateAcct(), getC_DocType_ID(), getAD_Org_ID());