@lucianpacurar/iso20022.js 0.2.14 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +88 -1
- package/dist/index.js +157 -0
- package/dist/index.mjs +157 -1
- package/dist/src/camt/052/cash-management-account-report.d.ts +90 -0
- package/dist/src/camt/index.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1681,6 +1681,93 @@ declare const BalanceTypeCodeDescriptionMap: {
|
|
|
1681
1681
|
};
|
|
1682
1682
|
type BalanceType = (typeof BalanceTypeCode)[keyof typeof BalanceTypeCode];
|
|
1683
1683
|
|
|
1684
|
+
/**
|
|
1685
|
+
* Configuration interface for creating a CashManagementAccountReport instance.
|
|
1686
|
+
*/
|
|
1687
|
+
interface CashManagementAccountReportConfig {
|
|
1688
|
+
/** Unique identifier for the message */
|
|
1689
|
+
messageId: string;
|
|
1690
|
+
/** Date and time when the report was created */
|
|
1691
|
+
creationDate: Date;
|
|
1692
|
+
/** Recipient (party without bank and institution) receiving the report */
|
|
1693
|
+
recipient?: {
|
|
1694
|
+
id?: string;
|
|
1695
|
+
name?: string;
|
|
1696
|
+
address?: StructuredAddress;
|
|
1697
|
+
};
|
|
1698
|
+
/** Array of bank account reports included in the report */
|
|
1699
|
+
statements: Statement[];
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Represents a Cash Management Account Report (CAMT.052.x).
|
|
1703
|
+
* This class encapsulates the data and functionality related to processing
|
|
1704
|
+
* and accessing information from a CAMT.052 XML file.
|
|
1705
|
+
*/
|
|
1706
|
+
declare class CashManagementAccountReport implements GenericISO20022Message {
|
|
1707
|
+
private _messageId;
|
|
1708
|
+
private _creationDate;
|
|
1709
|
+
private _recipient?;
|
|
1710
|
+
private _statements;
|
|
1711
|
+
constructor(config: CashManagementAccountReportConfig);
|
|
1712
|
+
static supportedMessages(): ISO20022MessageTypeName[];
|
|
1713
|
+
get data(): CashManagementAccountReportConfig;
|
|
1714
|
+
static fromDocumentObject(obj: {
|
|
1715
|
+
Document: any;
|
|
1716
|
+
}): CashManagementAccountReport;
|
|
1717
|
+
/**
|
|
1718
|
+
* Creates a CashManagementAccountReport instance from a raw XML string.
|
|
1719
|
+
*
|
|
1720
|
+
* @param {string} rawXml - The raw XML string containing the CAMT.052 data.
|
|
1721
|
+
* @returns {CashManagementAccountReport} A new instance of CashManagementAccountReport.
|
|
1722
|
+
* @throws {Error} If the XML parsing fails or required data is missing.
|
|
1723
|
+
*/
|
|
1724
|
+
static fromXML(rawXml: string): CashManagementAccountReport;
|
|
1725
|
+
/**
|
|
1726
|
+
*
|
|
1727
|
+
* @param json - JSON string representing a CashManagementAccountReport
|
|
1728
|
+
* @returns {CashManagementAccountReport} A new instance of CashManagementAccountReport
|
|
1729
|
+
* @throws {Error} If the JSON parsing fails or required data is missing.
|
|
1730
|
+
*/
|
|
1731
|
+
static fromJSON(json: string): CashManagementAccountReport;
|
|
1732
|
+
toJSON(): any;
|
|
1733
|
+
serialize(): string;
|
|
1734
|
+
/**
|
|
1735
|
+
* Retrieves all balances from all statements in the report.
|
|
1736
|
+
* @returns {Balance[]} An array of all balances across all statements.
|
|
1737
|
+
*/
|
|
1738
|
+
get balances(): Balance[];
|
|
1739
|
+
/**
|
|
1740
|
+
* Retrieves all transactions from all statements in the report.
|
|
1741
|
+
* @returns {Transaction[]} An array of all transactions across all statements.
|
|
1742
|
+
*/
|
|
1743
|
+
get transactions(): Transaction[];
|
|
1744
|
+
/**
|
|
1745
|
+
* Retrieves all entries from all statements in the report.
|
|
1746
|
+
* @returns {Entry[]} An array of all entries across all statements.
|
|
1747
|
+
*/
|
|
1748
|
+
get entries(): Entry[];
|
|
1749
|
+
/**
|
|
1750
|
+
* Gets the unique identifier for the message.
|
|
1751
|
+
* @returns {string} The message ID.
|
|
1752
|
+
*/
|
|
1753
|
+
get messageId(): string;
|
|
1754
|
+
/**
|
|
1755
|
+
* Gets the party receiving the report.
|
|
1756
|
+
* @returns {Party | undefined} The recipient party information, or undefined if no recipient is set.
|
|
1757
|
+
*/
|
|
1758
|
+
get recipient(): Party | undefined;
|
|
1759
|
+
/**
|
|
1760
|
+
* Gets the date and time when the report was created.
|
|
1761
|
+
* @returns {Date} The creation date of the report.
|
|
1762
|
+
*/
|
|
1763
|
+
get creationDate(): Date;
|
|
1764
|
+
/**
|
|
1765
|
+
* Gets all statements included in the report.
|
|
1766
|
+
* @returns {Statement[]} An array of all statements in the report.
|
|
1767
|
+
*/
|
|
1768
|
+
get statements(): Statement[];
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1684
1771
|
type AtLeastOne<T> = [T, ...T[]];
|
|
1685
1772
|
/**
|
|
1686
1773
|
* Configuration interface for the ISO20022 class.
|
|
@@ -2500,4 +2587,4 @@ declare class InvalidXmlNamespaceError extends Iso20022JsError {
|
|
|
2500
2587
|
constructor(message: string);
|
|
2501
2588
|
}
|
|
2502
2589
|
|
|
2503
|
-
export { type ABAAgent, ACHCreditPaymentInitiation, type ACHCreditPaymentInitiationConfig$1 as ACHCreditPaymentInitiationConfig, type ACHCreditPaymentInstruction, type ACHLocalInstrument, ACHLocalInstrumentCode, ACHLocalInstrumentCodeDescriptionMap, type Account, type Agent, type BICAgent, type Balance, type BalanceType, BalanceTypeCode, BalanceTypeCodeDescriptionMap, type BaseAccount, type BaseStatusInformation as BaseStatus, CashManagementEndOfDayReport, type Entry, type GroupStatusInformation as GroupStatus, type IBANAccount, ISO20022, InvalidXmlError, InvalidXmlNamespaceError, Iso20022JsError, type MandateAmendmentInformation, type MandateInformation, type OriginalGroupInformation, type Party, type PaymentStatusInformation as PaymentStatus, PaymentStatusCode, PaymentStatusReport, RTPCreditPaymentInitiation, type RTPCreditPaymentInitiationConfig$1 as RTPCreditPaymentInitiationConfig, type RTPCreditPaymentInstruction, SEPACreditPaymentInitiation, type SEPACreditPaymentInitiationConfig$1 as SEPACreditPaymentInitiationConfig, type SEPACreditPaymentInstruction, SEPADirectDebitPaymentInitiation, type SEPADirectDebitPaymentInitiationConfig$1 as SEPADirectDebitPaymentInitiationConfig, type SEPADirectDebitPaymentInstruction, type SEPADirectDebitPaymentInstructionGroup, type SEPALocalInstrument, SEPAMultiCreditPaymentInitiation, type SEPAMultiCreditPaymentInitiationConfig$1 as SEPAMultiCreditPaymentInitiationConfig, type SEPAMultiCreditPaymentInstructionGroup, type SEPASequenceType, SWIFTCreditPaymentInitiation, type SWIFTCreditPaymentInitiationConfig$1 as SWIFTCreditPaymentInitiationConfig, type SWIFTCreditPaymentInstruction, type Statement, type PaymentStatus as Status, type StatusInformation, type StatusType, type StructuredAddress, type Transaction, type TransactionStatusInformation as TransactionStatus };
|
|
2590
|
+
export { type ABAAgent, ACHCreditPaymentInitiation, type ACHCreditPaymentInitiationConfig$1 as ACHCreditPaymentInitiationConfig, type ACHCreditPaymentInstruction, type ACHLocalInstrument, ACHLocalInstrumentCode, ACHLocalInstrumentCodeDescriptionMap, type Account, type Agent, type BICAgent, type Balance, type BalanceType, BalanceTypeCode, BalanceTypeCodeDescriptionMap, type BaseAccount, type BaseStatusInformation as BaseStatus, CashManagementAccountReport, CashManagementEndOfDayReport, type Entry, type GroupStatusInformation as GroupStatus, type IBANAccount, ISO20022, InvalidXmlError, InvalidXmlNamespaceError, Iso20022JsError, type MandateAmendmentInformation, type MandateInformation, type OriginalGroupInformation, type Party, type PaymentStatusInformation as PaymentStatus, PaymentStatusCode, PaymentStatusReport, RTPCreditPaymentInitiation, type RTPCreditPaymentInitiationConfig$1 as RTPCreditPaymentInitiationConfig, type RTPCreditPaymentInstruction, SEPACreditPaymentInitiation, type SEPACreditPaymentInitiationConfig$1 as SEPACreditPaymentInitiationConfig, type SEPACreditPaymentInstruction, SEPADirectDebitPaymentInitiation, type SEPADirectDebitPaymentInitiationConfig$1 as SEPADirectDebitPaymentInitiationConfig, type SEPADirectDebitPaymentInstruction, type SEPADirectDebitPaymentInstructionGroup, type SEPALocalInstrument, SEPAMultiCreditPaymentInitiation, type SEPAMultiCreditPaymentInitiationConfig$1 as SEPAMultiCreditPaymentInitiationConfig, type SEPAMultiCreditPaymentInstructionGroup, type SEPASequenceType, SWIFTCreditPaymentInitiation, type SWIFTCreditPaymentInitiationConfig$1 as SWIFTCreditPaymentInitiationConfig, type SWIFTCreditPaymentInstruction, type Statement, type PaymentStatus as Status, type StatusInformation, type StatusType, type StructuredAddress, type Transaction, type TransactionStatusInformation as TransactionStatus };
|
package/dist/index.js
CHANGED
|
@@ -2397,6 +2397,7 @@ const ISO20022Messages = {
|
|
|
2397
2397
|
CAMT_004: 'CAMT.004',
|
|
2398
2398
|
CAMT_005: 'CAMT.005',
|
|
2399
2399
|
CAMT_006: 'CAMT.006',
|
|
2400
|
+
CAMT_052: 'CAMT.052',
|
|
2400
2401
|
CAMT_053: 'CAMT.053',
|
|
2401
2402
|
PAIN_001: 'PAIN.001',
|
|
2402
2403
|
PAIN_002: 'PAIN.002',
|
|
@@ -10668,6 +10669,161 @@ class CashManagementReturnTransaction {
|
|
|
10668
10669
|
}
|
|
10669
10670
|
registerISO20022Implementation(CashManagementReturnTransaction);
|
|
10670
10671
|
|
|
10672
|
+
/**
|
|
10673
|
+
* Represents a Cash Management Account Report (CAMT.052.x).
|
|
10674
|
+
* This class encapsulates the data and functionality related to processing
|
|
10675
|
+
* and accessing information from a CAMT.052 XML file.
|
|
10676
|
+
*/
|
|
10677
|
+
class CashManagementAccountReport {
|
|
10678
|
+
_messageId;
|
|
10679
|
+
_creationDate;
|
|
10680
|
+
_recipient;
|
|
10681
|
+
_statements;
|
|
10682
|
+
constructor(config) {
|
|
10683
|
+
this._messageId = config.messageId;
|
|
10684
|
+
this._creationDate = config.creationDate;
|
|
10685
|
+
this._recipient = config.recipient;
|
|
10686
|
+
this._statements = config.statements;
|
|
10687
|
+
}
|
|
10688
|
+
static supportedMessages() {
|
|
10689
|
+
return [ISO20022Messages.CAMT_052];
|
|
10690
|
+
}
|
|
10691
|
+
get data() {
|
|
10692
|
+
return {
|
|
10693
|
+
messageId: this._messageId,
|
|
10694
|
+
creationDate: this._creationDate,
|
|
10695
|
+
recipient: this._recipient,
|
|
10696
|
+
statements: this._statements,
|
|
10697
|
+
};
|
|
10698
|
+
}
|
|
10699
|
+
static fromDocumentObject(obj) {
|
|
10700
|
+
const bankToCustomerAcctRpt = obj.Document.BkToCstmrAcctRpt;
|
|
10701
|
+
const rawCreationDate = bankToCustomerAcctRpt.GrpHdr.CreDtTm;
|
|
10702
|
+
const creationDate = new Date(rawCreationDate);
|
|
10703
|
+
let statements = [];
|
|
10704
|
+
if (Array.isArray(bankToCustomerAcctRpt.Rpt)) {
|
|
10705
|
+
statements = bankToCustomerAcctRpt.Rpt.map((stmt) => parseStatement(stmt));
|
|
10706
|
+
}
|
|
10707
|
+
else {
|
|
10708
|
+
statements = [parseStatement(bankToCustomerAcctRpt.Rpt)];
|
|
10709
|
+
}
|
|
10710
|
+
const rawRecipient = bankToCustomerAcctRpt.GrpHdr.MsgRcpt;
|
|
10711
|
+
return new CashManagementAccountReport({
|
|
10712
|
+
messageId: bankToCustomerAcctRpt.GrpHdr.MsgId.toString(),
|
|
10713
|
+
creationDate,
|
|
10714
|
+
recipient: rawRecipient ? parseRecipient(rawRecipient) : undefined,
|
|
10715
|
+
statements: statements,
|
|
10716
|
+
});
|
|
10717
|
+
}
|
|
10718
|
+
/**
|
|
10719
|
+
* Creates a CashManagementAccountReport instance from a raw XML string.
|
|
10720
|
+
*
|
|
10721
|
+
* @param {string} rawXml - The raw XML string containing the CAMT.052 data.
|
|
10722
|
+
* @returns {CashManagementAccountReport} A new instance of CashManagementAccountReport.
|
|
10723
|
+
* @throws {Error} If the XML parsing fails or required data is missing.
|
|
10724
|
+
*/
|
|
10725
|
+
static fromXML(rawXml) {
|
|
10726
|
+
const parser = XML.getParser();
|
|
10727
|
+
const xml = parser.parse(rawXml);
|
|
10728
|
+
if (!xml.Document) {
|
|
10729
|
+
throw new InvalidXmlError('Invalid XML format');
|
|
10730
|
+
}
|
|
10731
|
+
const namespace = (xml.Document['@_xmlns'] ||
|
|
10732
|
+
xml.Document['@_Xmlns']);
|
|
10733
|
+
if (!namespace.startsWith('urn:iso:std:iso:20022:tech:xsd:camt.052.001.')) {
|
|
10734
|
+
throw new InvalidXmlNamespaceError('Invalid CAMT.052 namespace');
|
|
10735
|
+
}
|
|
10736
|
+
return CashManagementAccountReport.fromDocumentObject(xml);
|
|
10737
|
+
}
|
|
10738
|
+
/**
|
|
10739
|
+
*
|
|
10740
|
+
* @param json - JSON string representing a CashManagementAccountReport
|
|
10741
|
+
* @returns {CashManagementAccountReport} A new instance of CashManagementAccountReport
|
|
10742
|
+
* @throws {Error} If the JSON parsing fails or required data is missing.
|
|
10743
|
+
*/
|
|
10744
|
+
static fromJSON(json) {
|
|
10745
|
+
const obj = JSON.parse(json);
|
|
10746
|
+
if (!obj.Document) {
|
|
10747
|
+
throw new InvalidXmlError('Invalid JSON format');
|
|
10748
|
+
}
|
|
10749
|
+
return CashManagementAccountReport.fromDocumentObject(obj);
|
|
10750
|
+
}
|
|
10751
|
+
toJSON() {
|
|
10752
|
+
const Document = {
|
|
10753
|
+
BkToCstmrAcctRpt: {
|
|
10754
|
+
GrpHdr: {
|
|
10755
|
+
MsgId: this._messageId,
|
|
10756
|
+
CreDtTm: this._creationDate.toISOString(),
|
|
10757
|
+
MsgRcpt: this._recipient
|
|
10758
|
+
? exportRecipient(this._recipient)
|
|
10759
|
+
: undefined,
|
|
10760
|
+
},
|
|
10761
|
+
Rpt: this._statements.map(stmt => exportStatement(stmt)),
|
|
10762
|
+
},
|
|
10763
|
+
};
|
|
10764
|
+
return { Document };
|
|
10765
|
+
}
|
|
10766
|
+
serialize() {
|
|
10767
|
+
const builder = XML.getBuilder();
|
|
10768
|
+
const obj = this.toJSON();
|
|
10769
|
+
obj.Document['@_xmlns'] = 'urn:iso:std:iso:20022:tech:xsd:camt.052.001.02';
|
|
10770
|
+
obj.Document['@_xmlns:xsi'] = 'http://www.w3.org/2001/XMLSchema-instance';
|
|
10771
|
+
return builder.build(obj);
|
|
10772
|
+
}
|
|
10773
|
+
/**
|
|
10774
|
+
* Retrieves all balances from all statements in the report.
|
|
10775
|
+
* @returns {Balance[]} An array of all balances across all statements.
|
|
10776
|
+
*/
|
|
10777
|
+
get balances() {
|
|
10778
|
+
return this._statements.flatMap(statement => statement.balances);
|
|
10779
|
+
}
|
|
10780
|
+
/**
|
|
10781
|
+
* Retrieves all transactions from all statements in the report.
|
|
10782
|
+
* @returns {Transaction[]} An array of all transactions across all statements.
|
|
10783
|
+
*/
|
|
10784
|
+
get transactions() {
|
|
10785
|
+
return this._statements
|
|
10786
|
+
.flatMap(statement => statement.entries)
|
|
10787
|
+
.flatMap(entry => entry.transactions);
|
|
10788
|
+
}
|
|
10789
|
+
/**
|
|
10790
|
+
* Retrieves all entries from all statements in the report.
|
|
10791
|
+
* @returns {Entry[]} An array of all entries across all statements.
|
|
10792
|
+
*/
|
|
10793
|
+
get entries() {
|
|
10794
|
+
return this._statements.flatMap(statement => statement.entries);
|
|
10795
|
+
}
|
|
10796
|
+
/**
|
|
10797
|
+
* Gets the unique identifier for the message.
|
|
10798
|
+
* @returns {string} The message ID.
|
|
10799
|
+
*/
|
|
10800
|
+
get messageId() {
|
|
10801
|
+
return this._messageId;
|
|
10802
|
+
}
|
|
10803
|
+
/**
|
|
10804
|
+
* Gets the party receiving the report.
|
|
10805
|
+
* @returns {Party | undefined} The recipient party information, or undefined if no recipient is set.
|
|
10806
|
+
*/
|
|
10807
|
+
get recipient() {
|
|
10808
|
+
return this._recipient;
|
|
10809
|
+
}
|
|
10810
|
+
/**
|
|
10811
|
+
* Gets the date and time when the report was created.
|
|
10812
|
+
* @returns {Date} The creation date of the report.
|
|
10813
|
+
*/
|
|
10814
|
+
get creationDate() {
|
|
10815
|
+
return this._creationDate;
|
|
10816
|
+
}
|
|
10817
|
+
/**
|
|
10818
|
+
* Gets all statements included in the report.
|
|
10819
|
+
* @returns {Statement[]} An array of all statements in the report.
|
|
10820
|
+
*/
|
|
10821
|
+
get statements() {
|
|
10822
|
+
return this._statements;
|
|
10823
|
+
}
|
|
10824
|
+
}
|
|
10825
|
+
registerISO20022Implementation(CashManagementAccountReport);
|
|
10826
|
+
|
|
10671
10827
|
// Types related to CAMT 053
|
|
10672
10828
|
/**
|
|
10673
10829
|
* Balance types as defined in ISO 20022.
|
|
@@ -11383,6 +11539,7 @@ exports.ACHLocalInstrumentCode = ACHLocalInstrumentCode;
|
|
|
11383
11539
|
exports.ACHLocalInstrumentCodeDescriptionMap = ACHLocalInstrumentCodeDescriptionMap;
|
|
11384
11540
|
exports.BalanceTypeCode = BalanceTypeCode;
|
|
11385
11541
|
exports.BalanceTypeCodeDescriptionMap = BalanceTypeCodeDescriptionMap;
|
|
11542
|
+
exports.CashManagementAccountReport = CashManagementAccountReport;
|
|
11386
11543
|
exports.CashManagementEndOfDayReport = CashManagementEndOfDayReport;
|
|
11387
11544
|
exports.ISO20022 = ISO20022;
|
|
11388
11545
|
exports.InvalidXmlError = InvalidXmlError;
|
package/dist/index.mjs
CHANGED
|
@@ -2395,6 +2395,7 @@ const ISO20022Messages = {
|
|
|
2395
2395
|
CAMT_004: 'CAMT.004',
|
|
2396
2396
|
CAMT_005: 'CAMT.005',
|
|
2397
2397
|
CAMT_006: 'CAMT.006',
|
|
2398
|
+
CAMT_052: 'CAMT.052',
|
|
2398
2399
|
CAMT_053: 'CAMT.053',
|
|
2399
2400
|
PAIN_001: 'PAIN.001',
|
|
2400
2401
|
PAIN_002: 'PAIN.002',
|
|
@@ -10666,6 +10667,161 @@ class CashManagementReturnTransaction {
|
|
|
10666
10667
|
}
|
|
10667
10668
|
registerISO20022Implementation(CashManagementReturnTransaction);
|
|
10668
10669
|
|
|
10670
|
+
/**
|
|
10671
|
+
* Represents a Cash Management Account Report (CAMT.052.x).
|
|
10672
|
+
* This class encapsulates the data and functionality related to processing
|
|
10673
|
+
* and accessing information from a CAMT.052 XML file.
|
|
10674
|
+
*/
|
|
10675
|
+
class CashManagementAccountReport {
|
|
10676
|
+
_messageId;
|
|
10677
|
+
_creationDate;
|
|
10678
|
+
_recipient;
|
|
10679
|
+
_statements;
|
|
10680
|
+
constructor(config) {
|
|
10681
|
+
this._messageId = config.messageId;
|
|
10682
|
+
this._creationDate = config.creationDate;
|
|
10683
|
+
this._recipient = config.recipient;
|
|
10684
|
+
this._statements = config.statements;
|
|
10685
|
+
}
|
|
10686
|
+
static supportedMessages() {
|
|
10687
|
+
return [ISO20022Messages.CAMT_052];
|
|
10688
|
+
}
|
|
10689
|
+
get data() {
|
|
10690
|
+
return {
|
|
10691
|
+
messageId: this._messageId,
|
|
10692
|
+
creationDate: this._creationDate,
|
|
10693
|
+
recipient: this._recipient,
|
|
10694
|
+
statements: this._statements,
|
|
10695
|
+
};
|
|
10696
|
+
}
|
|
10697
|
+
static fromDocumentObject(obj) {
|
|
10698
|
+
const bankToCustomerAcctRpt = obj.Document.BkToCstmrAcctRpt;
|
|
10699
|
+
const rawCreationDate = bankToCustomerAcctRpt.GrpHdr.CreDtTm;
|
|
10700
|
+
const creationDate = new Date(rawCreationDate);
|
|
10701
|
+
let statements = [];
|
|
10702
|
+
if (Array.isArray(bankToCustomerAcctRpt.Rpt)) {
|
|
10703
|
+
statements = bankToCustomerAcctRpt.Rpt.map((stmt) => parseStatement(stmt));
|
|
10704
|
+
}
|
|
10705
|
+
else {
|
|
10706
|
+
statements = [parseStatement(bankToCustomerAcctRpt.Rpt)];
|
|
10707
|
+
}
|
|
10708
|
+
const rawRecipient = bankToCustomerAcctRpt.GrpHdr.MsgRcpt;
|
|
10709
|
+
return new CashManagementAccountReport({
|
|
10710
|
+
messageId: bankToCustomerAcctRpt.GrpHdr.MsgId.toString(),
|
|
10711
|
+
creationDate,
|
|
10712
|
+
recipient: rawRecipient ? parseRecipient(rawRecipient) : undefined,
|
|
10713
|
+
statements: statements,
|
|
10714
|
+
});
|
|
10715
|
+
}
|
|
10716
|
+
/**
|
|
10717
|
+
* Creates a CashManagementAccountReport instance from a raw XML string.
|
|
10718
|
+
*
|
|
10719
|
+
* @param {string} rawXml - The raw XML string containing the CAMT.052 data.
|
|
10720
|
+
* @returns {CashManagementAccountReport} A new instance of CashManagementAccountReport.
|
|
10721
|
+
* @throws {Error} If the XML parsing fails or required data is missing.
|
|
10722
|
+
*/
|
|
10723
|
+
static fromXML(rawXml) {
|
|
10724
|
+
const parser = XML.getParser();
|
|
10725
|
+
const xml = parser.parse(rawXml);
|
|
10726
|
+
if (!xml.Document) {
|
|
10727
|
+
throw new InvalidXmlError('Invalid XML format');
|
|
10728
|
+
}
|
|
10729
|
+
const namespace = (xml.Document['@_xmlns'] ||
|
|
10730
|
+
xml.Document['@_Xmlns']);
|
|
10731
|
+
if (!namespace.startsWith('urn:iso:std:iso:20022:tech:xsd:camt.052.001.')) {
|
|
10732
|
+
throw new InvalidXmlNamespaceError('Invalid CAMT.052 namespace');
|
|
10733
|
+
}
|
|
10734
|
+
return CashManagementAccountReport.fromDocumentObject(xml);
|
|
10735
|
+
}
|
|
10736
|
+
/**
|
|
10737
|
+
*
|
|
10738
|
+
* @param json - JSON string representing a CashManagementAccountReport
|
|
10739
|
+
* @returns {CashManagementAccountReport} A new instance of CashManagementAccountReport
|
|
10740
|
+
* @throws {Error} If the JSON parsing fails or required data is missing.
|
|
10741
|
+
*/
|
|
10742
|
+
static fromJSON(json) {
|
|
10743
|
+
const obj = JSON.parse(json);
|
|
10744
|
+
if (!obj.Document) {
|
|
10745
|
+
throw new InvalidXmlError('Invalid JSON format');
|
|
10746
|
+
}
|
|
10747
|
+
return CashManagementAccountReport.fromDocumentObject(obj);
|
|
10748
|
+
}
|
|
10749
|
+
toJSON() {
|
|
10750
|
+
const Document = {
|
|
10751
|
+
BkToCstmrAcctRpt: {
|
|
10752
|
+
GrpHdr: {
|
|
10753
|
+
MsgId: this._messageId,
|
|
10754
|
+
CreDtTm: this._creationDate.toISOString(),
|
|
10755
|
+
MsgRcpt: this._recipient
|
|
10756
|
+
? exportRecipient(this._recipient)
|
|
10757
|
+
: undefined,
|
|
10758
|
+
},
|
|
10759
|
+
Rpt: this._statements.map(stmt => exportStatement(stmt)),
|
|
10760
|
+
},
|
|
10761
|
+
};
|
|
10762
|
+
return { Document };
|
|
10763
|
+
}
|
|
10764
|
+
serialize() {
|
|
10765
|
+
const builder = XML.getBuilder();
|
|
10766
|
+
const obj = this.toJSON();
|
|
10767
|
+
obj.Document['@_xmlns'] = 'urn:iso:std:iso:20022:tech:xsd:camt.052.001.02';
|
|
10768
|
+
obj.Document['@_xmlns:xsi'] = 'http://www.w3.org/2001/XMLSchema-instance';
|
|
10769
|
+
return builder.build(obj);
|
|
10770
|
+
}
|
|
10771
|
+
/**
|
|
10772
|
+
* Retrieves all balances from all statements in the report.
|
|
10773
|
+
* @returns {Balance[]} An array of all balances across all statements.
|
|
10774
|
+
*/
|
|
10775
|
+
get balances() {
|
|
10776
|
+
return this._statements.flatMap(statement => statement.balances);
|
|
10777
|
+
}
|
|
10778
|
+
/**
|
|
10779
|
+
* Retrieves all transactions from all statements in the report.
|
|
10780
|
+
* @returns {Transaction[]} An array of all transactions across all statements.
|
|
10781
|
+
*/
|
|
10782
|
+
get transactions() {
|
|
10783
|
+
return this._statements
|
|
10784
|
+
.flatMap(statement => statement.entries)
|
|
10785
|
+
.flatMap(entry => entry.transactions);
|
|
10786
|
+
}
|
|
10787
|
+
/**
|
|
10788
|
+
* Retrieves all entries from all statements in the report.
|
|
10789
|
+
* @returns {Entry[]} An array of all entries across all statements.
|
|
10790
|
+
*/
|
|
10791
|
+
get entries() {
|
|
10792
|
+
return this._statements.flatMap(statement => statement.entries);
|
|
10793
|
+
}
|
|
10794
|
+
/**
|
|
10795
|
+
* Gets the unique identifier for the message.
|
|
10796
|
+
* @returns {string} The message ID.
|
|
10797
|
+
*/
|
|
10798
|
+
get messageId() {
|
|
10799
|
+
return this._messageId;
|
|
10800
|
+
}
|
|
10801
|
+
/**
|
|
10802
|
+
* Gets the party receiving the report.
|
|
10803
|
+
* @returns {Party | undefined} The recipient party information, or undefined if no recipient is set.
|
|
10804
|
+
*/
|
|
10805
|
+
get recipient() {
|
|
10806
|
+
return this._recipient;
|
|
10807
|
+
}
|
|
10808
|
+
/**
|
|
10809
|
+
* Gets the date and time when the report was created.
|
|
10810
|
+
* @returns {Date} The creation date of the report.
|
|
10811
|
+
*/
|
|
10812
|
+
get creationDate() {
|
|
10813
|
+
return this._creationDate;
|
|
10814
|
+
}
|
|
10815
|
+
/**
|
|
10816
|
+
* Gets all statements included in the report.
|
|
10817
|
+
* @returns {Statement[]} An array of all statements in the report.
|
|
10818
|
+
*/
|
|
10819
|
+
get statements() {
|
|
10820
|
+
return this._statements;
|
|
10821
|
+
}
|
|
10822
|
+
}
|
|
10823
|
+
registerISO20022Implementation(CashManagementAccountReport);
|
|
10824
|
+
|
|
10669
10825
|
// Types related to CAMT 053
|
|
10670
10826
|
/**
|
|
10671
10827
|
* Balance types as defined in ISO 20022.
|
|
@@ -11376,4 +11532,4 @@ class CashManagementEndOfDayReport {
|
|
|
11376
11532
|
}
|
|
11377
11533
|
registerISO20022Implementation(CashManagementEndOfDayReport);
|
|
11378
11534
|
|
|
11379
|
-
export { ACHCreditPaymentInitiation, ACHLocalInstrumentCode, ACHLocalInstrumentCodeDescriptionMap, BalanceTypeCode, BalanceTypeCodeDescriptionMap, CashManagementEndOfDayReport, ISO20022, InvalidXmlError, InvalidXmlNamespaceError, Iso20022JsError, PaymentStatusCode, PaymentStatusReport, RTPCreditPaymentInitiation, SEPACreditPaymentInitiation, SEPADirectDebitPaymentInitiation, SEPAMultiCreditPaymentInitiation, SWIFTCreditPaymentInitiation };
|
|
11535
|
+
export { ACHCreditPaymentInitiation, ACHLocalInstrumentCode, ACHLocalInstrumentCodeDescriptionMap, BalanceTypeCode, BalanceTypeCodeDescriptionMap, CashManagementAccountReport, CashManagementEndOfDayReport, ISO20022, InvalidXmlError, InvalidXmlNamespaceError, Iso20022JsError, PaymentStatusCode, PaymentStatusReport, RTPCreditPaymentInitiation, SEPACreditPaymentInitiation, SEPADirectDebitPaymentInitiation, SEPAMultiCreditPaymentInitiation, SWIFTCreditPaymentInitiation };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Balance, Entry, Statement, Transaction } from '../types';
|
|
2
|
+
import { Party, StructuredAddress } from '../../lib/types';
|
|
3
|
+
import { GenericISO20022Message, ISO20022MessageTypeName } from '../../lib/interfaces';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration interface for creating a CashManagementAccountReport instance.
|
|
6
|
+
*/
|
|
7
|
+
interface CashManagementAccountReportConfig {
|
|
8
|
+
/** Unique identifier for the message */
|
|
9
|
+
messageId: string;
|
|
10
|
+
/** Date and time when the report was created */
|
|
11
|
+
creationDate: Date;
|
|
12
|
+
/** Recipient (party without bank and institution) receiving the report */
|
|
13
|
+
recipient?: {
|
|
14
|
+
id?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
address?: StructuredAddress;
|
|
17
|
+
};
|
|
18
|
+
/** Array of bank account reports included in the report */
|
|
19
|
+
statements: Statement[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Represents a Cash Management Account Report (CAMT.052.x).
|
|
23
|
+
* This class encapsulates the data and functionality related to processing
|
|
24
|
+
* and accessing information from a CAMT.052 XML file.
|
|
25
|
+
*/
|
|
26
|
+
export declare class CashManagementAccountReport implements GenericISO20022Message {
|
|
27
|
+
private _messageId;
|
|
28
|
+
private _creationDate;
|
|
29
|
+
private _recipient?;
|
|
30
|
+
private _statements;
|
|
31
|
+
constructor(config: CashManagementAccountReportConfig);
|
|
32
|
+
static supportedMessages(): ISO20022MessageTypeName[];
|
|
33
|
+
get data(): CashManagementAccountReportConfig;
|
|
34
|
+
static fromDocumentObject(obj: {
|
|
35
|
+
Document: any;
|
|
36
|
+
}): CashManagementAccountReport;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a CashManagementAccountReport instance from a raw XML string.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} rawXml - The raw XML string containing the CAMT.052 data.
|
|
41
|
+
* @returns {CashManagementAccountReport} A new instance of CashManagementAccountReport.
|
|
42
|
+
* @throws {Error} If the XML parsing fails or required data is missing.
|
|
43
|
+
*/
|
|
44
|
+
static fromXML(rawXml: string): CashManagementAccountReport;
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param json - JSON string representing a CashManagementAccountReport
|
|
48
|
+
* @returns {CashManagementAccountReport} A new instance of CashManagementAccountReport
|
|
49
|
+
* @throws {Error} If the JSON parsing fails or required data is missing.
|
|
50
|
+
*/
|
|
51
|
+
static fromJSON(json: string): CashManagementAccountReport;
|
|
52
|
+
toJSON(): any;
|
|
53
|
+
serialize(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves all balances from all statements in the report.
|
|
56
|
+
* @returns {Balance[]} An array of all balances across all statements.
|
|
57
|
+
*/
|
|
58
|
+
get balances(): Balance[];
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves all transactions from all statements in the report.
|
|
61
|
+
* @returns {Transaction[]} An array of all transactions across all statements.
|
|
62
|
+
*/
|
|
63
|
+
get transactions(): Transaction[];
|
|
64
|
+
/**
|
|
65
|
+
* Retrieves all entries from all statements in the report.
|
|
66
|
+
* @returns {Entry[]} An array of all entries across all statements.
|
|
67
|
+
*/
|
|
68
|
+
get entries(): Entry[];
|
|
69
|
+
/**
|
|
70
|
+
* Gets the unique identifier for the message.
|
|
71
|
+
* @returns {string} The message ID.
|
|
72
|
+
*/
|
|
73
|
+
get messageId(): string;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the party receiving the report.
|
|
76
|
+
* @returns {Party | undefined} The recipient party information, or undefined if no recipient is set.
|
|
77
|
+
*/
|
|
78
|
+
get recipient(): Party | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Gets the date and time when the report was created.
|
|
81
|
+
* @returns {Date} The creation date of the report.
|
|
82
|
+
*/
|
|
83
|
+
get creationDate(): Date;
|
|
84
|
+
/**
|
|
85
|
+
* Gets all statements included in the report.
|
|
86
|
+
* @returns {Statement[]} An array of all statements in the report.
|
|
87
|
+
*/
|
|
88
|
+
get statements(): Statement[];
|
|
89
|
+
}
|
|
90
|
+
export {};
|
package/dist/src/camt/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export * from './003/cash-management-get-account';
|
|
|
2
2
|
export * from './004/cash-management-return-account';
|
|
3
3
|
export * from './005/cash-management-get-transaction';
|
|
4
4
|
export * from './006/cash-management-return-transaction';
|
|
5
|
+
export * from './052/cash-management-account-report';
|
|
5
6
|
export * from './types';
|
package/dist/src/index.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export { PaymentStatusCode } from './pain/002/types';
|
|
|
59
59
|
export { PaymentStatusReport } from './pain/002/payment-status-report';
|
|
60
60
|
export type { SEPADirectDebitPaymentInitiationConfig, SEPADirectDebitPaymentInstructionGroup, } from './pain/008/sepa-direct-debit-payment-initiation';
|
|
61
61
|
export { SEPADirectDebitPaymentInitiation } from './pain/008/sepa-direct-debit-payment-initiation';
|
|
62
|
+
export { CashManagementAccountReport } from './camt/052/cash-management-account-report';
|
|
62
63
|
export type { Statement, Balance, Entry, Transaction, BalanceType, } from './camt/types';
|
|
63
64
|
export { BalanceTypeCode, BalanceTypeCodeDescriptionMap } from './camt/types';
|
|
64
65
|
export { CashManagementEndOfDayReport } from './camt/053/cash-management-end-of-day-report';
|