1. Carlos Ruiz
  2. globalqss-iDempiere-LCO

Commits

Carlos Augusto Sánchez Sánchez  committed d288e9f

corrección de comportamiento del prefijo y cambio del tipo de final/initial sequence a numeric

  • Participants
  • Parent commits 70a4860
  • Branches default

Comments (0)

Files changed (5)

File org.globalqss.idempiere.LCO.invoicenumbercontrol/META-INF/2Pack.zip

Binary file modified.

File org.globalqss.idempiere.LCO.invoicenumbercontrol/packout/org.globalqss.idempiere.LCO.invoicenumbercontrol/dict/PackOut.xml

View file
             <FKConstraintType>N</FKConstraintType>
             <FKConstraintName/>
             <AD_Element_ID reference="uuid" reference-key="AD_Element">7144d1ac-d565-4500-9f03-34a4ea0ce245</AD_Element_ID>
-            <AD_Reference_ID reference="id">10</AD_Reference_ID>
+            <AD_Reference_ID reference="id">11</AD_Reference_ID>
             <AD_Val_Rule_ID reference="id"/>
         </AD_Column>
         <AD_Element type="table">
             <FKConstraintType>N</FKConstraintType>
             <FKConstraintName/>
             <AD_Element_ID reference="uuid" reference-key="AD_Element">5c4b1390-c690-4e81-900d-c893a7e56184</AD_Element_ID>
-            <AD_Reference_ID reference="id">10</AD_Reference_ID>
+            <AD_Reference_ID reference="id">11</AD_Reference_ID>
             <AD_Val_Rule_ID reference="id"/>
         </AD_Column>
         <AD_Element type="table">

File org.globalqss.idempiere.LCO.invoicenumbercontrol/src/org/globalqss/model/I_LCO_PrintedFormControl.java

View file
     /** TableName=LCO_PrintedFormControl */
     public static final String Table_Name = "LCO_PrintedFormControl";
 
-    /** AD_Table_ID=1000009 */
+    /** AD_Table_ID=1000050 */
     public static final int Table_ID = MTable.getTable_ID(Table_Name);
 
     KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
     public static final String COLUMNNAME_FinalSequence = "FinalSequence";
 
 	/** Set Final Sequence	  */
-	public void setFinalSequence (String FinalSequence);
+	public void setFinalSequence (int FinalSequence);
 
 	/** Get Final Sequence	  */
-	public String getFinalSequence();
+	public int getFinalSequence();
 
     /** Column name InitialSequence */
     public static final String COLUMNNAME_InitialSequence = "InitialSequence";
 
 	/** Set Initial Sequence	  */
-	public void setInitialSequence (String InitialSequence);
+	public void setInitialSequence (int InitialSequence);
 
 	/** Get Initial Sequence	  */
-	public String getInitialSequence();
+	public int getInitialSequence();
 
     /** Column name IsActive */
     public static final String COLUMNNAME_IsActive = "IsActive";

File org.globalqss.idempiere.LCO.invoicenumbercontrol/src/org/globalqss/model/LCO_ModelValidatorINC.java

View file
 			return msg;
 
 		final boolean isPrefixMandatory = MSysConfig.getBooleanValue("QSSLCO_IsPrefixMandatory", true, Env.getAD_Client_ID(Env.getCtx()));
-		final int prefixLengthExpected = Integer.valueOf(MSysConfig.getValue("QSSLCO_PrefixLength", null, Env.getAD_Client_ID(Env.getCtx())));
+		final int prefixLengthExpected;
+		if(isPrefixMandatory)
+			 prefixLengthExpected = Integer.valueOf(MSysConfig.getValue("QSSLCO_PrefixLength", null, Env.getAD_Client_ID(Env.getCtx())));	
+		else
+			prefixLengthExpected = 0;
 
 		final int docNoLengthExpected = Integer.valueOf(MSysConfig.getValue("QSSLCO_DocNoLength", null, Env.getAD_Client_ID(Env.getCtx())));
 		final int docNoLengthOptionalExpected = Integer.valueOf(MSysConfig.getValue("QSSLEC_DocNoLengthOptional", null, Env.getAD_Client_ID(Env.getCtx())));
 		final int docNoLengthEntered = invoiceWithholding.getDocumentNo().length();
 
 		boolean docNoLengthOptionalActive = MSysConfig.getBooleanValue("QSSLEC_DocNoLengthOptionalActive", true, Env.getAD_Client_ID(Env.getCtx()));
