IDEMPIERE-3279 Implement configurable Write-Off in Payment Selection
This commit is contained in:
parent
e86a6d6e53
commit
afaedf1bf6
|
@ -0,0 +1,23 @@
|
||||||
|
CREATE OR REPLACE FUNCTION invoiceWriteOff
|
||||||
|
(
|
||||||
|
p_C_Invoice_ID IN NUMBER
|
||||||
|
)
|
||||||
|
RETURN NUMBER
|
||||||
|
AS
|
||||||
|
v_Amount NUMBER;
|
||||||
|
v_ClientId C_Invoice.AD_Client_ID%TYPE;
|
||||||
|
custom_function AD_SysConfig.Value%TYPE;
|
||||||
|
command VARCHAR2(1000);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID INTO v_ClientId FROM C_Invoice WHERE C_Invoice_ID=p_C_Invoice_ID;
|
||||||
|
custom_function := get_Sysconfig('PAYSELECTION_CUSTOM_INVOICEWRITEOFF_FUNCTION', '', v_ClientId, 0);
|
||||||
|
IF LENGTH(custom_function) > 0
|
||||||
|
THEN
|
||||||
|
command := 'SELECT '||custom_function||'('||p_C_Invoice_ID||') FROM DUAL';
|
||||||
|
EXECUTE IMMEDIATE command INTO v_Amount;
|
||||||
|
ELSE
|
||||||
|
v_Amount := 0;
|
||||||
|
END IF;
|
||||||
|
RETURN v_Amount;
|
||||||
|
END invoiceWriteOff;
|
||||||
|
/
|
|
@ -0,0 +1,24 @@
|
||||||
|
CREATE OR REPLACE FUNCTION invoiceWriteOff
|
||||||
|
(
|
||||||
|
p_C_Invoice_ID NUMERIC
|
||||||
|
)
|
||||||
|
RETURNS numeric AS $body$
|
||||||
|
DECLARE
|
||||||
|
v_Amount NUMERIC;
|
||||||
|
v_ClientId C_Invoice.AD_Client_ID%TYPE;
|
||||||
|
custom_function AD_SysConfig.Value%TYPE;
|
||||||
|
command VARCHAR(1000);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID INTO v_ClientId FROM C_Invoice WHERE C_Invoice_ID=p_C_Invoice_ID;
|
||||||
|
custom_function := get_Sysconfig('PAYSELECTION_CUSTOM_INVOICEWRITEOFF_FUNCTION', '', v_ClientId, 0);
|
||||||
|
IF LENGTH(custom_function) > 0
|
||||||
|
THEN
|
||||||
|
command := 'SELECT '||custom_function||'('||p_C_Invoice_ID||')';
|
||||||
|
EXECUTE command INTO v_Amount;
|
||||||
|
ELSE
|
||||||
|
v_Amount := 0;
|
||||||
|
END IF;
|
||||||
|
RETURN v_Amount;
|
||||||
|
END;
|
||||||
|
$body$ LANGUAGE plpgsql STABLE;
|
||||||
|
|
|
@ -0,0 +1,203 @@
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
-- IDEMPIERE-3279 Implement configurable Write-Off in Payment Selection
|
||||||
|
-- Jan 13, 2017 2:39:27 PM CET
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,IsToolbarButton,IsSecure) VALUES (212953,1,'Write-off Amount','Amount to write-off','The Write Off Amount indicates the amount to be written off as uncollectible.',525,'WriteOffAmt',22,'N','N','Y','N','N',0,'N',12,0,0,'Y',TO_DATE('2017-01-13 14:39:19','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2017-01-13 14:39:19','YYYY-MM-DD HH24:MI:SS'),100,1450,'N','N','D','N','N','N','Y','0e379fab-cf4d-4209-8576-f8c7f13031af','Y','N','N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:40:17 PM CET
|
||||||
|
UPDATE AD_Column SET IsUpdateable='Y',Updated=TO_DATE('2017-01-13 14:40:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=212953
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:40:30 PM CET
|
||||||
|
UPDATE AD_Column SET DefaultValue='0',Updated=TO_DATE('2017-01-13 14:40:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=212953
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:40:32 PM CET
|
||||||
|
ALTER TABLE C_PaySelectionCheck ADD WriteOffAmt NUMBER DEFAULT 0 NOT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:41:26 PM CET
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,IsToolbarButton,IsSecure) VALUES (212955,1,'Write-off Amount','Amount to write-off','The Write Off Amount indicates the amount to be written off as uncollectible.',427,'WriteOffAmt',22,'N','N','Y','N','N',0,'N',12,0,0,'Y',TO_DATE('2017-01-13 14:41:16','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2017-01-13 14:41:16','YYYY-MM-DD HH24:MI:SS'),100,1450,'N','N','D','N','N','N','Y','5a8e715a-7b5f-4daf-b88f-aaa0f229e9df','Y','N','N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:41:55 PM CET
|
||||||
|
UPDATE AD_Column SET DefaultValue='0',Updated=TO_DATE('2017-01-13 14:41:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=212955
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:41:56 PM CET
|
||||||
|
ALTER TABLE C_PaySelectionLine ADD WriteOffAmt NUMBER DEFAULT 0 NOT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:36 PM CET
|
||||||
|
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField) VALUES (204354,'Write-off Amount','Amount to write-off','The Write Off Amount indicates the amount to be written off as uncollectible.',353,212955,'Y',0,160,0,'N','N','N','N',0,0,'Y',TO_DATE('2017-01-13 14:43:35','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2017-01-13 14:43:35','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','13756b9c-d9db-4c83-9fea-d0b05b866bc0','Y',160,1,1,1,'N','N','N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=4416
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y' WHERE AD_Field_ID=4417
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y' WHERE AD_Field_ID=4423
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y' WHERE AD_Field_ID=4431
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y' WHERE AD_Field_ID=4938
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y' WHERE AD_Field_ID=4429
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=60,IsDisplayedGrid='Y' WHERE AD_Field_ID=4433
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=70,IsDisplayedGrid='Y' WHERE AD_Field_ID=4421
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=80,IsDisplayedGrid='Y' WHERE AD_Field_ID=10896
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=90,IsDisplayedGrid='Y' WHERE AD_Field_ID=10641
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=100,IsDisplayedGrid='Y' WHERE AD_Field_ID=4432
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=110,IsDisplayedGrid='Y' WHERE AD_Field_ID=10640
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=120,IsDisplayedGrid='Y' WHERE AD_Field_ID=204354
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:17 PM CET
|
||||||
|
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:44:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204354
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:17 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:44:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10640
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:17 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:44:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4939
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:17 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:44:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5840
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:17 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=160, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:44:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10616
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:39 PM CET
|
||||||
|
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField) VALUES (204355,'Write-off Amount','Amount to write-off','The Write Off Amount indicates the amount to be written off as uncollectible.',436,212953,'Y',0,140,0,'N','N','N','N',0,0,'Y',TO_DATE('2017-01-13 14:44:38','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2017-01-13 14:44:38','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','9bef867f-a47d-49f4-b2a7-3d69c3a71a14','Y',140,1,1,1,'N','N','N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=5828
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y' WHERE AD_Field_ID=5829
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y' WHERE AD_Field_ID=5830
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y' WHERE AD_Field_ID=5831
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y' WHERE AD_Field_ID=5837
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y' WHERE AD_Field_ID=5833
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=60,IsDisplayedGrid='Y' WHERE AD_Field_ID=5835
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=70,IsDisplayedGrid='Y' WHERE AD_Field_ID=10642
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=80,IsDisplayedGrid='Y' WHERE AD_Field_ID=204355
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204355
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5839
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10897
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5838
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5836
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10617
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:23 PM CET
|
||||||
|
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_DATE('2017-01-13 14:45:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204355
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION invoiceWriteOff
|
||||||
|
(
|
||||||
|
p_C_Invoice_ID IN NUMBER
|
||||||
|
)
|
||||||
|
RETURN NUMBER
|
||||||
|
AS
|
||||||
|
v_Amount NUMBER;
|
||||||
|
v_ClientId C_Invoice.AD_Client_ID%TYPE;
|
||||||
|
custom_function AD_SysConfig.Value%TYPE;
|
||||||
|
command VARCHAR2(1000);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID INTO v_ClientId FROM C_Invoice WHERE C_Invoice_ID=p_C_Invoice_ID;
|
||||||
|
custom_function := get_Sysconfig('PAYSELECTION_CUSTOM_INVOICEWRITEOFF_FUNCTION', '', v_ClientId, 0);
|
||||||
|
IF LENGTH(custom_function) > 0
|
||||||
|
THEN
|
||||||
|
command := 'SELECT '||custom_function||'('||p_C_Invoice_ID||') FROM DUAL';
|
||||||
|
EXECUTE IMMEDIATE command INTO v_Amount;
|
||||||
|
ELSE
|
||||||
|
v_Amount := 0;
|
||||||
|
END IF;
|
||||||
|
RETURN v_Amount;
|
||||||
|
END invoiceWriteOff;
|
||||||
|
/
|
||||||
|
|
||||||
|
SELECT register_migration_script('201701131446_IDEMPIERE-3279.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,200 @@
|
||||||
|
-- IDEMPIERE-3279 Implement configurable Write-Off in Payment Selection
|
||||||
|
-- Jan 13, 2017 2:39:27 PM CET
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,IsToolbarButton,IsSecure) VALUES (212953,1,'Write-off Amount','Amount to write-off','The Write Off Amount indicates the amount to be written off as uncollectible.',525,'WriteOffAmt',22,'N','N','Y','N','N',0,'N',12,0,0,'Y',TO_TIMESTAMP('2017-01-13 14:39:19','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2017-01-13 14:39:19','YYYY-MM-DD HH24:MI:SS'),100,1450,'N','N','D','N','N','N','Y','0e379fab-cf4d-4209-8576-f8c7f13031af','Y','N','N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:40:17 PM CET
|
||||||
|
UPDATE AD_Column SET IsUpdateable='Y',Updated=TO_TIMESTAMP('2017-01-13 14:40:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=212953
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:40:30 PM CET
|
||||||
|
UPDATE AD_Column SET DefaultValue='0',Updated=TO_TIMESTAMP('2017-01-13 14:40:30','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=212953
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:40:32 PM CET
|
||||||
|
ALTER TABLE C_PaySelectionCheck ADD COLUMN WriteOffAmt NUMERIC DEFAULT '0' NOT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:41:26 PM CET
|
||||||
|
INSERT INTO AD_Column (AD_Column_ID,Version,Name,Description,Help,AD_Table_ID,ColumnName,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,IsToolbarButton,IsSecure) VALUES (212955,1,'Write-off Amount','Amount to write-off','The Write Off Amount indicates the amount to be written off as uncollectible.',427,'WriteOffAmt',22,'N','N','Y','N','N',0,'N',12,0,0,'Y',TO_TIMESTAMP('2017-01-13 14:41:16','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2017-01-13 14:41:16','YYYY-MM-DD HH24:MI:SS'),100,1450,'N','N','D','N','N','N','Y','5a8e715a-7b5f-4daf-b88f-aaa0f229e9df','Y','N','N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:41:55 PM CET
|
||||||
|
UPDATE AD_Column SET DefaultValue='0',Updated=TO_TIMESTAMP('2017-01-13 14:41:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=212955
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:41:56 PM CET
|
||||||
|
ALTER TABLE C_PaySelectionLine ADD COLUMN WriteOffAmt NUMERIC DEFAULT '0' NOT NULL
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:36 PM CET
|
||||||
|
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField) VALUES (204354,'Write-off Amount','Amount to write-off','The Write Off Amount indicates the amount to be written off as uncollectible.',353,212955,'Y',0,160,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2017-01-13 14:43:35','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2017-01-13 14:43:35','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','13756b9c-d9db-4c83-9fea-d0b05b866bc0','Y',160,1,1,1,'N','N','N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=4416
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y' WHERE AD_Field_ID=4417
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y' WHERE AD_Field_ID=4423
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y' WHERE AD_Field_ID=4431
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y' WHERE AD_Field_ID=4938
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y' WHERE AD_Field_ID=4429
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=60,IsDisplayedGrid='Y' WHERE AD_Field_ID=4433
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=70,IsDisplayedGrid='Y' WHERE AD_Field_ID=4421
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=80,IsDisplayedGrid='Y' WHERE AD_Field_ID=10896
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=90,IsDisplayedGrid='Y' WHERE AD_Field_ID=10641
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=100,IsDisplayedGrid='Y' WHERE AD_Field_ID=4432
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=110,IsDisplayedGrid='Y' WHERE AD_Field_ID=10640
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:43:49 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=120,IsDisplayedGrid='Y' WHERE AD_Field_ID=204354
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:17 PM CET
|
||||||
|
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:44:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204354
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:17 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:44:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10640
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:17 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:44:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=4939
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:17 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=150, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:44:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5840
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:17 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=160, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:44:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10616
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:39 PM CET
|
||||||
|
INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,SortNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan,NumLines,IsQuickEntry,IsDefaultFocus,IsAdvancedField) VALUES (204355,'Write-off Amount','Amount to write-off','The Write Off Amount indicates the amount to be written off as uncollectible.',436,212953,'Y',0,140,0,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2017-01-13 14:44:38','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2017-01-13 14:44:38','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','9bef867f-a47d-49f4-b2a7-3d69c3a71a14','Y',140,1,1,1,'N','N','N')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=0,IsDisplayedGrid='N' WHERE AD_Field_ID=5828
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=10,IsDisplayedGrid='Y' WHERE AD_Field_ID=5829
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=20,IsDisplayedGrid='Y' WHERE AD_Field_ID=5830
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=30,IsDisplayedGrid='Y' WHERE AD_Field_ID=5831
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=40,IsDisplayedGrid='Y' WHERE AD_Field_ID=5837
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=50,IsDisplayedGrid='Y' WHERE AD_Field_ID=5833
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=60,IsDisplayedGrid='Y' WHERE AD_Field_ID=5835
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=70,IsDisplayedGrid='Y' WHERE AD_Field_ID=10642
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:44:47 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNoGrid=80,IsDisplayedGrid='Y' WHERE AD_Field_ID=204355
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=1, ColumnSpan=2, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204355
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=100, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5839
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=110, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10897
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5838
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5836
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:13 PM CET
|
||||||
|
UPDATE AD_Field SET SeqNo=140, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:45:13','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10617
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 13, 2017 2:45:23 PM CET
|
||||||
|
UPDATE AD_Field SET IsDisplayed='Y', SeqNo=90, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, XPosition=4, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-01-13 14:45:23','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204355
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION invoiceWriteOff
|
||||||
|
(
|
||||||
|
p_C_Invoice_ID NUMERIC
|
||||||
|
)
|
||||||
|
RETURNS numeric AS $body$
|
||||||
|
DECLARE
|
||||||
|
v_Amount NUMERIC;
|
||||||
|
v_ClientId C_Invoice.AD_Client_ID%TYPE;
|
||||||
|
custom_function AD_SysConfig.Value%TYPE;
|
||||||
|
command VARCHAR(1000);
|
||||||
|
BEGIN
|
||||||
|
SELECT AD_Client_ID INTO v_ClientId FROM C_Invoice WHERE C_Invoice_ID=p_C_Invoice_ID;
|
||||||
|
custom_function := get_Sysconfig('PAYSELECTION_CUSTOM_INVOICEWRITEOFF_FUNCTION', '', v_ClientId, 0);
|
||||||
|
IF LENGTH(custom_function) > 0
|
||||||
|
THEN
|
||||||
|
command := 'SELECT '||custom_function||'('||p_C_Invoice_ID||')';
|
||||||
|
EXECUTE command INTO v_Amount;
|
||||||
|
ELSE
|
||||||
|
v_Amount := 0;
|
||||||
|
END IF;
|
||||||
|
RETURN v_Amount;
|
||||||
|
END;
|
||||||
|
$body$ LANGUAGE plpgsql STABLE;
|
||||||
|
|
||||||
|
SELECT register_migration_script('201701131446_IDEMPIERE-3279.sql') FROM dual
|
||||||
|
;
|
||||||
|
|
|
@ -66,9 +66,10 @@ public class CalloutPaySelection extends CalloutEngine
|
||||||
BigDecimal OpenAmt = (BigDecimal)mTab.getValue("OpenAmt");
|
BigDecimal OpenAmt = (BigDecimal)mTab.getValue("OpenAmt");
|
||||||
BigDecimal PayAmt = (BigDecimal)mTab.getValue("PayAmt");
|
BigDecimal PayAmt = (BigDecimal)mTab.getValue("PayAmt");
|
||||||
BigDecimal DiscountAmt = (BigDecimal)mTab.getValue("DiscountAmt");
|
BigDecimal DiscountAmt = (BigDecimal)mTab.getValue("DiscountAmt");
|
||||||
BigDecimal DifferenceAmt = OpenAmt.subtract(PayAmt).subtract(DiscountAmt);
|
BigDecimal WriteOffAmt = (BigDecimal)mTab.getValue("WriteOffAmt");
|
||||||
|
BigDecimal DifferenceAmt = OpenAmt.subtract(PayAmt).subtract(DiscountAmt).subtract(WriteOffAmt);
|
||||||
if (log.isLoggable(Level.FINE)) log.fine(" - OpenAmt=" + OpenAmt + " - PayAmt=" + PayAmt
|
if (log.isLoggable(Level.FINE)) log.fine(" - OpenAmt=" + OpenAmt + " - PayAmt=" + PayAmt
|
||||||
+ ", Discount=" + DiscountAmt + ", Difference=" + DifferenceAmt);
|
+ ", Discount=" + DiscountAmt + ", WriteOff=" + WriteOffAmt + ", Difference=" + DifferenceAmt);
|
||||||
|
|
||||||
mTab.setValue("DifferenceAmt", DifferenceAmt);
|
mTab.setValue("DifferenceAmt", DifferenceAmt);
|
||||||
|
|
||||||
|
|
|
@ -427,8 +427,8 @@ public class AllocationAuto extends SvrProcess
|
||||||
{
|
{
|
||||||
BigDecimal invoiceAmt = invoice.getOpenAmt(true, null);
|
BigDecimal invoiceAmt = invoice.getOpenAmt(true, null);
|
||||||
BigDecimal overUnder = line.getOpenAmt().subtract(line.getPayAmt())
|
BigDecimal overUnder = line.getOpenAmt().subtract(line.getPayAmt())
|
||||||
.subtract(line.getDiscountAmt()).subtract(line.getDifferenceAmt());
|
.subtract(line.getDiscountAmt()).subtract(line.getWriteOffAmt()).subtract(line.getDifferenceAmt());
|
||||||
invoiceAmt = invoiceAmt.subtract(line.getDiscountAmt())
|
invoiceAmt = invoiceAmt.subtract(line.getDiscountAmt()).subtract(line.getWriteOffAmt())
|
||||||
.subtract(line.getDifferenceAmt()).subtract(overUnder);
|
.subtract(line.getDifferenceAmt()).subtract(overUnder);
|
||||||
if (!invoice.isSOTrx())
|
if (!invoice.isSOTrx())
|
||||||
invoiceAmt = invoiceAmt.negate();
|
invoiceAmt = invoiceAmt.negate();
|
||||||
|
|
|
@ -117,14 +117,15 @@ public class PaySelectionCreateFrom extends SvrProcess
|
||||||
|
|
||||||
// psel.getPayDate();
|
// psel.getPayDate();
|
||||||
|
|
||||||
StringBuilder sql = new StringBuilder("SELECT C_Invoice_ID,")
|
StringBuilder sql = new StringBuilder("SELECT C_Invoice_ID,") // 1
|
||||||
// Open
|
// Open
|
||||||
.append(" currencyConvert(invoiceOpen(i.C_Invoice_ID, i.C_InvoicePaySchedule_ID)")
|
.append(" currencyConvert(invoiceOpen(i.C_Invoice_ID, i.C_InvoicePaySchedule_ID)")
|
||||||
.append(",i.C_Currency_ID, ?,?, i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS PayAmt,") // ##1/2 Currency_To,PayDate
|
.append(",i.C_Currency_ID, ?,?, i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS PayAmt,") // 2 ##p1/p2 Currency_To,PayDate
|
||||||
// Discount
|
// Discount
|
||||||
.append(" currencyConvert(invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID)") // ##3 PayDate
|
.append(" currencyConvert(invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID)") // ##p3 PayDate
|
||||||
.append(",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS DiscountAmt,") // ##4/5 Currency_To,PayDate
|
.append(",i.C_Currency_ID, ?,?,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) AS DiscountAmt,") // 3 ##p4/p5 Currency_To,PayDate
|
||||||
.append(" PaymentRule, IsSOTrx ") // 4..6
|
.append(" PaymentRule, IsSOTrx, ") // 4..5
|
||||||
|
.append(" currencyConvert(invoiceWriteOff(i.C_Invoice_ID) AS WriteOffAmt,") // 6
|
||||||
.append("FROM C_Invoice_v i WHERE ");
|
.append("FROM C_Invoice_v i WHERE ");
|
||||||
if (X_C_Order.PAYMENTRULE_DirectDebit.equals(p_PaymentRule))
|
if (X_C_Order.PAYMENTRULE_DirectDebit.equals(p_PaymentRule))
|
||||||
sql.append("IsSOTrx='Y'");
|
sql.append("IsSOTrx='Y'");
|
||||||
|
@ -228,13 +229,14 @@ public class PaySelectionCreateFrom extends SvrProcess
|
||||||
if (C_Invoice_ID == 0 || Env.ZERO.compareTo(PayAmt) == 0)
|
if (C_Invoice_ID == 0 || Env.ZERO.compareTo(PayAmt) == 0)
|
||||||
continue;
|
continue;
|
||||||
BigDecimal DiscountAmt = rs.getBigDecimal(3);
|
BigDecimal DiscountAmt = rs.getBigDecimal(3);
|
||||||
|
BigDecimal WriteOffAmt = rs.getBigDecimal(6);
|
||||||
String PaymentRule = rs.getString(4);
|
String PaymentRule = rs.getString(4);
|
||||||
boolean isSOTrx = "Y".equals(rs.getString(5));
|
boolean isSOTrx = "Y".equals(rs.getString(5));
|
||||||
//
|
//
|
||||||
lines++;
|
lines++;
|
||||||
MPaySelectionLine pselLine = new MPaySelectionLine (psel, lines*10, PaymentRule);
|
MPaySelectionLine pselLine = new MPaySelectionLine (psel, lines*10, PaymentRule);
|
||||||
pselLine.setInvoice (C_Invoice_ID, isSOTrx,
|
pselLine.setInvoice (C_Invoice_ID, isSOTrx,
|
||||||
PayAmt, PayAmt.subtract(DiscountAmt), DiscountAmt);
|
PayAmt, PayAmt.subtract(DiscountAmt).subtract(WriteOffAmt), DiscountAmt, WriteOffAmt);
|
||||||
if (!pselLine.save())
|
if (!pselLine.save())
|
||||||
{
|
{
|
||||||
throw new IllegalStateException ("Cannot save MPaySelectionLine");
|
throw new IllegalStateException ("Cannot save MPaySelectionLine");
|
||||||
|
|
|
@ -301,4 +301,17 @@ public interface I_C_PaySelectionCheck
|
||||||
* User who updated this records
|
* User who updated this records
|
||||||
*/
|
*/
|
||||||
public int getUpdatedBy();
|
public int getUpdatedBy();
|
||||||
|
|
||||||
|
/** Column name WriteOffAmt */
|
||||||
|
public static final String COLUMNNAME_WriteOffAmt = "WriteOffAmt";
|
||||||
|
|
||||||
|
/** Set Write-off Amount.
|
||||||
|
* Amount to write-off
|
||||||
|
*/
|
||||||
|
public void setWriteOffAmt (BigDecimal WriteOffAmt);
|
||||||
|
|
||||||
|
/** Get Write-off Amount.
|
||||||
|
* Amount to write-off
|
||||||
|
*/
|
||||||
|
public BigDecimal getWriteOffAmt();
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,4 +303,17 @@ public interface I_C_PaySelectionLine
|
||||||
* User who updated this records
|
* User who updated this records
|
||||||
*/
|
*/
|
||||||
public int getUpdatedBy();
|
public int getUpdatedBy();
|
||||||
|
|
||||||
|
/** Column name WriteOffAmt */
|
||||||
|
public static final String COLUMNNAME_WriteOffAmt = "WriteOffAmt";
|
||||||
|
|
||||||
|
/** Set Write-off Amount.
|
||||||
|
* Amount to write-off
|
||||||
|
*/
|
||||||
|
public void setWriteOffAmt (BigDecimal WriteOffAmt);
|
||||||
|
|
||||||
|
/** Get Write-off Amount.
|
||||||
|
* Amount to write-off
|
||||||
|
*/
|
||||||
|
public BigDecimal getWriteOffAmt();
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
psc.setIsReceipt(payment.isReceipt());
|
psc.setIsReceipt(payment.isReceipt());
|
||||||
psc.setPayAmt (payment.getPayAmt());
|
psc.setPayAmt (payment.getPayAmt());
|
||||||
psc.setDiscountAmt(payment.getDiscountAmt());
|
psc.setDiscountAmt(payment.getDiscountAmt());
|
||||||
|
psc.setWriteOffAmt(payment.getWriteOffAmt());
|
||||||
psc.setQty (1);
|
psc.setQty (1);
|
||||||
psc.setDocumentNo(payment.getDocumentNo());
|
psc.setDocumentNo(payment.getDocumentNo());
|
||||||
psc.setProcessed(true);
|
psc.setProcessed(true);
|
||||||
|
@ -148,6 +149,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
psl.setOpenAmt(payment.getPayAmt().add(payment.getDiscountAmt()));
|
psl.setOpenAmt(payment.getPayAmt().add(payment.getDiscountAmt()));
|
||||||
psl.setPayAmt (payment.getPayAmt());
|
psl.setPayAmt (payment.getPayAmt());
|
||||||
psl.setDiscountAmt(payment.getDiscountAmt());
|
psl.setDiscountAmt(payment.getDiscountAmt());
|
||||||
|
psl.setWriteOffAmt(payment.getWriteOffAmt());
|
||||||
psl.setDifferenceAmt (Env.ZERO);
|
psl.setDifferenceAmt (Env.ZERO);
|
||||||
psl.setC_PaySelectionCheck_ID(psc.getC_PaySelectionCheck_ID());
|
psl.setC_PaySelectionCheck_ID(psc.getC_PaySelectionCheck_ID());
|
||||||
psl.setProcessed(true);
|
psl.setProcessed(true);
|
||||||
|
@ -170,6 +172,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
psla.setOpenAmt(pAlloc.getAmount().add(pAlloc.getDiscountAmt()));
|
psla.setOpenAmt(pAlloc.getAmount().add(pAlloc.getDiscountAmt()));
|
||||||
psla.setPayAmt (pAlloc.getAmount());
|
psla.setPayAmt (pAlloc.getAmount());
|
||||||
psla.setDiscountAmt(pAlloc.getDiscountAmt());
|
psla.setDiscountAmt(pAlloc.getDiscountAmt());
|
||||||
|
psla.setWriteOffAmt(pAlloc.getWriteOffAmt());
|
||||||
psla.setDifferenceAmt (Env.ZERO);
|
psla.setDifferenceAmt (Env.ZERO);
|
||||||
psla.setC_PaySelectionCheck_ID(psc.getC_PaySelectionCheck_ID());
|
psla.setC_PaySelectionCheck_ID(psc.getC_PaySelectionCheck_ID());
|
||||||
psla.setProcessed(true);
|
psla.setProcessed(true);
|
||||||
|
@ -310,6 +313,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
payment.setTrxType(X_C_Payment.TRXTYPE_CreditPayment);
|
payment.setTrxType(X_C_Payment.TRXTYPE_CreditPayment);
|
||||||
payment.setAmount(check.getParent().getC_Currency_ID(), check.getPayAmt());
|
payment.setAmount(check.getParent().getC_Currency_ID(), check.getPayAmt());
|
||||||
payment.setDiscountAmt(check.getDiscountAmt());
|
payment.setDiscountAmt(check.getDiscountAmt());
|
||||||
|
payment.setWriteOffAmt(check.getWriteOffAmt());
|
||||||
payment.setDateTrx(check.getParent().getPayDate());
|
payment.setDateTrx(check.getParent().getPayDate());
|
||||||
payment.setDateAcct(payment.getDateTrx()); // globalqss [ 2030685 ]
|
payment.setDateAcct(payment.getDateTrx()); // globalqss [ 2030685 ]
|
||||||
payment.setC_BPartner_ID(check.getC_BPartner_ID());
|
payment.setC_BPartner_ID(check.getC_BPartner_ID());
|
||||||
|
@ -330,14 +334,16 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
//
|
//
|
||||||
payment.setC_Invoice_ID (psl.getC_Invoice_ID());
|
payment.setC_Invoice_ID (psl.getC_Invoice_ID());
|
||||||
payment.setDiscountAmt (psl.getDiscountAmt());
|
payment.setDiscountAmt (psl.getDiscountAmt());
|
||||||
payment.setWriteOffAmt(psl.getDifferenceAmt());
|
payment.setWriteOffAmt (psl.getWriteOffAmt());
|
||||||
BigDecimal overUnder = psl.getOpenAmt().subtract(psl.getPayAmt())
|
BigDecimal overUnder = psl.getOpenAmt().subtract(psl.getPayAmt())
|
||||||
.subtract(psl.getDiscountAmt()).subtract(psl.getDifferenceAmt());
|
.subtract(psl.getDiscountAmt()).subtract(psl.getWriteOffAmt()).subtract(psl.getDifferenceAmt());
|
||||||
payment.setOverUnderAmt(overUnder);
|
payment.setOverUnderAmt(overUnder);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
payment.setWriteOffAmt(Env.ZERO);
|
||||||
payment.setDiscountAmt(Env.ZERO);
|
payment.setDiscountAmt(Env.ZERO);
|
||||||
payment.setWriteOffAmt(Env.ZERO);
|
}
|
||||||
payment.saveEx();
|
payment.saveEx();
|
||||||
//
|
//
|
||||||
int C_Payment_ID = payment.get_ID();
|
int C_Payment_ID = payment.get_ID();
|
||||||
|
@ -450,6 +456,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
// setPaymentRule (null);
|
// setPaymentRule (null);
|
||||||
setPayAmt (Env.ZERO);
|
setPayAmt (Env.ZERO);
|
||||||
setDiscountAmt(Env.ZERO);
|
setDiscountAmt(Env.ZERO);
|
||||||
|
setWriteOffAmt(Env.ZERO);
|
||||||
setIsPrinted (false);
|
setIsPrinted (false);
|
||||||
setIsReceipt (false);
|
setIsReceipt (false);
|
||||||
setQty (0);
|
setQty (0);
|
||||||
|
@ -511,6 +518,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
setIsReceipt(line.isSOTrx());
|
setIsReceipt(line.isSOTrx());
|
||||||
setPayAmt (line.getPayAmt());
|
setPayAmt (line.getPayAmt());
|
||||||
setDiscountAmt(line.getDiscountAmt());
|
setDiscountAmt(line.getDiscountAmt());
|
||||||
|
setWriteOffAmt(line.getWriteOffAmt());
|
||||||
setQty (1);
|
setQty (1);
|
||||||
} // MPaySelectionCheck
|
} // MPaySelectionCheck
|
||||||
|
|
||||||
|
@ -541,17 +549,19 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
public void addLine (MPaySelectionLine line)
|
public void addLine (MPaySelectionLine line)
|
||||||
{
|
{
|
||||||
if (getC_BPartner_ID() != line.getInvoice().getC_BPartner_ID())
|
if (getC_BPartner_ID() != line.getInvoice().getC_BPartner_ID())
|
||||||
throw new IllegalArgumentException("Line for fifferent BPartner");
|
throw new IllegalArgumentException("Line for different BPartner");
|
||||||
//
|
//
|
||||||
if (isReceipt() == line.isSOTrx())
|
if (isReceipt() == line.isSOTrx())
|
||||||
{
|
{
|
||||||
setPayAmt (getPayAmt().add(line.getPayAmt()));
|
setPayAmt (getPayAmt().add(line.getPayAmt()));
|
||||||
setDiscountAmt(getDiscountAmt().add(line.getDiscountAmt()));
|
setDiscountAmt(getDiscountAmt().add(line.getDiscountAmt()));
|
||||||
|
setWriteOffAmt(getWriteOffAmt().add(line.getWriteOffAmt()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setPayAmt (getPayAmt().subtract(line.getPayAmt()));
|
setPayAmt (getPayAmt().subtract(line.getPayAmt()));
|
||||||
setDiscountAmt(getDiscountAmt().subtract(line.getDiscountAmt()));
|
setDiscountAmt(getDiscountAmt().subtract(line.getDiscountAmt()));
|
||||||
|
setWriteOffAmt(getWriteOffAmt().subtract(line.getWriteOffAmt()));
|
||||||
}
|
}
|
||||||
setQty (getQty()+1);
|
setQty (getQty()+1);
|
||||||
} // addLine
|
} // addLine
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -3486055138810301789L;
|
private static final long serialVersionUID = -1880961891234637133L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* Standard Constructor
|
||||||
|
@ -54,8 +54,9 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
||||||
setIsSOTrx (false);
|
setIsSOTrx (false);
|
||||||
setOpenAmt(Env.ZERO);
|
setOpenAmt(Env.ZERO);
|
||||||
setPayAmt (Env.ZERO);
|
setPayAmt (Env.ZERO);
|
||||||
setDiscountAmt(Env.ZERO);
|
setDiscountAmt(Env.ZERO);
|
||||||
setDifferenceAmt (Env.ZERO);
|
setWriteOffAmt (Env.ZERO);
|
||||||
|
setDifferenceAmt (Env.ZERO);
|
||||||
setIsManual (false);
|
setIsManual (false);
|
||||||
}
|
}
|
||||||
} // MPaySelectionLine
|
} // MPaySelectionLine
|
||||||
|
@ -97,17 +98,33 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
||||||
* @param OpenAmt open
|
* @param OpenAmt open
|
||||||
* @param DiscountAmt discount
|
* @param DiscountAmt discount
|
||||||
*/
|
*/
|
||||||
public void setInvoice (int C_Invoice_ID, boolean isSOTrx, BigDecimal OpenAmt,
|
public void xsetInvoice (int C_Invoice_ID, boolean isSOTrx, BigDecimal OpenAmt,
|
||||||
BigDecimal PayAmt, BigDecimal DiscountAmt)
|
BigDecimal PayAmt, BigDecimal DiscountAmt)
|
||||||
{
|
{
|
||||||
setC_Invoice_ID (C_Invoice_ID);
|
setInvoice(C_Invoice_ID, isSOTrx, OpenAmt, PayAmt, DiscountAmt, Env.ZERO);
|
||||||
setIsSOTrx(isSOTrx);
|
|
||||||
setOpenAmt(OpenAmt);
|
|
||||||
setPayAmt (PayAmt);
|
|
||||||
setDiscountAmt(DiscountAmt);
|
|
||||||
setDifferenceAmt(OpenAmt.subtract(PayAmt).subtract(DiscountAmt));
|
|
||||||
} // setInvoive
|
} // setInvoive
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Invoice Info
|
||||||
|
* @param C_Invoice_ID invoice
|
||||||
|
* @param isSOTrx sales trx
|
||||||
|
* @param PayAmt payment
|
||||||
|
* @param OpenAmt open
|
||||||
|
* @param DiscountAmt discount
|
||||||
|
* @param WriteOffAmt writeoff
|
||||||
|
*/
|
||||||
|
public void setInvoice (int C_Invoice_ID, boolean isSOTrx, BigDecimal OpenAmt,
|
||||||
|
BigDecimal PayAmt, BigDecimal DiscountAmt, BigDecimal WriteOffAmt)
|
||||||
|
{
|
||||||
|
setC_Invoice_ID (C_Invoice_ID);
|
||||||
|
setIsSOTrx(isSOTrx);
|
||||||
|
setOpenAmt(OpenAmt);
|
||||||
|
setPayAmt (PayAmt);
|
||||||
|
setDiscountAmt(DiscountAmt);
|
||||||
|
setWriteOffAmt(WriteOffAmt);
|
||||||
|
setDifferenceAmt(OpenAmt.subtract(PayAmt).subtract(DiscountAmt).subtract(WriteOffAmt));
|
||||||
|
} // setInvoice
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Invoice
|
* Get Invoice
|
||||||
* @return invoice
|
* @return invoice
|
||||||
|
@ -126,7 +143,7 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
|
||||||
*/
|
*/
|
||||||
protected boolean beforeSave (boolean newRecord)
|
protected boolean beforeSave (boolean newRecord)
|
||||||
{
|
{
|
||||||
setDifferenceAmt(getOpenAmt().subtract(getPayAmt()).subtract(getDiscountAmt()));
|
setDifferenceAmt(getOpenAmt().subtract(getPayAmt()).subtract(getDiscountAmt()).subtract(getWriteOffAmt()));
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // beforeSave
|
||||||
|
|
||||||
|
|
|
@ -2329,7 +2329,7 @@ public class MPayment extends X_C_Payment
|
||||||
alloc.setDateAcct(getDateAcct()); // in case date acct is different from datetrx in payment
|
alloc.setDateAcct(getDateAcct()); // in case date acct is different from datetrx in payment
|
||||||
|
|
||||||
String sql = "SELECT psc.C_BPartner_ID, psl.C_Invoice_ID, psl.IsSOTrx, " // 1..3
|
String sql = "SELECT psc.C_BPartner_ID, psl.C_Invoice_ID, psl.IsSOTrx, " // 1..3
|
||||||
+ " psl.PayAmt, psl.DiscountAmt, psl.DifferenceAmt, psl.OpenAmt "
|
+ " psl.PayAmt, psl.DiscountAmt, psl.DifferenceAmt, psl.OpenAmt, psl.WriteOffAmt " // 4..8
|
||||||
+ "FROM C_PaySelectionLine psl"
|
+ "FROM C_PaySelectionLine psl"
|
||||||
+ " INNER JOIN C_PaySelectionCheck psc ON (psl.C_PaySelectionCheck_ID=psc.C_PaySelectionCheck_ID) "
|
+ " INNER JOIN C_PaySelectionCheck psc ON (psl.C_PaySelectionCheck_ID=psc.C_PaySelectionCheck_ID) "
|
||||||
+ "WHERE psc.C_Payment_ID=?";
|
+ "WHERE psc.C_Payment_ID=?";
|
||||||
|
@ -2349,7 +2349,7 @@ public class MPayment extends X_C_Payment
|
||||||
boolean isSOTrx = "Y".equals(rs.getString(3));
|
boolean isSOTrx = "Y".equals(rs.getString(3));
|
||||||
BigDecimal PayAmt = rs.getBigDecimal(4);
|
BigDecimal PayAmt = rs.getBigDecimal(4);
|
||||||
BigDecimal DiscountAmt = rs.getBigDecimal(5);
|
BigDecimal DiscountAmt = rs.getBigDecimal(5);
|
||||||
BigDecimal WriteOffAmt = Env.ZERO;
|
BigDecimal WriteOffAmt = rs.getBigDecimal(8);
|
||||||
BigDecimal OpenAmt = rs.getBigDecimal(7);
|
BigDecimal OpenAmt = rs.getBigDecimal(7);
|
||||||
BigDecimal OverUnderAmt = OpenAmt.subtract(PayAmt)
|
BigDecimal OverUnderAmt = OpenAmt.subtract(PayAmt)
|
||||||
.subtract(DiscountAmt).subtract(WriteOffAmt);
|
.subtract(DiscountAmt).subtract(WriteOffAmt);
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class X_C_PaySelectionCheck extends PO implements I_C_PaySelectionCheck,
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 20161030L;
|
private static final long serialVersionUID = 20170113L;
|
||||||
|
|
||||||
/** Standard Constructor */
|
/** Standard Constructor */
|
||||||
public X_C_PaySelectionCheck (Properties ctx, int C_PaySelectionCheck_ID, String trxName)
|
public X_C_PaySelectionCheck (Properties ctx, int C_PaySelectionCheck_ID, String trxName)
|
||||||
|
@ -52,6 +52,8 @@ public class X_C_PaySelectionCheck extends PO implements I_C_PaySelectionCheck,
|
||||||
setProcessed (false);
|
setProcessed (false);
|
||||||
// N
|
// N
|
||||||
setQty (0);
|
setQty (0);
|
||||||
|
setWriteOffAmt (Env.ZERO);
|
||||||
|
// 0
|
||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,4 +437,24 @@ public class X_C_PaySelectionCheck extends PO implements I_C_PaySelectionCheck,
|
||||||
return 0;
|
return 0;
|
||||||
return ii.intValue();
|
return ii.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set Write-off Amount.
|
||||||
|
@param WriteOffAmt
|
||||||
|
Amount to write-off
|
||||||
|
*/
|
||||||
|
public void setWriteOffAmt (BigDecimal WriteOffAmt)
|
||||||
|
{
|
||||||
|
set_Value (COLUMNNAME_WriteOffAmt, WriteOffAmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Write-off Amount.
|
||||||
|
@return Amount to write-off
|
||||||
|
*/
|
||||||
|
public BigDecimal getWriteOffAmt ()
|
||||||
|
{
|
||||||
|
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_WriteOffAmt);
|
||||||
|
if (bd == null)
|
||||||
|
return Env.ZERO;
|
||||||
|
return bd;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -32,7 +32,7 @@ public class X_C_PaySelectionLine extends PO implements I_C_PaySelectionLine, I_
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 20161030L;
|
private static final long serialVersionUID = 20170113L;
|
||||||
|
|
||||||
/** Standard Constructor */
|
/** Standard Constructor */
|
||||||
public X_C_PaySelectionLine (Properties ctx, int C_PaySelectionLine_ID, String trxName)
|
public X_C_PaySelectionLine (Properties ctx, int C_PaySelectionLine_ID, String trxName)
|
||||||
|
@ -55,6 +55,8 @@ public class X_C_PaySelectionLine extends PO implements I_C_PaySelectionLine, I_
|
||||||
// S
|
// S
|
||||||
setProcessed (false);
|
setProcessed (false);
|
||||||
// N
|
// N
|
||||||
|
setWriteOffAmt (Env.ZERO);
|
||||||
|
// 0
|
||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,4 +439,24 @@ public class X_C_PaySelectionLine extends PO implements I_C_PaySelectionLine, I_
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set Write-off Amount.
|
||||||
|
@param WriteOffAmt
|
||||||
|
Amount to write-off
|
||||||
|
*/
|
||||||
|
public void setWriteOffAmt (BigDecimal WriteOffAmt)
|
||||||
|
{
|
||||||
|
set_ValueNoCheck (COLUMNNAME_WriteOffAmt, WriteOffAmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Write-off Amount.
|
||||||
|
@return Amount to write-off
|
||||||
|
*/
|
||||||
|
public BigDecimal getWriteOffAmt ()
|
||||||
|
{
|
||||||
|
BigDecimal bd = (BigDecimal)get_Value(COLUMNNAME_WriteOffAmt);
|
||||||
|
if (bd == null)
|
||||||
|
return Env.ZERO;
|
||||||
|
return bd;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -334,6 +334,8 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
|
||||||
*/
|
*/
|
||||||
protected void cmd_export()
|
protected void cmd_export()
|
||||||
{
|
{
|
||||||
|
if (fPaymentRule.getSelectedItem() == null)
|
||||||
|
return;
|
||||||
String PaymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
|
String PaymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
|
||||||
log.info(PaymentRule);
|
log.info(PaymentRule);
|
||||||
if (!getChecks(PaymentRule))
|
if (!getChecks(PaymentRule))
|
||||||
|
|
|
@ -226,12 +226,13 @@ public class PaySelect
|
||||||
new ColumnInfo(Msg.translate(ctx, "C_BPartner_ID"), "bp.Name", KeyNamePair.class, true, false, "i.C_BPartner_ID"),
|
new ColumnInfo(Msg.translate(ctx, "C_BPartner_ID"), "bp.Name", KeyNamePair.class, true, false, "i.C_BPartner_ID"),
|
||||||
new ColumnInfo(Msg.translate(ctx, "DocumentNo"), "i.DocumentNo", String.class),
|
new ColumnInfo(Msg.translate(ctx, "DocumentNo"), "i.DocumentNo", String.class),
|
||||||
new ColumnInfo(Msg.translate(ctx, "C_Currency_ID"), "c.ISO_Code", KeyNamePair.class, true, false, "i.C_Currency_ID"),
|
new ColumnInfo(Msg.translate(ctx, "C_Currency_ID"), "c.ISO_Code", KeyNamePair.class, true, false, "i.C_Currency_ID"),
|
||||||
// 5..9
|
// 5..10
|
||||||
new ColumnInfo(Msg.translate(ctx, "GrandTotal"), "i.GrandTotal", BigDecimal.class),
|
new ColumnInfo(Msg.translate(ctx, "GrandTotal"), "i.GrandTotal", BigDecimal.class),
|
||||||
new ColumnInfo(Msg.translate(ctx, "DiscountAmt"), "invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID)", BigDecimal.class),
|
new ColumnInfo(Msg.translate(ctx, "DiscountAmt"), "invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID)", BigDecimal.class),
|
||||||
|
new ColumnInfo(Msg.translate(ctx, "WriteOffAmt"), "invoiceWriteOff(i.C_Invoice_ID)", BigDecimal.class),
|
||||||
new ColumnInfo(Msg.getMsg(ctx, "DiscountDate"), "COALESCE((SELECT discountdate from C_InvoicePaySchedule ips WHERE ips.C_InvoicePaySchedule_ID=i.C_InvoicePaySchedule_ID),i.DateInvoiced+p.DiscountDays+p.GraceDays) AS DiscountDate", Timestamp.class),
|
new ColumnInfo(Msg.getMsg(ctx, "DiscountDate"), "COALESCE((SELECT discountdate from C_InvoicePaySchedule ips WHERE ips.C_InvoicePaySchedule_ID=i.C_InvoicePaySchedule_ID),i.DateInvoiced+p.DiscountDays+p.GraceDays) AS DiscountDate", Timestamp.class),
|
||||||
new ColumnInfo(Msg.getMsg(ctx, "AmountDue"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID) AS AmountDue", BigDecimal.class),
|
new ColumnInfo(Msg.getMsg(ctx, "AmountDue"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID) AS AmountDue", BigDecimal.class),
|
||||||
new ColumnInfo(Msg.getMsg(ctx, "AmountPay"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID)-invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID) AS AmountPay", BigDecimal.class)
|
new ColumnInfo(Msg.getMsg(ctx, "AmountPay"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID)-invoiceDiscount(i.C_Invoice_ID,?,i.C_InvoicePaySchedule_ID)-invoiceWriteOff(i.C_Invoice_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID) AS AmountPay", BigDecimal.class)
|
||||||
},
|
},
|
||||||
// FROM
|
// FROM
|
||||||
"C_Invoice_v i"
|
"C_Invoice_v i"
|
||||||
|
@ -442,14 +443,16 @@ public class PaySelect
|
||||||
line += 10;
|
line += 10;
|
||||||
MPaySelectionLine psl = new MPaySelectionLine (m_ps, line, PaymentRule);
|
MPaySelectionLine psl = new MPaySelectionLine (m_ps, line, PaymentRule);
|
||||||
int C_Invoice_ID = id.getRecord_ID().intValue();
|
int C_Invoice_ID = id.getRecord_ID().intValue();
|
||||||
BigDecimal OpenAmt = (BigDecimal)miniTable.getValueAt(i, 8);
|
BigDecimal OpenAmt = (BigDecimal)miniTable.getValueAt(i, 9);
|
||||||
BigDecimal PayAmt = (BigDecimal)miniTable.getValueAt(i, 9);
|
BigDecimal DiscountAmt = (BigDecimal)miniTable.getValueAt(i, 6);
|
||||||
|
BigDecimal WriteOffAmt = (BigDecimal)miniTable.getValueAt(i, 7);
|
||||||
|
BigDecimal PayAmt = (BigDecimal)miniTable.getValueAt(i, 10);
|
||||||
boolean isSOTrx = false;
|
boolean isSOTrx = false;
|
||||||
if (paymentRule != null && X_C_Order.PAYMENTRULE_DirectDebit.equals(paymentRule.getValue()))
|
if (paymentRule != null && X_C_Order.PAYMENTRULE_DirectDebit.equals(paymentRule.getValue()))
|
||||||
isSOTrx = true;
|
isSOTrx = true;
|
||||||
//
|
//
|
||||||
psl.setInvoice(C_Invoice_ID, isSOTrx,
|
psl.setInvoice(C_Invoice_ID, isSOTrx,
|
||||||
OpenAmt, PayAmt, OpenAmt.subtract(PayAmt));
|
OpenAmt, PayAmt, DiscountAmt, WriteOffAmt);
|
||||||
psl.saveEx(trxName);
|
psl.saveEx(trxName);
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("C_Invoice_ID=" + C_Invoice_ID + ", PayAmt=" + PayAmt);
|
if (log.isLoggable(Level.FINE)) log.fine("C_Invoice_ID=" + C_Invoice_ID + ", PayAmt=" + PayAmt);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue