Implement Feature Request [ 1789836 ] Add fields to Import Invoice - allow import charges

This commit is contained in:
Carlos Ruiz 2007-09-07 03:50:47 +00:00
parent 1707618b0a
commit 42fc2ba250
5 changed files with 2219 additions and 1609 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* 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 *
@ -26,7 +26,7 @@ import org.compiere.util.*;
* Import Invoice from I_Invoice
*
* @author Jorg Janke
* @version $Id: ImportInvoice.java,v 1.2 2006/07/30 00:51:01 jjanke Exp $
* @version $Id: ImportInvoice.java,v 1.1 2007/09/05 09:27:31 cruiz Exp $
*/
public class ImportInvoice extends SvrProcess
{
@ -244,6 +244,52 @@ public class ImportInvoice extends SvrProcess
if (no != 0)
log.warning ("No PaymentTerm=" + no);
// globalqss - Add project and activity
// Project
sql = new StringBuffer ("UPDATE I_Invoice o "
+ "SET C_Project_ID=(SELECT C_Project_ID FROM C_Project p"
+ " WHERE o.ProjectValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) "
+ "WHERE C_Project_ID IS NULL AND ProjectValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("Set Project=" + no);
sql = new StringBuffer ("UPDATE I_Invoice "
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Project, ' "
+ "WHERE C_Project_ID IS NULL AND (ProjectValue IS NOT NULL)"
+ " AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0)
log.warning ("Invalid Project=" + no);
// Activity
sql = new StringBuffer ("UPDATE I_Invoice o "
+ "SET C_Activity_ID=(SELECT C_Activity_ID FROM C_Activity p"
+ " WHERE o.ActivityValue=p.Value AND o.AD_Client_ID=p.AD_Client_ID) "
+ "WHERE C_Activity_ID IS NULL AND ActivityValue IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("Set Activity=" + no);
sql = new StringBuffer ("UPDATE I_Invoice "
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Activity, ' "
+ "WHERE C_Activity_ID IS NULL AND (ActivityValue IS NOT NULL)"
+ " AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0)
log.warning ("Invalid Activity=" + no);
// globalqss - add charge
// Charge
sql = new StringBuffer ("UPDATE I_Invoice o "
+ "SET C_Charge_ID=(SELECT C_Charge_ID FROM C_Charge p"
+ " WHERE o.ChargeName=p.Name AND o.AD_Client_ID=p.AD_Client_ID) "
+ "WHERE C_Charge_ID IS NULL AND ChargeName IS NOT NULL AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("Set Charge=" + no);
sql = new StringBuffer ("UPDATE I_Invoice "
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Charge, ' "
+ "WHERE C_Charge_ID IS NULL AND (ChargeName IS NOT NULL)"
+ " AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0)
log.warning ("Invalid Charge=" + no);
//
// BP from EMail
sql = new StringBuffer ("UPDATE I_Invoice o "
+ "SET (C_BPartner_ID,AD_User_ID)=(SELECT C_BPartner_ID,AD_User_ID FROM AD_User u"
@ -394,7 +440,16 @@ public class ImportInvoice extends SvrProcess
if (no != 0)
log.warning ("Invalid Product=" + no);
// Tax
// globalqss - charge and product are exclusive
sql = new StringBuffer ("UPDATE I_Invoice "
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Product and Charge, ' "
+ "WHERE M_Product_ID IS NOT NULL AND C_Charge_ID IS NOT NULL "
+ " AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0)
log.warning ("Invalid Product and Charge exclusive=" + no);
// Tax
sql = new StringBuffer ("UPDATE I_Invoice o "
+ "SET C_Tax_ID=(SELECT MAX(C_Tax_ID) FROM C_Tax t"
+ " WHERE o.TaxIndicator=t.TaxIndicator AND o.AD_Client_ID=t.AD_Client_ID) "
@ -637,6 +692,10 @@ public class ImportInvoice extends SvrProcess
lineNo += 10;
if (imp.getM_Product_ID() != 0)
line.setM_Product_ID(imp.getM_Product_ID(), true);
// globalqss - import invoice with charges
if (imp.getC_Charge_ID() != 0)
line.setC_Charge_ID(imp.getC_Charge_ID());
//
line.setQty(imp.getQtyOrdered());
line.setPrice();
BigDecimal price = imp.getPriceActual();
@ -686,4 +745,4 @@ public class ImportInvoice extends SvrProcess
return "";
} // doIt
} // ImportInvoice
} // ImportInvoice

View File

@ -0,0 +1,178 @@
-- [ 1789836 ] Add fields to Import Invoice - allow import charges
-- http://sourceforge.net/tracker/index.php?func=detail&aid=1789836&group_id=176962&atid=879335
ALTER TABLE I_INVOICE ADD (projectvalue NVARCHAR2(40));
ALTER TABLE I_INVOICE ADD (activityvalue NVARCHAR2(40));
ALTER TABLE I_INVOICE ADD (chargename NVARCHAR2(60));
ALTER TABLE I_INVOICE ADD (c_charge_id NUMBER(10));
INSERT INTO AD_ELEMENT
(ad_element_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
columnname, entitytype, NAME, printname
)
VALUES (53222, 0, 0, 'Y',
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
'ActivityValue', 'U', 'ActivityValue', 'ActivityValue'
);
INSERT INTO AD_COLUMN
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description, VERSION, entitytype,
columnname, ad_table_id, ad_reference_id, fieldlength, iskey,
isparent, ismandatory, isupdateable, isidentifier, istranslated,
isencrypted, isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53241, 0, 0, 'Y',
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'),
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Project Key', 'Key of the Project', 0, 'U',
'ProjectValue', 598, 10, 40, 'N',
'N', 'N', 'Y', 'N', 'N',
'N', 'N', 2118, 'Y',
'N'
);
INSERT INTO AD_COLUMN
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
HELP,
VERSION, entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, istranslated, isencrypted, isselectioncolumn,
ad_element_id, issyncdatabase, isalwaysupdateable
)
VALUES (53242, 0, 0, 'Y',
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'),
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Charge', 'Additional document charges',
'The Charge indicates a type of Charge (Handling, Shipping, Restocking)',
0, 'U', 'C_Charge_ID', 598, 19,
10, 'N', 'N', 'N', 'Y',
'N', 'N', 'N', 'N',
968, 'Y', 'N'
);
INSERT INTO AD_COLUMN
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, VERSION, entitytype, columnname, ad_table_id,
ad_reference_id, fieldlength, iskey, isparent, ismandatory,
isupdateable, isidentifier, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53243, 0, 0, 'Y',
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'),
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'ActivityValue', 0, 'U', 'ActivityValue', 598,
10, 40, 'N', 'N', 'N',
'Y', 'N', 'N', 'N',
'N', 53222, 'Y',
'N'
);
INSERT INTO AD_COLUMN
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description, VERSION, entitytype, columnname,
ad_table_id, ad_reference_id, fieldlength, iskey, isparent,
ismandatory, isupdateable, isidentifier, istranslated,
isencrypted, isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53244, 0, 0, 'Y',
TO_DATE ('09/04/2007 22:54:46', 'MM/DD/YYYY HH24:MI:SS'),
TO_DATE ('09/04/2007 22:54:46', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Charge Name', 'Name of the Charge', 0, 'U', 'ChargeName',
598, 10, 60, 'N', 'N',
'N', 'Y', 'N', 'N',
'N', 'N', 2096, 'Y',
'N'
);
INSERT INTO AD_FIELD
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, iscentrallymaintained, ad_tab_id, ad_column_id,
isdisplayed, displaylength, isreadonly, seqno, sortno,
issameline, isheading, isfieldonly, isencrypted, entitytype
)
VALUES (53251, 0, 0, 'Y',
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
'ActivityValue', 'Y', 510, 53243,
'Y', 40, 'N', 498, 0,
'N', 'N', 'N', 'N', 'U'
);
INSERT INTO AD_FIELD
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description, iscentrallymaintained, ad_tab_id,
ad_column_id, ad_fieldgroup_id, isdisplayed, displaylength,
isreadonly, seqno, sortno, issameline, isheading, isfieldonly,
isencrypted, entitytype
)
VALUES (53252, 0, 0, 'Y',
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Project Key', 'Key of the Project', 'Y', 510,
53241, 104, 'Y', 40,
'N', 478, 0, 'N', 'N', 'N',
'N', 'U'
);
INSERT INTO AD_FIELD
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
HELP,
iscentrallymaintained, ad_tab_id, ad_column_id, isdisplayed,
displaylength, isreadonly, seqno, sortno, issameline, isheading,
isfieldonly, isencrypted, entitytype
)
VALUES (53253, 0, 0, 'Y',
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Charge', 'Additional document charges',
'The Charge indicates a type of Charge (Handling, Shipping, Restocking)',
'Y', 510, 53242, 'Y',
10, 'N', 392, 0, 'N', 'N',
'N', 'N', 'U'
);
INSERT INTO AD_FIELD
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description, iscentrallymaintained, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly, seqno,
sortno, issameline, isheading, isfieldonly, isencrypted,
entitytype
)
VALUES (53254, 0, 0, 'Y',
TO_DATE ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_DATE ('09/04/2007 22:57:16', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Charge Name', 'Name of the Charge', 'Y', 510,
53244, 'Y', 40, 'N', 394,
0, 'Y', 'N', 'N', 'N',
'U'
);
COMMIT ;

View File

@ -0,0 +1,177 @@
-- [ 1789836 ] Add fields to Import Invoice - allow import charges
-- http://sourceforge.net/tracker/index.php?func=detail&aid=1789836&group_id=176962&atid=879335
ALTER TABLE I_INVOICE ADD COLUMN projectvalue VARCHAR(40) NULL;
ALTER TABLE I_INVOICE ADD COLUMN activityvalue VARCHAR(40) NULL;
ALTER TABLE I_INVOICE ADD COLUMN chargename VARCHAR(60) NULL;
ALTER TABLE I_INVOICE ADD COLUMN c_charge_id NUMERIC(10,0) NULL;
INSERT INTO AD_ELEMENT
(ad_element_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
columnname, entitytype, NAME, printname
)
VALUES (53222, 0, 0, 'Y',
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
'ActivityValue', 'U', 'ActivityValue', 'ActivityValue'
);
INSERT INTO AD_COLUMN
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description, VERSION, entitytype,
columnname, ad_table_id, ad_reference_id, fieldlength, iskey,
isparent, ismandatory, isupdateable, isidentifier, istranslated,
isencrypted, isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53241, 0, 0, 'Y',
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'),
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Project Key', 'Key of the Project', 0, 'U',
'ProjectValue', 598, 10, 40, 'N',
'N', 'N', 'Y', 'N', 'N',
'N', 'N', 2118, 'Y',
'N'
);
INSERT INTO AD_COLUMN
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description,
HELP,
VERSION, entitytype, columnname, ad_table_id, ad_reference_id,
fieldlength, iskey, isparent, ismandatory, isupdateable,
isidentifier, istranslated, isencrypted, isselectioncolumn,
ad_element_id, issyncdatabase, isalwaysupdateable
)
VALUES (53242, 0, 0, 'Y',
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'),
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Charge', 'Additional document charges',
'The Charge indicates a type of Charge (Handling, Shipping, Restocking)',
0, 'U', 'C_Charge_ID', 598, 19,
10, 'N', 'N', 'N', 'Y',
'N', 'N', 'N', 'N',
968, 'Y', 'N'
);
INSERT INTO AD_COLUMN
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, VERSION, entitytype, columnname, ad_table_id,
ad_reference_id, fieldlength, iskey, isparent, ismandatory,
isupdateable, isidentifier, istranslated, isencrypted,
isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53243, 0, 0, 'Y',
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'),
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'ActivityValue', 0, 'U', 'ActivityValue', 598,
10, 40, 'N', 'N', 'N',
'Y', 'N', 'N', 'N',
'N', 53222, 'Y',
'N'
);
INSERT INTO AD_COLUMN
(ad_column_id, ad_client_id, ad_org_id, isactive,
created,
updated, createdby,
updatedby, NAME, description, VERSION, entitytype, columnname,
ad_table_id, ad_reference_id, fieldlength, iskey, isparent,
ismandatory, isupdateable, isidentifier, istranslated,
isencrypted, isselectioncolumn, ad_element_id, issyncdatabase,
isalwaysupdateable
)
VALUES (53244, 0, 0, 'Y',
TO_TIMESTAMP ('09/04/2007 22:54:46', 'MM/DD/YYYY HH24:MI:SS'),
TO_TIMESTAMP ('09/04/2007 22:54:46', 'MM/DD/YYYY HH24:MI:SS'), 100,
100, 'Charge Name', 'Name of the Charge', 0, 'U', 'ChargeName',
598, 10, 60, 'N', 'N',
'N', 'Y', 'N', 'N',
'N', 'N', 2096, 'Y',
'N'
);
INSERT INTO AD_FIELD
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, iscentrallymaintained, ad_tab_id, ad_column_id,
isdisplayed, displaylength, isreadonly, seqno, sortno,
issameline, isheading, isfieldonly, isencrypted, entitytype
)
VALUES (53251, 0, 0, 'Y',
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
'ActivityValue', 'Y', 510, 53243,
'Y', 40, 'N', 498, 0,
'N', 'N', 'N', 'N', 'U'
);
INSERT INTO AD_FIELD
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description, iscentrallymaintained, ad_tab_id,
ad_column_id, ad_fieldgroup_id, isdisplayed, displaylength,
isreadonly, seqno, sortno, issameline, isheading, isfieldonly,
isencrypted, entitytype
)
VALUES (53252, 0, 0, 'Y',
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Project Key', 'Key of the Project', 'Y', 510,
53241, 104, 'Y', 40,
'N', 478, 0, 'N', 'N', 'N',
'N', 'U'
);
INSERT INTO AD_FIELD
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description,
HELP,
iscentrallymaintained, ad_tab_id, ad_column_id, isdisplayed,
displaylength, isreadonly, seqno, sortno, issameline, isheading,
isfieldonly, isencrypted, entitytype
)
VALUES (53253, 0, 0, 'Y',
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Charge', 'Additional document charges',
'The Charge indicates a type of Charge (Handling, Shipping, Restocking)',
'Y', 510, 53242, 'Y',
10, 'N', 392, 0, 'N', 'N',
'N', 'N', 'U'
);
INSERT INTO AD_FIELD
(ad_field_id, ad_client_id, ad_org_id, isactive,
created, createdby,
updated, updatedby,
NAME, description, iscentrallymaintained, ad_tab_id,
ad_column_id, isdisplayed, displaylength, isreadonly, seqno,
sortno, issameline, isheading, isfieldonly, isencrypted,
entitytype
)
VALUES (53254, 0, 0, 'Y',
TO_TIMESTAMP ('09/04/2007 22:54:47', 'MM/DD/YYYY HH24:MI:SS'), 100,
TO_TIMESTAMP ('09/04/2007 22:57:16', 'MM/DD/YYYY HH24:MI:SS'), 100,
'Charge Name', 'Name of the Charge', 'Y', 510,
53244, 'Y', 40, 'N', 394,
0, 'Y', 'N', 'N', 'N',
'U'
);