+		
+		if ( (isPrefixMandatory && docNoLengthEntered == docNoLengthExpected) && (prefixLengthExpected >= docNoLengthEntered ))
+			return Msg.getMsg(invoiceWithholding.getCtx(), "LCO_PrefixLengthInadequate");
 
 		MInvoice m_invoice = new MInvoice (invoiceWithholding.getCtx(), invoiceWithholding.getC_Invoice_ID(), invoiceWithholding.get_TrxName());
 		if (docNoLengthEntered == docNoLengthExpected || (docNoLengthEntered == docNoLengthOptionalExpected && docNoLengthOptionalActive)) {
 			else
 				params.add(m_invoice.getC_BPartner_ID());
 			if (isPrefixMandatory)
-				params.add(invoiceWithholding.getDocumentNo().toString().substring(0, prefixLengthExpected));
-			params.add(Integer.valueOf(invoiceWithholding.getDocumentNo().toString().substring(prefixLengthExpected, docNoLengthEntered)));
+				params.add(invoiceWithholding.getDocumentNo().substring(0, prefixLengthExpected));
+			params.add(Integer.valueOf(invoiceWithholding.getDocumentNo().substring(prefixLengthExpected, docNoLengthEntered)));
 			params.add(invoiceWithholding.getDateAcct());
 
 			log.fine(sqlCount);
 			return null;
 
 		final boolean isPrefixMandatory = MSysConfig.getBooleanValue("QSSLCO_IsPrefixMandatory", true, Env.getAD_Client_ID(Env.getCtx()));
-		final int prefixLengthExpected = Integer.valueOf(MSysConfig.getValue("QSSLCO_PrefixLength", null, Env.getAD_Client_ID(Env.getCtx())));
-
+		final int prefixLengthExpected;
+		if(isPrefixMandatory)
+			 prefixLengthExpected = Integer.valueOf(MSysConfig.getValue("QSSLCO_PrefixLength", null, Env.getAD_Client_ID(Env.getCtx())));	
+		else
+			prefixLengthExpected = 0;
+		
 		final int docNoLengthExpected = Integer.valueOf(MSysConfig.getValue("QSSLCO_DocNoLength", null, Env.getAD_Client_ID(Env.getCtx())));
 		final int docNoLengthOptionalExpected = Integer.valueOf(MSysConfig.getValue("QSSLEC_DocNoLengthOptional", null, Env.getAD_Client_ID(Env.getCtx())));
 		final int docNoLengthEntered = invoice.getDocumentNo().length();
-
+		
 		boolean docNoLengthOptionalActive = MSysConfig.getBooleanValue("QSSLEC_DocNoLengthOptionalActive", true, Env.getAD_Client_ID(Env.getCtx()));
+		
+		if ( (isPrefixMandatory && docNoLengthEntered == docNoLengthExpected) && (prefixLengthExpected >= docNoLengthEntered ))
+			return Msg.getMsg(invoice.getCtx(), "LCO_PrefixLengthInadequate");
 
 		if (docNoLengthEntered == docNoLengthExpected || (docNoLengthEntered == docNoLengthOptionalExpected && docNoLengthOptionalActive)) {
 
 			else
 				params.add(invoice.getC_BPartner_ID());
 			if (isPrefixMandatory)
-				params.add(invoice.getDocumentNo().toString().substring(0, prefixLengthExpected));
-			params.add(Integer.valueOf(invoice.getDocumentNo().toString().substring(prefixLengthExpected, docNoLengthEntered)));
+				params.add(invoice.getDocumentNo().substring(0, prefixLengthExpected));
+			params.add(Integer.valueOf(invoice.getDocumentNo().substring(prefixLengthExpected, docNoLengthEntered)));
+			
 			params.add(invoice.getDateInvoiced());
 
 			log.fine(sqlCount);
 		final int prefixLengthExpected = Integer.valueOf(MSysConfig.getValue("QSSLCO_PrefixLength", null, Env.getAD_Client_ID(Env.getCtx())));
 		int prefixLengthEntered = 0;
 		if (cpf.getPrefix() !=  null)
-			prefixLengthEntered = cpf.getPrefix().toString().length();
+			prefixLengthEntered = cpf.getPrefix().length();
 
 		if (cpf.getC_DocTypeTarget_ID() <= 0 && !cpf.isWithholding())
 			return Msg.getMsg(cpf.getCtx(), "LCO_TypeOfPrintedFormControlRequired");
 
 		if (cpf.is_ValueChanged("InitialSequence") || cpf.is_ValueChanged("FinalSequence") || (cpf.is_ValueChanged("IsActive") && cpf.isActive())) {
 
-			int initialSequence = Integer.parseInt(cpf.getInitialSequence());
-			int finalSequence = Integer.parseInt(cpf.getFinalSequence());
+			int initialSequence = cpf.getInitialSequence();
+			int finalSequence = cpf.getFinalSequence();
 			if (finalSequence <= initialSequence)
 				return Msg.getMsg(cpf.getCtx(), "LCO_InvalidSequences");
 
 				return Msg.getMsg(cpf.getCtx(), "LCO_InvalidDates");
 
 			MDocType dt = new MDocType(cpf.getCtx(), cpf.getC_DocTypeTarget_ID(), cpf.get_TrxName());
+			
 
 			boolean isSOTrx = dt.isSOTrx();
 			String sql = getSqlToValidatePrintedForm(isSOTrx, cpf.isWithholding(), false, true, isPrefixMandatory).toString();
 			if (isPrefixMandatory)
 				params.add(cpf.getPrefix());
 
-			params.add(Integer.valueOf(cpf.getInitialSequence()));
-			params.add(Integer.valueOf(cpf.getFinalSequence()));
+			params.add(cpf.getInitialSequence());
+			params.add(cpf.getFinalSequence());
 
 			int cnt = DB.getSQLValueEx(cpf.get_TrxName(), sql, params);
 			

File org.globalqss.idempiere.LCO.invoicenumbercontrol/src/org/globalqss/model/X_LCO_PrintedFormControl.java

View file
 	/**
 	 *
 	 */
-	private static final long serialVersionUID = 20140318L;
+	private static final long serialVersionUID = 20140505L;
 
     /** Standard Constructor */
     public X_LCO_PrintedFormControl (Properties ctx, int LCO_PrintedFormControl_ID, String trxName)
       /** if (LCO_PrintedFormControl_ID == 0)
         {
 			setAuthorizationNo (null);
-			setFinalSequence (null);
-			setInitialSequence (null);
+			setFinalSequence (0);
+			setInitialSequence (0);
 			setLCO_PrintedFormControl_ID (0);
 			setValidFrom (new Timestamp( System.currentTimeMillis() ));
 			setValidUntil (new Timestamp( System.currentTimeMillis() ));
 
 	/** Set Final Sequence.
 		@param FinalSequence Final Sequence	  */
-	public void setFinalSequence (String FinalSequence)
+	public void setFinalSequence (int FinalSequence)
 	{
-		set_Value (COLUMNNAME_FinalSequence, FinalSequence);
+		set_Value (COLUMNNAME_FinalSequence, Integer.valueOf(FinalSequence));
 	}
 
 	/** Get Final Sequence.
 		@return Final Sequence	  */
-	public String getFinalSequence () 
+	public int getFinalSequence () 
 	{
-		return (String)get_Value(COLUMNNAME_FinalSequence);
+		Integer ii = (Integer)get_Value(COLUMNNAME_FinalSequence);
+		if (ii == null)
+			 return 0;
+		return ii.intValue();
 	}
 
 	/** Set Initial Sequence.
 		@param InitialSequence Initial Sequence	  */
-	public void setInitialSequence (String InitialSequence)
+	public void setInitialSequence (int InitialSequence)
 	{
-		set_Value (COLUMNNAME_InitialSequence, InitialSequence);
+		set_Value (COLUMNNAME_InitialSequence, Integer.valueOf(InitialSequence));
 	}
 
 	/** Get Initial Sequence.
 		@return Initial Sequence	  */
-	public String getInitialSequence () 
+	public int getInitialSequence () 
 	{
-		return (String)get_Value(COLUMNNAME_InitialSequence);
+		Integer ii = (Integer)get_Value(COLUMNNAME_InitialSequence);
+		if (ii == null)
+			 return 0;
+		return ii.intValue();
 	}
 
 	/** Set Is Withholding.