@@ -35,25 +35,25 @@ export class SepaParser {
3535 let data : Partial < BankTxBatch > = { } ;
3636 try {
3737 data = {
38- sequenceNumber : + info ?. ElctrncSeqNb ,
38+ sequenceNumber : this . toNumber ( info ?. ElctrncSeqNb ) ,
3939 creationDate : new Date ( info ?. CreDtTm ) ,
4040 fromDate : new Date ( info ?. FrToDt ?. FrDtTm ) ,
4141 toDate : new Date ( info ?. FrToDt ?. ToDtTm ) ,
4242 duplicate : this . toString ( info ?. CpyDplctInd ) ,
4343 iban : this . toString ( info ?. Acct ?. Id ?. IBAN ) ,
44- balanceBeforeAmount : + info ?. Bal ?. [ 0 ] ?. Amt ?. [ '#text' ] ,
44+ balanceBeforeAmount : this . toNumber ( info ?. Bal ?. [ 0 ] ?. Amt ?. [ '#text' ] ) ,
4545 balanceBeforeCurrency : this . toString ( info ?. Bal ?. [ 0 ] ?. Amt ?. [ '@_Ccy' ] ) ,
4646 balanceBeforeCdi : this . toString ( info ?. Bal ?. [ 0 ] ?. CdtDbtInd ) ,
47- balanceAfterAmount : + info ?. Bal ?. [ 1 ] ?. Amt ?. [ '#text' ] ,
47+ balanceAfterAmount : this . toNumber ( info ?. Bal ?. [ 1 ] ?. Amt ?. [ '#text' ] ) ,
4848 balanceAfterCurrency : this . toString ( info ?. Bal ?. [ 1 ] ?. Amt ?. [ '@_Ccy' ] ) ,
4949 balanceAfterCdi : this . toString ( info ?. Bal ?. [ 1 ] ?. CdtDbtInd ) ,
50- totalCount : + info ?. TxsSummry ?. TtlNtries ?. NbOfNtries ,
51- totalAmount : + info ?. TxsSummry ?. TtlNtries ?. TtlNetNtry ?. Amt ,
50+ totalCount : this . toNumber ( info ?. TxsSummry ?. TtlNtries ?. NbOfNtries ) ,
51+ totalAmount : this . toNumber ( info ?. TxsSummry ?. TtlNtries ?. TtlNetNtry ?. Amt ) ,
5252 totalCdi : this . toString ( info ?. TxsSummry ?. TtlNtries ?. TtlNetNtry ?. CdtDbtInd ) ,
53- creditCount : + info ?. TxsSummry ?. TtlCdtNtries ?. NbOfNtries ,
54- creditAmount : + info ?. TxsSummry ?. TtlCdtNtries ?. Sum ,
55- debitCount : + info ?. TxsSummry ?. TtlDbtNtries ?. NbOfNtries ,
56- debitAmount : + info ?. TxsSummry ?. TtlDbtNtries ?. Sum ,
53+ creditCount : this . toNumber ( info ?. TxsSummry ?. TtlCdtNtries ?. NbOfNtries ) ,
54+ creditAmount : this . toNumber ( info ?. TxsSummry ?. TtlCdtNtries ?. Sum ) ,
55+ debitCount : this . toNumber ( info ?. TxsSummry ?. TtlDbtNtries ?. NbOfNtries ) ,
56+ debitAmount : this . toNumber ( info ?. TxsSummry ?. TtlDbtNtries ?. Sum ) ,
5757 } ;
5858 } catch ( e ) {
5959 this . logger . error ( `Failed to import SEPA batch data for ID ${ identification } :` , e ) ;
@@ -87,20 +87,20 @@ export class SepaParser {
8787 data = {
8888 bookingDate : new Date ( entry ?. BookgDt ?. Dt ) ,
8989 valueDate : new Date ( entry ?. ValDt ?. Dt ) ,
90- txCount : + entry ?. NtryDtls ?. Btch ?. NbOfTxs ,
90+ txCount : this . toNumber ( entry ?. NtryDtls ?. Btch ?. NbOfTxs ) ,
9191 endToEndId : this . toString ( entry ?. NtryDtls ?. TxDtls ?. Refs ?. EndToEndId ) ,
9292 instructionId : this . toString ( entry ?. NtryDtls ?. TxDtls ?. Refs ?. InstrId ) ,
9393 txId : this . toString ( entry ?. NtryDtls ?. TxDtls ?. Refs ?. TxId ) ,
94- amount : + entry ?. NtryDtls ?. TxDtls ?. Amt ?. [ '#text' ] ,
94+ amount : this . toNumber ( entry ?. NtryDtls ?. TxDtls ?. Amt ?. [ '#text' ] ) ,
9595 currency,
9696 creditDebitIndicator,
97- instructedAmount : + amtDtls ?. InstdAmt ?. Amt ?. [ '#text' ] ,
97+ instructedAmount : this . toNumber ( amtDtls ?. InstdAmt ?. Amt ?. [ '#text' ] ) ,
9898 instructedCurrency : this . toString ( amtDtls ?. InstdAmt ?. Amt ?. [ '@_Ccy' ] ) ,
99- txAmount : + amtDtls ?. TxAmt ?. Amt ?. [ '#text' ] ,
99+ txAmount : this . toNumber ( amtDtls ?. TxAmt ?. Amt ?. [ '#text' ] ) ,
100100 txCurrency : this . toString ( amtDtls ?. TxAmt ?. Amt ?. [ '@_Ccy' ] ) ,
101101 exchangeSourceCurrency : this . toString ( amtDtls ?. TxAmt ?. CcyXchg ?. SrcCcy ) ,
102102 exchangeTargetCurrency : this . toString ( amtDtls ?. TxAmt ?. CcyXchg ?. TrgtCcy ) ,
103- exchangeRate : + amtDtls ?. TxAmt ?. CcyXchg ?. XchgRate ,
103+ exchangeRate : this . toNumber ( amtDtls ?. TxAmt ?. CcyXchg ?. XchgRate ) ,
104104 ...( await this . getTotalCharge (
105105 creditDebitIndicator === SepaCdi . CREDIT ? entry ?. NtryDtls ?. TxDtls ?. Chrgs ?. Rcrd : entry ?. Chrgs ?. Rcrd ,
106106 currency ,
@@ -254,4 +254,10 @@ export class SepaParser {
254254 private toString ( item : unknown ) : string | undefined {
255255 return item != null ? `${ item } ` : undefined ;
256256 }
257+
258+ private toNumber ( item : unknown ) : number | undefined {
259+ if ( item == null ) return undefined ;
260+ const num = + item ;
261+ return isNaN ( num ) ? undefined : num ;
262+ }
257263}
0 commit comments