Skip to content

Commit

Permalink
fix: allow optional bic for Sepa Credit Transfert on creditor agent (#…
Browse files Browse the repository at this point in the history
…289)

* fix: allow optional bic for Sepa Credit Transfert on creditor agent

* fix: remove pnpm-lock and add more precision on test name
  • Loading branch information
remadex authored Dec 3, 2024
1 parent e5cdf01 commit f205e5b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
39 changes: 39 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,42 @@ test("issue #287", () => {
),
).toThrow("sepaData.positions[0].bic is not valid (Test)");
});

test("BIC is not necessary for SEPA Credit Transfer and SEPA Direct Debit on creditor", () => {
expect(
createSepaXML(
{
painVersion: "pain.001.001.03",
id: "Test1345",
creationDate: dayjs.utc("2022-06-16").toDate(),
initiatorName: "Test Company",
positions: [
{
id: "Test123",
batchBooking: false,
iban: "DE02701500000000594937",
requestedExecutionDate: dayjs.utc("2022-06-16").toDate(),
name: "Pos 1",
payments: [
{
id: "123",
amount: 230,
currency: "EUR",
name: "Money Company",
iban: "DE02701500000000594937",
remittanceInformation: "Money please",
end2endReference: "lol",
},
],
},
],
},
{
checkIBAN: true,
checkBIC: true,
},
),
).toBe(
`<?xml version="1.0" encoding="UTF-8"?><Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03 pain.001.001.03.xsd"><CstmrCdtTrfInitn><GrpHdr><MsgId>Test1345</MsgId><CreDtTm>2022-06-16T00:00:00</CreDtTm><NbOfTxs>1</NbOfTxs><CtrlSum>230.00</CtrlSum><InitgPty><Nm>Test Company</Nm></InitgPty></GrpHdr><PmtInf><PmtInfId>Test123</PmtInfId><PmtMtd>TRF</PmtMtd><BtchBookg>false</BtchBookg><NbOfTxs>1</NbOfTxs><CtrlSum>230.00</CtrlSum><PmtTpInf><SvcLvl><Cd>SEPA</Cd></SvcLvl></PmtTpInf><ReqdExctnDt>2022-06-16</ReqdExctnDt><Dbtr><Nm>Pos 1</Nm></Dbtr><DbtrAcct><Id><IBAN>DE02701500000000594937</IBAN></Id></DbtrAcct><DbtrAgt><FinInstnId><BIC/></FinInstnId></DbtrAgt><ChrgBr>SLEV</ChrgBr><CdtTrfTxInf><PmtId><InstrId>123</InstrId><EndToEndId>lol</EndToEndId></PmtId><Amt><InstdAmt Ccy="EUR">230.00</InstdAmt></Amt><CdtrAgt><FinInstnId/></CdtrAgt><Cdtr><Nm>Money Company</Nm></Cdtr><CdtrAcct><Id><IBAN>DE02701500000000594937</IBAN></Id></CdtrAcct><RmtInf><Ustrd>Money please</Ustrd></RmtInf></CdtTrfTxInf></PmtInf></CstmrCdtTrfInitn></Document>`,
);
});
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ function getPayments(
},
};

const bicOptional = PAIN_TYPES[painFormat] === "CstmrDrctDbtInitn";
const bicOptional =
PAIN_TYPES[painFormat] === "CstmrDrctDbtInitn" ||
PAIN_TYPES[painFormat] === "CstmrCdtTrfInitn";
paymentData.CdtrAgt = {
FinInstnId: { BIC: payment.bic },
};
Expand Down

0 comments on commit f205e5b

Please sign in to comment.