Skip to content

Commit

Permalink
#6511 repair pay selection trx type calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
metas-rc committed May 19, 2020
1 parent 389ee89 commit edf4a08
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

DROP VIEW IF EXISTS C_Invoice_PaySelectionTrxType_V;
CREATE OR REPLACE VIEW C_Invoice_PaySelectionTrxType_V AS
SELECT C_Invoice_ID,
CASE
WHEN /* CREDIT_TRANSFER_TO_VENDOR - "OUT" */ i.IsSOTrx='N' AND i.PaymentRule IN ('T'/*DirectDeposit*/, 'P'/*OnCredit*/) AND i.DocStatus IN ('CO', 'CL') THEN 'CT'
WHEN /* DIRECT_DEBIT_FROM_CUSTOMER - "CDD" */ i.IsSOTrx='Y' AND dt.DocBaseType != 'ARC' AND i.PaymentRule IN ('D'/*DirectDebit*/, 'P'/*OnCredit*/) AND i.DocStatus IN ('CO', 'CL') THEN 'DD'
WHEN /* CREDIT_TRANSFER_TO_CUSTOMER - "CRE" */ i.IsSOTrx='Y' AND dt.DocBaseType = 'ARC' AND i.PaymentRule IN ('T'/*DirectDeposit*/, 'P'/*OnCredit*/) AND i.DocStatus IN ('CO', 'CL') THEN 'CT'
ELSE /* not compatible to any type */ 'XX'
END AS PaySelectionTrxType,
i.IsSOTrx,
i.PaymentRule,
i.DocStatus,
i.DocumentNo,
dt.DocBaseType
FROM C_Invoice i
JOIN C_DocType dt ON dt.C_DocType_ID=i.C_DocType_ID;
COMMENT ON VIEW C_Invoice_PaySelectionTrxType_V IS
'Selects C_Invoice_IDs together with their respective PaySelectionTrxTypes. XX means "none".
The other columns are just for diagnostics/troubleshooting.
Please keep in sync with the code at de.metas.banking.payment.impl.PaySelectionUpdater.buildSelectSQL_MatchRequirement()';
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ else if (getC_BP_Group_ID() > 0)
private String buildSelectSQL_MatchRequirement()
{
final String whereCreditTransferToVendor = " i.IsSOTrx='N' AND i.PaymentRule IN ('" + PaymentRule.DirectDeposit.getCode() + "','" + PaymentRule.OnCredit.getCode() + "') ";
final String whereDirectDebitFromCustomer = " i.IsSOTrx='Y' AND dt.DocBaseType!='ARC' AND i.PaymentRule IN ('" + PaymentRule.DirectDebit.getCode() + "') ";
final String whereDirectDebitFromCustomer = " i.IsSOTrx='Y' AND dt.DocBaseType!='ARC' AND i.PaymentRule IN ('" + PaymentRule.DirectDebit.getCode() + "','" + PaymentRule.OnCredit.getCode() + "') ";
final String whereCreditTransferToCustomer = " i.IsSOTrx='Y' AND dt.DocBaseType='ARC' AND i.PaymentRule IN ('" + PaymentRule.DirectDeposit.getCode() + "','" + PaymentRule.OnCredit.getCode() + "') ";

final InvoiceMatchingMode matchRequirement = getMatchRequirement().orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ CREATE OR REPLACE VIEW C_Invoice_PaySelectionTrxType_V AS
SELECT C_Invoice_ID,
CASE
WHEN /* CREDIT_TRANSFER_TO_VENDOR - "OUT" */ i.IsSOTrx='N' AND i.PaymentRule IN ('T'/*DirectDeposit*/, 'P'/*OnCredit*/) AND i.DocStatus IN ('CO', 'CL') THEN 'CT'
WHEN /* DIRECT_DEBIT_FROM_CUSTOMER - "CDD" */ i.IsSOTrx='Y' AND dt.DocBaseType = 'ARC' AND i.PaymentRule IN ('D'/*DirectDebit*/) AND i.DocStatus IN ('CO', 'CL') THEN 'DD'
WHEN /* CREDIT_TRANSFER_TO_CUSTOMER - "CRE" */ i.IsSOTrx='Y' AND dt.DocBaseType = 'ARC' AND i.PaymentRule IN ('T'/*DirectDeposit*/) AND i.DocStatus IN ('CO', 'CL') THEN 'CT'
WHEN /* DIRECT_DEBIT_FROM_CUSTOMER - "CDD" */ i.IsSOTrx='Y' AND dt.DocBaseType != 'ARC' AND i.PaymentRule IN ('D'/*DirectDebit*/, 'P'/*OnCredit*/) AND i.DocStatus IN ('CO', 'CL') THEN 'DD'
WHEN /* CREDIT_TRANSFER_TO_CUSTOMER - "CRE" */ i.IsSOTrx='Y' AND dt.DocBaseType = 'ARC' AND i.PaymentRule IN ('T'/*DirectDeposit*/, 'P'/*OnCredit*/) AND i.DocStatus IN ('CO', 'CL') THEN 'CT'
ELSE /* not compatible to any type */ 'XX'
END AS PaySelectionTrxType,
i.IsSOTrx,
Expand Down

0 comments on commit edf4a08

Please sign in to comment.