@ripwords/myinvois-client 0.3.6 → 0.4.0
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/README.md +27 -0
- package/dist/{apiQueue-DgKWaQDS.cjs → apiQueue-C45w-ymm.cjs} +1 -1
- package/dist/{apiQueue-DgKWaQDS.cjs.map → apiQueue-C45w-ymm.cjs.map} +1 -1
- package/dist/{certificate-CWmfCPdt.cjs → certificate-Dw46fkYv.cjs} +5 -31
- package/dist/certificate-Dw46fkYv.cjs.map +1 -0
- package/dist/{document-B6ab06s1.cjs → document-B11B5lqd.cjs} +75 -21
- package/dist/document-B11B5lqd.cjs.map +1 -0
- package/dist/{documentManagement-BviJDtf2.cjs → documentManagement-qJnd0l1z.cjs} +3 -2
- package/dist/documentManagement-qJnd0l1z.cjs.map +1 -0
- package/dist/{documentSubmission-B6hkivRK.cjs → documentSubmission-BaPECvYU.cjs} +6 -5
- package/dist/{documentSubmission-B6hkivRK.cjs.map → documentSubmission-BaPECvYU.cjs.map} +1 -1
- package/dist/{documentTypeManagement-D_-LiQVg.cjs → documentTypeManagement-DXRLfTsW.cjs} +1 -1
- package/dist/{documentTypeManagement-D_-LiQVg.cjs.map → documentTypeManagement-DXRLfTsW.cjs.map} +1 -1
- package/dist/{getBaseUrl-D0G4GZmp.cjs → getBaseUrl-D2iJdUGL.cjs} +1 -1
- package/dist/{getBaseUrl-D0G4GZmp.cjs.map → getBaseUrl-D2iJdUGL.cjs.map} +1 -1
- package/dist/index.cjs +14 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index10.cjs +6 -195
- package/dist/index11.cjs +22 -0
- package/dist/index12.cjs +2 -24
- package/dist/index13.cjs +3 -0
- package/dist/index14.cjs +3 -0
- package/dist/index15.cjs +325 -25
- package/dist/index15.cjs.map +1 -1
- package/dist/index16.cjs +187 -19
- package/dist/index16.cjs.map +1 -1
- package/dist/index17.cjs +62 -0
- package/dist/index17.cjs.map +1 -0
- package/dist/index18.cjs +523 -25
- package/dist/index18.cjs.map +1 -1
- package/dist/index19.cjs +187 -15
- package/dist/index19.cjs.map +1 -1
- package/dist/index2.cjs +1 -1
- package/dist/index21.cjs +25 -0
- package/dist/{index12.cjs.map → index21.cjs.map} +1 -1
- package/dist/index23.cjs +0 -5
- package/dist/index24.cjs +25 -9
- package/dist/index24.cjs.map +1 -1
- package/dist/index25.cjs +24 -4
- package/dist/index25.cjs.map +1 -0
- package/dist/index26.cjs +0 -22
- package/dist/index27.cjs +33 -2
- package/dist/index27.cjs.map +1 -0
- package/dist/index28.cjs +23 -2
- package/dist/index28.cjs.map +1 -0
- package/dist/index29.cjs +0 -330
- package/dist/index3.cjs +2 -2
- package/dist/index30.cjs +0 -193
- package/dist/index31.cjs +0 -208
- package/dist/index32.cjs +203 -104
- package/dist/index32.cjs.map +1 -1
- package/dist/index33.cjs +104 -132
- package/dist/index33.cjs.map +1 -1
- package/dist/index34.cjs +132 -59
- package/dist/index34.cjs.map +1 -1
- package/dist/index35.cjs +59 -262
- package/dist/index35.cjs.map +1 -1
- package/dist/index36.cjs +262 -74
- package/dist/index36.cjs.map +1 -1
- package/dist/index37.cjs +74 -102
- package/dist/index37.cjs.map +1 -1
- package/dist/index38.cjs +102 -68
- package/dist/index38.cjs.map +1 -1
- package/dist/index39.cjs +68 -107
- package/dist/index39.cjs.map +1 -1
- package/dist/index4.cjs +1 -1
- package/dist/index40.cjs +107 -95
- package/dist/index40.cjs.map +1 -1
- package/dist/index41.cjs +95 -13
- package/dist/index41.cjs.map +1 -1
- package/dist/index42.cjs +11 -31
- package/dist/index42.cjs.map +1 -1
- package/dist/index43.cjs +31 -12
- package/dist/index43.cjs.map +1 -1
- package/dist/index44.cjs +12 -22
- package/dist/index44.cjs.map +1 -1
- package/dist/index45.cjs +22 -13
- package/dist/index45.cjs.map +1 -1
- package/dist/index46.cjs +13 -7
- package/dist/index46.cjs.map +1 -1
- package/dist/index47.cjs +7 -7
- package/dist/index47.cjs.map +1 -1
- package/dist/index48.cjs +7 -10
- package/dist/index48.cjs.map +1 -1
- package/dist/index49.cjs +10 -6
- package/dist/index49.cjs.map +1 -1
- package/dist/index5.cjs +1 -1
- package/dist/index50.cjs +6 -101
- package/dist/index50.cjs.map +1 -1
- package/dist/index51.cjs +101 -106
- package/dist/index51.cjs.map +1 -1
- package/dist/index52.cjs +106 -119
- package/dist/index52.cjs.map +1 -1
- package/dist/index53.cjs +119 -106
- package/dist/index53.cjs.map +1 -1
- package/dist/index54.cjs +106 -98
- package/dist/index54.cjs.map +1 -1
- package/dist/index55.cjs +98 -118
- package/dist/index55.cjs.map +1 -1
- package/dist/index56.cjs +118 -127
- package/dist/index56.cjs.map +1 -1
- package/dist/index57.cjs +127 -117
- package/dist/index57.cjs.map +1 -1
- package/dist/index58.cjs +117 -14
- package/dist/index58.cjs.map +1 -1
- package/dist/index59.cjs +14 -95
- package/dist/index59.cjs.map +1 -1
- package/dist/index6.cjs +1 -1
- package/dist/index60.cjs +95 -142
- package/dist/index60.cjs.map +1 -1
- package/dist/index61.cjs +142 -114
- package/dist/index61.cjs.map +1 -1
- package/dist/index62.cjs +114 -144
- package/dist/index62.cjs.map +1 -1
- package/dist/index63.cjs +144 -113
- package/dist/index63.cjs.map +1 -1
- package/dist/index64.cjs +113 -17
- package/dist/index64.cjs.map +1 -1
- package/dist/index65.cjs +17 -112
- package/dist/index65.cjs.map +1 -1
- package/dist/index66.cjs +112 -47
- package/dist/index66.cjs.map +1 -1
- package/dist/index67.cjs +47 -14
- package/dist/index67.cjs.map +1 -1
- package/dist/index68.cjs +14 -28
- package/dist/index68.cjs.map +1 -1
- package/dist/index69.cjs +28 -22
- package/dist/index69.cjs.map +1 -1
- package/dist/index7.cjs +1 -1
- package/dist/index70.cjs +22 -9
- package/dist/index70.cjs.map +1 -1
- package/dist/index71.cjs +9 -8
- package/dist/index71.cjs.map +1 -1
- package/dist/index72.cjs +8 -17
- package/dist/index72.cjs.map +1 -1
- package/dist/index73.cjs +17 -412
- package/dist/index73.cjs.map +1 -1
- package/dist/index74.cjs +412 -8
- package/dist/index74.cjs.map +1 -1
- package/dist/index75.cjs +8 -9
- package/dist/index75.cjs.map +1 -1
- package/dist/index76.cjs +16 -0
- package/dist/index76.cjs.map +1 -0
- package/dist/index8.cjs +4 -61
- package/dist/index9.cjs +9 -528
- package/dist/index9.cjs.map +1 -1
- package/dist/lineItems-C8iT0OL1.cjs +64 -0
- package/dist/lineItems-C8iT0OL1.cjs.map +1 -0
- package/dist/{notificationManagement-DLBDn77E.cjs → notificationManagement-C_qrFwWL.cjs} +1 -1
- package/dist/{notificationManagement-DLBDn77E.cjs.map → notificationManagement-C_qrFwWL.cjs.map} +1 -1
- package/dist/{platformLogin-Ch6hFKoU.cjs → platformLogin-DC4s6Qpv.cjs} +1 -1
- package/dist/{platformLogin-Ch6hFKoU.cjs.map → platformLogin-DC4s6Qpv.cjs.map} +1 -1
- package/dist/{taxpayerValidation-j8s6YGED.cjs → taxpayerValidation-DzCJROgP.cjs} +1 -1
- package/dist/{taxpayerValidation-j8s6YGED.cjs.map → taxpayerValidation-DzCJROgP.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/0X-Cr3M7hci.d.cts +0 -211
- package/dist/0X-qj3c_vAo.d.ts +0 -210
- package/dist/1X-B-lyAVC4.d.ts +0 -111
- package/dist/1X-C72Wa4pk.d.ts +0 -19
- package/dist/1X-CWwmfCzo.d.cts +0 -112
- package/dist/1X-DYw2tURz.d.cts +0 -20
- package/dist/2X-BfCK614i.d.ts +0 -139
- package/dist/2X-CH89y3Af.d.ts +0 -39
- package/dist/2X-CXtqiwRg.d.cts +0 -40
- package/dist/2X-DNtkJ0tj.d.cts +0 -140
- package/dist/3X-BOxfatu3.d.cts +0 -62
- package/dist/3X-Bk_fUIAk.d.cts +0 -21
- package/dist/3X-DryrwYRf.d.ts +0 -20
- package/dist/3X-Du10Ix_V.d.ts +0 -61
- package/dist/4X-BPMLRoDv.d.ts +0 -30
- package/dist/4X-C7fzDWJ_.d.cts +0 -265
- package/dist/4X-CK9rj5qd.d.cts +0 -31
- package/dist/4X-x3cRFuSM.d.ts +0 -264
- package/dist/5X-B52AKeTz.d.ts +0 -76
- package/dist/5X-Bv7M6KyG.d.ts +0 -21
- package/dist/5X-CNAFsDm2.d.cts +0 -77
- package/dist/5X-CpAvNxvd.d.cts +0 -22
- package/dist/6X-DBwpWPQ6.d.ts +0 -104
- package/dist/6X-ZeZ8OB57.d.ts +0 -15
- package/dist/6X-bXWr_7xY.d.cts +0 -16
- package/dist/6X-uObUP4VG.d.cts +0 -105
- package/dist/7X-BJBOlWhV.d.cts +0 -16
- package/dist/7X-BifJnY24.d.cts +0 -71
- package/dist/7X-C_XGDSpE.d.ts +0 -70
- package/dist/7X-Dvw2Z2VN.d.ts +0 -15
- package/dist/8X-BkgoX8dg.d.ts +0 -18
- package/dist/8X-Di_0wuRX.d.ts +0 -109
- package/dist/8X-DioBXCJ0.d.cts +0 -110
- package/dist/8X-dshwiOxU.d.cts +0 -19
- package/dist/9X-8ZnvvViY.d.ts +0 -97
- package/dist/9X-9j2Djy4W.d.cts +0 -15
- package/dist/9X-BjffnXuq.d.cts +0 -98
- package/dist/9X-Du0e44cq.d.ts +0 -14
- package/dist/AX-BSPLpkVT.d.ts +0 -110
- package/dist/AX-CWCopjCC.d.cts +0 -111
- package/dist/BX-Cq7WdhD3.d.cts +0 -115
- package/dist/BX-u4yMaIkz.d.ts +0 -114
- package/dist/CX-BKZG0pVE.d.ts +0 -127
- package/dist/CX-DlcVZfxx.d.cts +0 -128
- package/dist/DX-CwA9WJAf.d.ts +0 -114
- package/dist/DX-DLdv-Nxj.d.cts +0 -115
- package/dist/EX-BRNu1Ooi.d.ts +0 -106
- package/dist/EX-CIJv8-Lw.d.cts +0 -107
- package/dist/FX-DBxjq6xY.d.ts +0 -126
- package/dist/FX-DlDM_Zea.d.cts +0 -127
- package/dist/GX-B3CvWNrP.d.ts +0 -135
- package/dist/GX-BFGNX6Jy.d.cts +0 -136
- package/dist/HX-D7FABgTv.d.ts +0 -125
- package/dist/HX-D7Y9qRSm.d.cts +0 -126
- package/dist/IX-D3ZknsAB.d.ts +0 -22
- package/dist/IX-DPTrbhgX.d.cts +0 -23
- package/dist/JX-BRaZM3Gc.d.ts +0 -103
- package/dist/JX-D8JmtNpo.d.cts +0 -104
- package/dist/KX-B1K0OWoi.d.ts +0 -150
- package/dist/KX-B46KJZrH.d.cts +0 -151
- package/dist/LX-CKRefinL.d.ts +0 -122
- package/dist/LX-CfTKy8Sx.d.cts +0 -123
- package/dist/MX-BKJ4gNvV.d.cts +0 -153
- package/dist/MX-DKmaeO9r.d.ts +0 -152
- package/dist/NX-CJL2Gn1U.d.ts +0 -121
- package/dist/NX-CSdLIFqU.d.cts +0 -122
- package/dist/OX-BwqOsulT.d.cts +0 -26
- package/dist/OX-Do2ap5v_.d.ts +0 -25
- package/dist/PX-BTx0TXsJ.d.cts +0 -121
- package/dist/PX-_DOr_rm9.d.ts +0 -120
- package/dist/QX-BUXR8RJL.d.cts +0 -59
- package/dist/QX-HlXLkIki.d.ts +0 -58
- package/dist/RX-CZ8HiH37.d.cts +0 -23
- package/dist/RX-DVPGOVES.d.ts +0 -22
- package/dist/SX-CLxsqiQk.d.cts +0 -40
- package/dist/SX-OGT3qwlS.d.ts +0 -39
- package/dist/TX-DKc8hLc4.d.cts +0 -31
- package/dist/TX-cPDINmZ5.d.ts +0 -30
- package/dist/UX-Be3sqvPV.d.ts +0 -17
- package/dist/UX-bc7xDnZI.d.cts +0 -18
- package/dist/VX-CIHTFyoC.d.cts +0 -17
- package/dist/VX-CoEuBNDK.d.ts +0 -16
- package/dist/WX-BHvlq7Jx.d.cts +0 -26
- package/dist/WX-DMvw__jH.d.ts +0 -25
- package/dist/XX-DOA-10JW.d.ts +0 -827
- package/dist/XX-DztQxYHJ.d.cts +0 -828
- package/dist/YX-CkxLeFb4.d.cts +0 -20
- package/dist/YX-F34sJ7Ik.d.ts +0 -19
- package/dist/ZX-CDQOfsHh.d.ts +0 -21
- package/dist/ZX-DVb_buNI.d.cts +0 -22
- package/dist/api/documentManagement.d.ts +0 -89
- package/dist/api/documentManagement.js +0 -3
- package/dist/api/documentSubmission.d.ts +0 -92
- package/dist/api/documentSubmission.js +0 -5
- package/dist/api/documentTypeManagement.d.ts +0 -70
- package/dist/api/documentTypeManagement.js +0 -3
- package/dist/api/notificationManagement.d.ts +0 -68
- package/dist/api/notificationManagement.js +0 -3
- package/dist/api/platformLogin.d.ts +0 -68
- package/dist/api/platformLogin.js +0 -3
- package/dist/api/taxpayerValidation.d.ts +0 -71
- package/dist/api/taxpayerValidation.js +0 -4
- package/dist/apiQueue-B6Q644Bz.js +0 -201
- package/dist/certificate-COwqszxD.js +0 -71
- package/dist/certificate-CWmfCPdt.cjs.map +0 -1
- package/dist/chunk-CUT6urMc.cjs +0 -30
- package/dist/classification-codes-B15PbWxz.d.cts +0 -118
- package/dist/classification-codes-C2X4xW5-.d.ts +0 -117
- package/dist/country-code-DPeNFMMi.d.cts +0 -543
- package/dist/country-code-DsI8Mbzx.d.ts +0 -542
- package/dist/currencies-DKuDflOO.d.ts +0 -207
- package/dist/currencies-S5g1gzBU.d.cts +0 -208
- package/dist/document-B6ab06s1.cjs.map +0 -1
- package/dist/document-Bb5WkhRe.js +0 -626
- package/dist/documentManagement-BviJDtf2.cjs.map +0 -1
- package/dist/documentManagement-lPm8Gziu.js +0 -49
- package/dist/documentSubmission-CMMzKvVl.js +0 -134
- package/dist/documentTypeManagement-cBtVCOY3.js +0 -22
- package/dist/documents-BYV12TVt.d.ts +0 -1196
- package/dist/documents-D_V38Q_U.d.cts +0 -1197
- package/dist/e-invoice-BuwtFnlI.d.cts +0 -44
- package/dist/e-invoice-C2TxhyrK.d.ts +0 -43
- package/dist/formatIdValue-qTxJqj9o.js +0 -7
- package/dist/getBaseUrl-D7nUmoYb.js +0 -7
- package/dist/index-CygwSf0x.d.ts +0 -15
- package/dist/index-Yr1QAbIF.d.cts +0 -16
- package/dist/index.d.ts +0 -614
- package/dist/index.js +0 -627
- package/dist/index10.cjs.map +0 -1
- package/dist/index29.cjs.map +0 -1
- package/dist/index30.cjs.map +0 -1
- package/dist/index31.cjs.map +0 -1
- package/dist/index61.cts.map +0 -1
- package/dist/index62.cts.map +0 -1
- package/dist/index63.cts.map +0 -1
- package/dist/index64.cts.map +0 -1
- package/dist/index65.cts.map +0 -1
- package/dist/index66.cts.map +0 -1
- package/dist/index67.cts.map +0 -1
- package/dist/index68.cts.map +0 -1
- package/dist/index69.cts.map +0 -1
- package/dist/index70.cts.map +0 -1
- package/dist/index71.cts.map +0 -1
- package/dist/index72.cts.map +0 -1
- package/dist/index73.cts.map +0 -1
- package/dist/index74.cts.map +0 -1
- package/dist/index75.cts.map +0 -1
- package/dist/index8.cjs.map +0 -1
- package/dist/msic-codes-CIKdPqag.d.cts +0 -26
- package/dist/msic-codes-CjrrJmzb.d.ts +0 -25
- package/dist/notificationManagement-n4Z5e-My.js +0 -19
- package/dist/notifications-DdlEkprb.d.cts +0 -63
- package/dist/notifications-sFhgh3rJ.d.ts +0 -62
- package/dist/payment-modes-7c1lWlIr.d.cts +0 -44
- package/dist/payment-modes-g3DzLmWb.d.ts +0 -43
- package/dist/platformLogin-CqI9OLYP.js +0 -39
- package/dist/signatures-CerHUrj3.d.ts +0 -172
- package/dist/signatures-CyDSZr_e.d.cts +0 -173
- package/dist/state-codes-Ow4oehYT.d.ts +0 -61
- package/dist/state-codes-u3ppueWo.d.cts +0 -62
- package/dist/tax-types-ClyLgydM.d.ts +0 -41
- package/dist/tax-types-fu5Q6dic.d.cts +0 -42
- package/dist/taxpayer-BAoT73gg.d.ts +0 -35
- package/dist/taxpayer-DwGzY1IL.d.cts +0 -36
- package/dist/taxpayerValidation-Xd_EHDvk.js +0 -47
- package/dist/types/classification-codes.d.ts +0 -2
- package/dist/types/country-code.d.ts +0 -2
- package/dist/types/currencies.d.ts +0 -2
- package/dist/types/documents.d.ts +0 -55
- package/dist/types/e-invoice.d.ts +0 -2
- package/dist/types/index.d.ts +0 -61
- package/dist/types/msic/0X.d.ts +0 -2
- package/dist/types/msic/1X.d.ts +0 -2
- package/dist/types/msic/2X.d.ts +0 -2
- package/dist/types/msic/3X.d.ts +0 -2
- package/dist/types/msic/4X.d.ts +0 -2
- package/dist/types/msic/5X.d.ts +0 -2
- package/dist/types/msic/6X.d.ts +0 -2
- package/dist/types/msic/7X.d.ts +0 -2
- package/dist/types/msic/8X.d.ts +0 -2
- package/dist/types/msic/9X.d.ts +0 -2
- package/dist/types/msic-codes.d.ts +0 -12
- package/dist/types/notifications.d.ts +0 -2
- package/dist/types/payment-modes.d.ts +0 -2
- package/dist/types/signatures.d.ts +0 -2
- package/dist/types/state-codes.d.ts +0 -2
- package/dist/types/tax-types.d.ts +0 -2
- package/dist/types/taxpayer.d.ts +0 -56
- package/dist/types/unit/1X.d.ts +0 -2
- package/dist/types/unit/2X.d.ts +0 -2
- package/dist/types/unit/3X.d.ts +0 -2
- package/dist/types/unit/4X.d.ts +0 -2
- package/dist/types/unit/5X.d.ts +0 -2
- package/dist/types/unit/6X.d.ts +0 -2
- package/dist/types/unit/7X.d.ts +0 -2
- package/dist/types/unit/8X.d.ts +0 -2
- package/dist/types/unit/9X.d.ts +0 -2
- package/dist/types/unit/AX.d.ts +0 -2
- package/dist/types/unit/BX.d.ts +0 -2
- package/dist/types/unit/CX.d.ts +0 -2
- package/dist/types/unit/DX.d.ts +0 -2
- package/dist/types/unit/EX.d.ts +0 -2
- package/dist/types/unit/FX.d.ts +0 -2
- package/dist/types/unit/GX.d.ts +0 -2
- package/dist/types/unit/HX.d.ts +0 -2
- package/dist/types/unit/IX.d.ts +0 -2
- package/dist/types/unit/JX.d.ts +0 -2
- package/dist/types/unit/KX.d.ts +0 -2
- package/dist/types/unit/LX.d.ts +0 -2
- package/dist/types/unit/MX.d.ts +0 -2
- package/dist/types/unit/NX.d.ts +0 -2
- package/dist/types/unit/OX.d.ts +0 -2
- package/dist/types/unit/PX.d.ts +0 -2
- package/dist/types/unit/QX.d.ts +0 -2
- package/dist/types/unit/RX.d.ts +0 -2
- package/dist/types/unit/SX.d.ts +0 -2
- package/dist/types/unit/TX.d.ts +0 -2
- package/dist/types/unit/UX.d.ts +0 -2
- package/dist/types/unit/VX.d.ts +0 -2
- package/dist/types/unit/WX.d.ts +0 -2
- package/dist/types/unit/XX.d.ts +0 -2
- package/dist/types/unit/YX.d.ts +0 -2
- package/dist/types/unit/ZX.d.ts +0 -2
- package/dist/types/unit-types.d.ts +0 -37
- package/dist/types/utils.d.ts +0 -2
- package/dist/unit-types-BXdufGWm.d.cts +0 -56
- package/dist/unit-types-VgYXIwTT.d.ts +0 -55
- package/dist/utils/apiQueue.d.ts +0 -45
- package/dist/utils/apiQueue.js +0 -3
- package/dist/utils/base64.d.ts +0 -5
- package/dist/utils/base64.js +0 -10
- package/dist/utils/certificate.d.ts +0 -26
- package/dist/utils/certificate.js +0 -3
- package/dist/utils/document.d.ts +0 -211
- package/dist/utils/document.js +0 -4
- package/dist/utils/formatIdValue.d.ts +0 -4
- package/dist/utils/formatIdValue.js +0 -3
- package/dist/utils/getBaseUrl.d.ts +0 -4
- package/dist/utils/getBaseUrl.js +0 -3
- package/dist/utils/signature-diagnostics.d.ts +0 -96
- package/dist/utils/signature-diagnostics.js +0 -327
- package/dist/utils/validation.d.ts +0 -108
- package/dist/utils/validation.js +0 -186
- package/dist/utils-C4FoVKLq.d.ts +0 -4
- package/dist/utils-Cdqbbzca.d.cts +0 -5
|
@@ -1,626 +0,0 @@
|
|
|
1
|
-
import { formatIdValue } from "./formatIdValue-qTxJqj9o.js";
|
|
2
|
-
import crypto, { X509Certificate } from "crypto";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/document.ts
|
|
5
|
-
/**
|
|
6
|
-
* MyInvois v1.1 Document Generation and Signing Utilities
|
|
7
|
-
* Strictly follows: https://sdk.myinvois.hasil.gov.my/documents/invoice-v1-1
|
|
8
|
-
* JSON Signature Guide: https://sdk.myinvois.hasil.gov.my/signature-creation-json/
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Determines if a line item uses fixed rate taxation
|
|
12
|
-
*/
|
|
13
|
-
const isFixedRateTax = (item) => {
|
|
14
|
-
return item.taxPerUnitAmount !== void 0 && item.baseUnitMeasure !== void 0;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Determines if a line item uses percentage taxation
|
|
18
|
-
*/
|
|
19
|
-
const isPercentageTax = (item) => {
|
|
20
|
-
return item.taxRate !== void 0 && !isFixedRateTax(item);
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Calculates expected tax amount for a line item based on its tax type
|
|
24
|
-
*/
|
|
25
|
-
const calculateExpectedTaxAmount = (item) => {
|
|
26
|
-
if (isFixedRateTax(item)) return item.taxPerUnitAmount * item.baseUnitMeasure;
|
|
27
|
-
else if (isPercentageTax(item)) return item.totalTaxableAmountPerLine * item.taxRate / 100;
|
|
28
|
-
return 0;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Extracts the line-item array from any document variant
|
|
32
|
-
*/
|
|
33
|
-
const getLineItems = (doc) => {
|
|
34
|
-
if ("invoiceLineItems" in doc) return doc.invoiceLineItems;
|
|
35
|
-
if ("creditNoteLineItems" in doc) return doc.creditNoteLineItems;
|
|
36
|
-
if ("debitNoteLineItems" in doc) return doc.debitNoteLineItems;
|
|
37
|
-
if ("refundNoteLineItems" in doc) return doc.refundNoteLineItems;
|
|
38
|
-
if ("selfBilledCreditNoteLineItems" in doc) return doc.selfBilledCreditNoteLineItems;
|
|
39
|
-
if ("selfBilledRefundNoteLineItems" in doc) return doc.selfBilledRefundNoteLineItems;
|
|
40
|
-
return [];
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Helper function to recursively sort object keys for JSON canonicalization
|
|
44
|
-
*/
|
|
45
|
-
function sortObjectKeys(obj) {
|
|
46
|
-
if (obj === null || typeof obj !== "object") return obj;
|
|
47
|
-
if (Array.isArray(obj)) return obj.map(sortObjectKeys);
|
|
48
|
-
const sortedObj = {};
|
|
49
|
-
const keys = Object.keys(obj).sort();
|
|
50
|
-
for (const key of keys) sortedObj[key] = sortObjectKeys(obj[key]);
|
|
51
|
-
return sortedObj;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Enhanced canonicalization following MyInvois specification exactly
|
|
55
|
-
* Key changes: ensure consistent ordering and formatting
|
|
56
|
-
*/
|
|
57
|
-
const canonicalizeJSON = (obj) => {
|
|
58
|
-
const sortedObj = sortObjectKeys(obj);
|
|
59
|
-
return JSON.stringify(sortedObj, null, 0);
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Generates a clean invoice object following MyInvois v1.1 specification exactly
|
|
63
|
-
* This is the base invoice structure WITHOUT signature elements (for hash calculation)
|
|
64
|
-
*
|
|
65
|
-
* Key requirements from working documents:
|
|
66
|
-
* - All mandatory fields must be present
|
|
67
|
-
* - Many optional fields must be present even if empty
|
|
68
|
-
* - Specific field ordering and structure
|
|
69
|
-
* - Correct listID values (e.g., "3166-1" not "ISO3166-1")
|
|
70
|
-
*/
|
|
71
|
-
const generateCleanInvoiceObject = (invoice) => {
|
|
72
|
-
const lineItems = getLineItems(invoice);
|
|
73
|
-
return {
|
|
74
|
-
ID: [{ _: invoice.eInvoiceCodeOrNumber }],
|
|
75
|
-
IssueDate: [{ _: invoice.eInvoiceDate }],
|
|
76
|
-
IssueTime: [{ _: invoice.eInvoiceTime }],
|
|
77
|
-
InvoiceTypeCode: [{
|
|
78
|
-
_: invoice.eInvoiceTypeCode,
|
|
79
|
-
listVersionID: invoice.eInvoiceVersion || "1.1"
|
|
80
|
-
}],
|
|
81
|
-
DocumentCurrencyCode: [{ _: invoice.invoiceCurrencyCode }],
|
|
82
|
-
..."originalEInvoiceReferenceNumber" in invoice && "originalEInvoiceInternalId" in invoice && invoice.originalEInvoiceReferenceNumber ? { BillingReference: [{ InvoiceDocumentReference: [{
|
|
83
|
-
UUID: [{ _: invoice.originalEInvoiceReferenceNumber }],
|
|
84
|
-
ID: [{ _: invoice.originalEInvoiceInternalId }]
|
|
85
|
-
}] }] } : {},
|
|
86
|
-
AccountingSupplierParty: [{ Party: [{
|
|
87
|
-
IndustryClassificationCode: [{
|
|
88
|
-
_: invoice.supplier.industryClassificationCode,
|
|
89
|
-
name: invoice.supplier.industryClassificationDescription
|
|
90
|
-
}],
|
|
91
|
-
PartyIdentification: [{ ID: [{
|
|
92
|
-
_: invoice.supplier.tin,
|
|
93
|
-
schemeID: "TIN"
|
|
94
|
-
}] }, { ID: [{
|
|
95
|
-
_: formatIdValue(invoice.supplier.registrationNumber),
|
|
96
|
-
schemeID: invoice.supplier.registrationType || "NRIC"
|
|
97
|
-
}] }],
|
|
98
|
-
PostalAddress: [{
|
|
99
|
-
CityName: [{ _: invoice.supplier.address.cityName }],
|
|
100
|
-
CountrySubentityCode: [{ _: invoice.supplier.address.state }],
|
|
101
|
-
AddressLine: [{ Line: [{ _: invoice.supplier.address.addressLine0 }] }],
|
|
102
|
-
Country: [{ IdentificationCode: [{
|
|
103
|
-
_: invoice.supplier.address.country || "MYS",
|
|
104
|
-
listID: "3166-1",
|
|
105
|
-
listAgencyID: "ISO"
|
|
106
|
-
}] }]
|
|
107
|
-
}],
|
|
108
|
-
PartyLegalEntity: [{ RegistrationName: [{ _: invoice.supplier.name }] }],
|
|
109
|
-
Contact: [{ Telephone: [{ _: invoice.supplier.contactNumber || "" }] }]
|
|
110
|
-
}] }],
|
|
111
|
-
AccountingCustomerParty: [{ Party: [{
|
|
112
|
-
PartyIdentification: [
|
|
113
|
-
{ ID: [{
|
|
114
|
-
_: invoice.buyer.tin,
|
|
115
|
-
schemeID: "TIN"
|
|
116
|
-
}] },
|
|
117
|
-
{ ID: [{
|
|
118
|
-
_: formatIdValue(invoice.buyer.registrationNumber),
|
|
119
|
-
schemeID: invoice.buyer.registrationType || "NRIC"
|
|
120
|
-
}] },
|
|
121
|
-
{ ID: [{
|
|
122
|
-
_: invoice.buyer.sstRegistrationNumber || "NA",
|
|
123
|
-
schemeID: "SST"
|
|
124
|
-
}] }
|
|
125
|
-
],
|
|
126
|
-
PostalAddress: [{
|
|
127
|
-
CityName: [{ _: invoice.buyer.address.cityName }],
|
|
128
|
-
CountrySubentityCode: [{ _: invoice.buyer.address.state }],
|
|
129
|
-
AddressLine: [{ Line: [{ _: invoice.buyer.address.addressLine0 }] }],
|
|
130
|
-
Country: [{ IdentificationCode: [{
|
|
131
|
-
_: invoice.buyer.address.country || "MYS",
|
|
132
|
-
listID: "3166-1",
|
|
133
|
-
listAgencyID: "ISO"
|
|
134
|
-
}] }]
|
|
135
|
-
}],
|
|
136
|
-
PartyLegalEntity: [{ RegistrationName: [{ _: invoice.buyer.name }] }],
|
|
137
|
-
Contact: [{ Telephone: [{ _: invoice.buyer.contactNumber || "" }] }]
|
|
138
|
-
}] }],
|
|
139
|
-
TaxTotal: [{
|
|
140
|
-
TaxAmount: [{
|
|
141
|
-
_: invoice.taxTotal.taxAmount,
|
|
142
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
143
|
-
}],
|
|
144
|
-
TaxSubtotal: [{
|
|
145
|
-
TaxableAmount: [{
|
|
146
|
-
_: invoice.legalMonetaryTotal.taxExclusiveAmount,
|
|
147
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
148
|
-
}],
|
|
149
|
-
TaxAmount: [{
|
|
150
|
-
_: invoice.taxTotal.taxAmount,
|
|
151
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
152
|
-
}],
|
|
153
|
-
TaxCategory: [{
|
|
154
|
-
ID: [{ _: lineItems[0]?.taxType || "01" }],
|
|
155
|
-
TaxScheme: [{ ID: [{
|
|
156
|
-
_: "OTH",
|
|
157
|
-
schemeAgencyID: "6",
|
|
158
|
-
schemeID: "UN/ECE 5153"
|
|
159
|
-
}] }]
|
|
160
|
-
}]
|
|
161
|
-
}]
|
|
162
|
-
}],
|
|
163
|
-
LegalMonetaryTotal: [{
|
|
164
|
-
LineExtensionAmount: [{
|
|
165
|
-
_: invoice.legalMonetaryTotal.taxExclusiveAmount,
|
|
166
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
167
|
-
}],
|
|
168
|
-
TaxExclusiveAmount: [{
|
|
169
|
-
_: invoice.legalMonetaryTotal.taxExclusiveAmount,
|
|
170
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
171
|
-
}],
|
|
172
|
-
TaxInclusiveAmount: [{
|
|
173
|
-
_: invoice.legalMonetaryTotal.taxInclusiveAmount,
|
|
174
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
175
|
-
}],
|
|
176
|
-
PayableRoundingAmount: [{
|
|
177
|
-
_: invoice.legalMonetaryTotal.payableRoundingAmount,
|
|
178
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
179
|
-
}],
|
|
180
|
-
PayableAmount: [{
|
|
181
|
-
_: invoice.legalMonetaryTotal.payableAmount,
|
|
182
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
183
|
-
}]
|
|
184
|
-
}],
|
|
185
|
-
InvoiceLine: lineItems.map((item, index) => ({
|
|
186
|
-
ID: [{ _: (index + 1).toString() }],
|
|
187
|
-
...item.quantity !== void 0 || item.measurement !== void 0 ? { InvoicedQuantity: [{
|
|
188
|
-
_: item.quantity ?? 1,
|
|
189
|
-
...item.measurement !== void 0 ? { unitCode: item.measurement } : {}
|
|
190
|
-
}] } : {},
|
|
191
|
-
Item: [{
|
|
192
|
-
CommodityClassification: [{ ItemClassificationCode: [{
|
|
193
|
-
_: item.itemClassificationCode,
|
|
194
|
-
listID: "CLASS"
|
|
195
|
-
}] }],
|
|
196
|
-
Description: [{ _: item.itemDescription }]
|
|
197
|
-
}],
|
|
198
|
-
ItemPriceExtension: [{ Amount: [{
|
|
199
|
-
_: (item.totalTaxableAmountPerLine ?? 0) + (item.discountAmount ?? 0),
|
|
200
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
201
|
-
}] }],
|
|
202
|
-
LineExtensionAmount: [{
|
|
203
|
-
_: item.totalTaxableAmountPerLine,
|
|
204
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
205
|
-
}],
|
|
206
|
-
Price: [{ PriceAmount: [{
|
|
207
|
-
_: item.unitPrice,
|
|
208
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
209
|
-
}] }],
|
|
210
|
-
...item.discountAmount !== void 0 || item.discountRate !== void 0 ? { AllowanceCharge: [{
|
|
211
|
-
ChargeIndicator: [{ _: false }],
|
|
212
|
-
Amount: [{
|
|
213
|
-
_: item.discountAmount ?? 0,
|
|
214
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
215
|
-
}],
|
|
216
|
-
...item.discountRate !== void 0 ? {
|
|
217
|
-
MultiplierFactorNumeric: [{ _: item.discountRate }],
|
|
218
|
-
BaseAmount: [{
|
|
219
|
-
_: (item.totalTaxableAmountPerLine ?? 0) + (item.discountAmount ?? 0),
|
|
220
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
221
|
-
}]
|
|
222
|
-
} : {}
|
|
223
|
-
}] } : {},
|
|
224
|
-
TaxTotal: [{
|
|
225
|
-
TaxAmount: [{
|
|
226
|
-
_: item.taxAmount,
|
|
227
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
228
|
-
}],
|
|
229
|
-
TaxSubtotal: [{
|
|
230
|
-
TaxableAmount: [{
|
|
231
|
-
_: item.totalTaxableAmountPerLine,
|
|
232
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
233
|
-
}],
|
|
234
|
-
TaxAmount: [{
|
|
235
|
-
_: item.taxAmount,
|
|
236
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
237
|
-
}],
|
|
238
|
-
...item.taxPerUnitAmount !== void 0 && item.baseUnitMeasure !== void 0 ? {
|
|
239
|
-
PerUnitAmount: [{
|
|
240
|
-
_: item.taxPerUnitAmount,
|
|
241
|
-
currencyID: invoice.invoiceCurrencyCode
|
|
242
|
-
}],
|
|
243
|
-
BaseUnitMeasure: [{
|
|
244
|
-
_: item.baseUnitMeasure,
|
|
245
|
-
unitCode: item.baseUnitMeasureCode || "C62"
|
|
246
|
-
}]
|
|
247
|
-
} : item.taxRate !== void 0 ? { Percent: [{ _: item.taxRate }] } : {},
|
|
248
|
-
TaxCategory: [{
|
|
249
|
-
ID: [{ _: item.taxType }],
|
|
250
|
-
TaxScheme: [{ ID: [{
|
|
251
|
-
_: "OTH",
|
|
252
|
-
schemeAgencyID: "6",
|
|
253
|
-
schemeID: "UN/ECE 5153"
|
|
254
|
-
}] }]
|
|
255
|
-
}]
|
|
256
|
-
}]
|
|
257
|
-
}]
|
|
258
|
-
})),
|
|
259
|
-
TaxExchangeRate: invoice.currencyExchangeRate ? [{
|
|
260
|
-
SourceCurrencyCode: [{ _: invoice.invoiceCurrencyCode }],
|
|
261
|
-
TargetCurrencyCode: [{ _: "MYR" }],
|
|
262
|
-
CalculationRate: [{ _: invoice.currencyExchangeRate }]
|
|
263
|
-
}] : void 0
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
/**
|
|
267
|
-
* Generates the complete UBL document structure with namespace declarations
|
|
268
|
-
*/
|
|
269
|
-
const generateCleanUBLDocument = (invoices) => {
|
|
270
|
-
return {
|
|
271
|
-
_D: "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",
|
|
272
|
-
_A: "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2",
|
|
273
|
-
_B: "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2",
|
|
274
|
-
Invoice: invoices.map(generateCleanInvoiceObject)
|
|
275
|
-
};
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* Step 1: Transform the document for hashing or transmission
|
|
279
|
-
* Removes UBLExtensions and Signature, and minifies the JSON
|
|
280
|
-
* Returns the minified, cleaned JSON string
|
|
281
|
-
*
|
|
282
|
-
* FIXED: Use regex-based minification to match PowerShell script exactly
|
|
283
|
-
*/
|
|
284
|
-
const transformDocumentForHashing = (invoices) => {
|
|
285
|
-
const cleanDocument = generateCleanUBLDocument(invoices);
|
|
286
|
-
const documentForTransform = JSON.parse(JSON.stringify(cleanDocument));
|
|
287
|
-
if (documentForTransform.Invoice && Array.isArray(documentForTransform.Invoice)) documentForTransform.Invoice.forEach((invoice) => {
|
|
288
|
-
delete invoice.UBLExtensions;
|
|
289
|
-
delete invoice.Signature;
|
|
290
|
-
});
|
|
291
|
-
const jsonString = JSON.stringify(documentForTransform);
|
|
292
|
-
const minifiedJson = jsonString.replace(/("(?:\\.|[^"\\])*")|\s+/g, (match, quotedString) => {
|
|
293
|
-
if (quotedString) return quotedString;
|
|
294
|
-
else return "";
|
|
295
|
-
});
|
|
296
|
-
return minifiedJson;
|
|
297
|
-
};
|
|
298
|
-
/**
|
|
299
|
-
* Step 2: Calculate Document Digest
|
|
300
|
-
* FIXED: Remove UBLExtensions and Signature before hashing (DS322)
|
|
301
|
-
* Based on working implementation pattern
|
|
302
|
-
*/
|
|
303
|
-
const calculateDocumentDigest = (invoices) => {
|
|
304
|
-
const documentString = transformDocumentForHashing(invoices);
|
|
305
|
-
const hash = crypto.createHash("sha256");
|
|
306
|
-
hash.update(documentString, "utf8");
|
|
307
|
-
return hash.digest("base64");
|
|
308
|
-
};
|
|
309
|
-
/**
|
|
310
|
-
* Step 4: Calculate Certificate Digest
|
|
311
|
-
* Enhanced to handle certificate content properly
|
|
312
|
-
* FIXED: Match PowerShell script exactly - use raw certificate data like $cert.RawData
|
|
313
|
-
*/
|
|
314
|
-
const calculateCertificateDigest = (certificatePem) => {
|
|
315
|
-
try {
|
|
316
|
-
const cert = new X509Certificate(certificatePem);
|
|
317
|
-
const rawCertificateData = cert.raw;
|
|
318
|
-
const hash = crypto.createHash("sha256");
|
|
319
|
-
hash.update(rawCertificateData);
|
|
320
|
-
return hash.digest("base64");
|
|
321
|
-
} catch {
|
|
322
|
-
const certificateContent = certificatePem.replace(/-----BEGIN CERTIFICATE-----/g, "").replace(/-----END CERTIFICATE-----/g, "").replace(/\s+/g, "");
|
|
323
|
-
const certificateBinary = Buffer.from(certificateContent, "base64");
|
|
324
|
-
const hash = crypto.createHash("sha256");
|
|
325
|
-
hash.update(certificateBinary);
|
|
326
|
-
return hash.digest("base64");
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
/**
|
|
330
|
-
* Enhanced certificate info extraction with better error handling
|
|
331
|
-
* FIXED: Normalize issuer name format to match MyInvois expectations (DS326)
|
|
332
|
-
*/
|
|
333
|
-
const extractCertificateInfo = (certificatePem) => {
|
|
334
|
-
try {
|
|
335
|
-
const cert = new X509Certificate(certificatePem);
|
|
336
|
-
const serialNumberHex = cert.serialNumber;
|
|
337
|
-
const escapeXmlSpecialChars = (str) => {
|
|
338
|
-
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
339
|
-
};
|
|
340
|
-
const normalizeIssuerName = (issuer) => {
|
|
341
|
-
const parts = issuer.split(/\r?\n|,\s*/).map((part) => part.trim()).filter((part) => part.length > 0).reverse();
|
|
342
|
-
return parts.join(", ").replace(/\s*=\s*/g, "=");
|
|
343
|
-
};
|
|
344
|
-
const formatSerialNumber = (serialHex) => {
|
|
345
|
-
const decimal = BigInt("0x" + serialHex).toString();
|
|
346
|
-
return decimal;
|
|
347
|
-
};
|
|
348
|
-
const rawSubjectName = cert.subject;
|
|
349
|
-
return {
|
|
350
|
-
issuerName: escapeXmlSpecialChars(normalizeIssuerName(cert.issuer)),
|
|
351
|
-
serialNumber: formatSerialNumber(serialNumberHex),
|
|
352
|
-
subjectName: rawSubjectName
|
|
353
|
-
};
|
|
354
|
-
} catch (error) {
|
|
355
|
-
throw new Error(`Failed to extract certificate info: ${error instanceof Error ? error.message : String(error)}`);
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
/**
|
|
359
|
-
* Step 5: Create SignedProperties with enhanced structure
|
|
360
|
-
* FIXED: Simplified structure to match MyInvois expectations (DS320)
|
|
361
|
-
* Following MyInvois JSON signature specification exactly
|
|
362
|
-
*/
|
|
363
|
-
const createSignedProperties = (certificateDigest, signingTime, issuerName, serialNumber) => {
|
|
364
|
-
return { SignedProperties: [{
|
|
365
|
-
Id: "id-xades-signed-props",
|
|
366
|
-
SignedSignatureProperties: [{
|
|
367
|
-
SigningTime: [{ _: signingTime }],
|
|
368
|
-
SigningCertificate: [{ Cert: [{
|
|
369
|
-
CertDigest: [{
|
|
370
|
-
DigestMethod: [{
|
|
371
|
-
_: "",
|
|
372
|
-
Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256"
|
|
373
|
-
}],
|
|
374
|
-
DigestValue: [{ _: certificateDigest }]
|
|
375
|
-
}],
|
|
376
|
-
IssuerSerial: [{
|
|
377
|
-
X509IssuerName: [{ _: issuerName }],
|
|
378
|
-
X509SerialNumber: [{ _: serialNumber }]
|
|
379
|
-
}]
|
|
380
|
-
}] }]
|
|
381
|
-
}]
|
|
382
|
-
}] };
|
|
383
|
-
};
|
|
384
|
-
/**
|
|
385
|
-
* Step 6: Calculate SignedProperties Digest
|
|
386
|
-
* Calculates the digest over the correct structure for validator compliance.
|
|
387
|
-
* FIXED: Calculate digest from SignedProperties only (without Target wrapper)
|
|
388
|
-
*/
|
|
389
|
-
const calculateSignedPropertiesDigest = (signedProperties, useTargetWrapper = true) => {
|
|
390
|
-
let digestObj;
|
|
391
|
-
if (useTargetWrapper) digestObj = {
|
|
392
|
-
Target: "signature",
|
|
393
|
-
SignedProperties: signedProperties.SignedProperties
|
|
394
|
-
};
|
|
395
|
-
else digestObj = signedProperties.SignedProperties;
|
|
396
|
-
const signedPropertiesString = JSON.stringify(digestObj);
|
|
397
|
-
const minifiedSignedProperties = signedPropertiesString.replace(/("(?:\\.|[^"\\])*")|\s+/g, (match, quotedString) => {
|
|
398
|
-
if (quotedString) return quotedString;
|
|
399
|
-
else return "";
|
|
400
|
-
});
|
|
401
|
-
const hash = crypto.createHash("sha256");
|
|
402
|
-
hash.update(minifiedSignedProperties, "utf8");
|
|
403
|
-
return hash.digest("base64");
|
|
404
|
-
};
|
|
405
|
-
/**
|
|
406
|
-
* Step 3: Create SignedInfo and calculate signature
|
|
407
|
-
* Enhanced with better structure and signature generation
|
|
408
|
-
*/
|
|
409
|
-
const createSignedInfoAndSign = (docDigest, propsDigest, privateKeyPem) => {
|
|
410
|
-
const signedInfo = {
|
|
411
|
-
CanonicalizationMethod: [{
|
|
412
|
-
_: "",
|
|
413
|
-
Algorithm: "http://www.w3.org/2006/12/xml-c14n11"
|
|
414
|
-
}],
|
|
415
|
-
SignatureMethod: [{
|
|
416
|
-
_: "",
|
|
417
|
-
Algorithm: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
|
|
418
|
-
}],
|
|
419
|
-
Reference: [{
|
|
420
|
-
Id: "id-doc-signed-data",
|
|
421
|
-
Type: "",
|
|
422
|
-
URI: "",
|
|
423
|
-
DigestMethod: [{
|
|
424
|
-
_: "",
|
|
425
|
-
Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256"
|
|
426
|
-
}],
|
|
427
|
-
DigestValue: [{ _: docDigest }]
|
|
428
|
-
}, {
|
|
429
|
-
Id: "id-xades-signed-props",
|
|
430
|
-
Type: "http://uri.etsi.org/01903/v1.3.2#SignedProperties",
|
|
431
|
-
URI: "#id-xades-signed-props",
|
|
432
|
-
DigestMethod: [{
|
|
433
|
-
_: "",
|
|
434
|
-
Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256"
|
|
435
|
-
}],
|
|
436
|
-
DigestValue: [{ _: propsDigest }]
|
|
437
|
-
}]
|
|
438
|
-
};
|
|
439
|
-
const signedInfoRaw = JSON.stringify(signedInfo);
|
|
440
|
-
try {
|
|
441
|
-
const signer = crypto.createSign("RSA-SHA256");
|
|
442
|
-
signer.update(signedInfoRaw, "utf8");
|
|
443
|
-
const signatureValue = signer.sign(privateKeyPem, "base64");
|
|
444
|
-
return {
|
|
445
|
-
signedInfo,
|
|
446
|
-
signatureValue
|
|
447
|
-
};
|
|
448
|
-
} catch (error) {
|
|
449
|
-
throw new Error(`Signature generation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
/**
|
|
453
|
-
* Signs the minified document string using the provided private key PEM
|
|
454
|
-
* Returns the signature as a base64 string
|
|
455
|
-
* FIXED: Match PowerShell script exactly - first compute hash, then sign the hash
|
|
456
|
-
*/
|
|
457
|
-
const signDocumentString = (documentString, privateKeyPem) => {
|
|
458
|
-
const signer = crypto.createSign("RSA-SHA256");
|
|
459
|
-
signer.update(documentString, "utf8");
|
|
460
|
-
return signer.sign(privateKeyPem, "base64");
|
|
461
|
-
};
|
|
462
|
-
/**
|
|
463
|
-
* Complete document generation with signatures
|
|
464
|
-
* Follows the complete MyInvois JSON signature creation process (Steps 1-7)
|
|
465
|
-
*/
|
|
466
|
-
const generateCompleteDocument = (invoices, signingCredentials) => {
|
|
467
|
-
try {
|
|
468
|
-
const docDigest = calculateDocumentDigest(invoices);
|
|
469
|
-
const documentString = transformDocumentForHashing(invoices);
|
|
470
|
-
const docSignature = signDocumentString(documentString, signingCredentials.privateKeyPem);
|
|
471
|
-
const now = /* @__PURE__ */ new Date();
|
|
472
|
-
const signingTime = now.getFullYear() + "-" + String(now.getMonth() + 1).padStart(2, "0") + "-" + String(now.getDate()).padStart(2, "0") + "T" + String(now.getHours()).padStart(2, "0") + ":" + String(now.getMinutes()).padStart(2, "0") + ":" + String(now.getSeconds()).padStart(2, "0") + "Z";
|
|
473
|
-
const certInfo = extractCertificateInfo(signingCredentials.certificatePem);
|
|
474
|
-
const certificateDigest = calculateCertificateDigest(signingCredentials.certificatePem);
|
|
475
|
-
const signedProperties = createSignedProperties(certificateDigest, signingTime, certInfo.issuerName, certInfo.serialNumber);
|
|
476
|
-
const propsDigest = calculateSignedPropertiesDigest(signedProperties);
|
|
477
|
-
const signedInfo = {
|
|
478
|
-
CanonicalizationMethod: [{
|
|
479
|
-
_: "",
|
|
480
|
-
Algorithm: "http://www.w3.org/2006/12/xml-c14n11"
|
|
481
|
-
}],
|
|
482
|
-
SignatureMethod: [{
|
|
483
|
-
_: "",
|
|
484
|
-
Algorithm: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
|
|
485
|
-
}],
|
|
486
|
-
Reference: [{
|
|
487
|
-
Id: "id-doc-signed-data",
|
|
488
|
-
Type: "",
|
|
489
|
-
URI: "",
|
|
490
|
-
DigestMethod: [{
|
|
491
|
-
_: "",
|
|
492
|
-
Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256"
|
|
493
|
-
}],
|
|
494
|
-
DigestValue: [{ _: docDigest }]
|
|
495
|
-
}, {
|
|
496
|
-
Id: "id-xades-signed-props",
|
|
497
|
-
Type: "http://uri.etsi.org/01903/v1.3.2#SignedProperties",
|
|
498
|
-
URI: "#id-xades-signed-props",
|
|
499
|
-
DigestMethod: [{
|
|
500
|
-
_: "",
|
|
501
|
-
Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256"
|
|
502
|
-
}],
|
|
503
|
-
DigestValue: [{ _: propsDigest }]
|
|
504
|
-
}]
|
|
505
|
-
};
|
|
506
|
-
const cert = new X509Certificate(signingCredentials.certificatePem);
|
|
507
|
-
const certificate = cert.raw.toString("base64");
|
|
508
|
-
const signedInvoices = invoices.map((invoice) => {
|
|
509
|
-
const cleanInvoice = generateCleanInvoiceObject(invoice);
|
|
510
|
-
return {
|
|
511
|
-
...cleanInvoice,
|
|
512
|
-
UBLExtensions: [{ UBLExtension: [{
|
|
513
|
-
ExtensionURI: [{ _: "urn:oasis:names:specification:ubl:dsig:enveloped:xades" }],
|
|
514
|
-
ExtensionContent: [{ UBLDocumentSignatures: [{ SignatureInformation: [{
|
|
515
|
-
ID: [{ _: "urn:oasis:names:specification:ubl:signature:1" }],
|
|
516
|
-
ReferencedSignatureID: [{ _: "urn:oasis:names:specification:ubl:signature:Invoice" }],
|
|
517
|
-
Signature: [{
|
|
518
|
-
Id: "signature",
|
|
519
|
-
Object: [{ QualifyingProperties: [{
|
|
520
|
-
Target: "signature",
|
|
521
|
-
SignedProperties: signedProperties.SignedProperties
|
|
522
|
-
}] }],
|
|
523
|
-
KeyInfo: [{ X509Data: [{
|
|
524
|
-
X509Certificate: [{ _: certificate }],
|
|
525
|
-
X509SubjectName: [{ _: certInfo.subjectName }],
|
|
526
|
-
X509IssuerSerial: [{
|
|
527
|
-
X509IssuerName: [{ _: certInfo.issuerName }],
|
|
528
|
-
X509SerialNumber: [{ _: certInfo.serialNumber }]
|
|
529
|
-
}]
|
|
530
|
-
}] }],
|
|
531
|
-
SignatureValue: [{ _: docSignature }],
|
|
532
|
-
SignedInfo: [signedInfo]
|
|
533
|
-
}]
|
|
534
|
-
}] }] }]
|
|
535
|
-
}] }],
|
|
536
|
-
Signature: [{
|
|
537
|
-
ID: [{ _: "urn:oasis:names:specification:ubl:signature:Invoice" }],
|
|
538
|
-
SignatureMethod: [{ _: "urn:oasis:names:specification:ubl:dsig:enveloped:xades" }]
|
|
539
|
-
}]
|
|
540
|
-
};
|
|
541
|
-
});
|
|
542
|
-
return {
|
|
543
|
-
_D: "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",
|
|
544
|
-
_A: "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2",
|
|
545
|
-
_B: "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2",
|
|
546
|
-
Invoice: signedInvoices
|
|
547
|
-
};
|
|
548
|
-
} catch (error) {
|
|
549
|
-
throw new Error(`Document generation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
|
-
/**
|
|
553
|
-
* Creates a line item with percentage-based taxation (e.g., SST, GST)
|
|
554
|
-
*/
|
|
555
|
-
const createPercentageTaxLineItem = (params) => {
|
|
556
|
-
const quantity = params.quantity ? params.quantity <= 0 ? 1 : params.quantity ?? 1 : 1;
|
|
557
|
-
const preDiscountAmount = params.unitPrice * quantity;
|
|
558
|
-
const hasDiscount = params.discountAmount !== void 0 || params.discountRate !== void 0;
|
|
559
|
-
const computedDiscountByRate = hasDiscount && params.discountRate !== void 0 ? preDiscountAmount * params.discountRate : 0;
|
|
560
|
-
const discountAmount = hasDiscount && params.discountAmount !== void 0 ? params.discountAmount : computedDiscountByRate;
|
|
561
|
-
const totalTaxableAmount = Math.max(0, preDiscountAmount - (hasDiscount ? discountAmount : 0));
|
|
562
|
-
const taxAmount = totalTaxableAmount * params.taxRate / 100;
|
|
563
|
-
return {
|
|
564
|
-
itemClassificationCode: params.itemClassificationCode,
|
|
565
|
-
itemDescription: params.itemDescription,
|
|
566
|
-
unitPrice: params.unitPrice,
|
|
567
|
-
taxType: params.taxType,
|
|
568
|
-
taxRate: params.taxRate,
|
|
569
|
-
...params.quantity !== void 0 ? { quantity: params.quantity } : {},
|
|
570
|
-
...params.measurement !== void 0 ? { measurement: params.measurement } : {},
|
|
571
|
-
...hasDiscount && discountAmount !== void 0 ? { discountAmount } : {},
|
|
572
|
-
...hasDiscount && params.discountRate !== void 0 ? { discountRate: params.discountRate } : {},
|
|
573
|
-
taxAmount: Math.round(taxAmount * 100) / 100,
|
|
574
|
-
totalTaxableAmountPerLine: totalTaxableAmount,
|
|
575
|
-
totalAmountPerLine: totalTaxableAmount + taxAmount
|
|
576
|
-
};
|
|
577
|
-
};
|
|
578
|
-
/**
|
|
579
|
-
* Creates a line item with fixed rate taxation (e.g., Tourism Tax)
|
|
580
|
-
*/
|
|
581
|
-
const createFixedRateTaxLineItem = (params) => {
|
|
582
|
-
const quantity = params.quantity || 1;
|
|
583
|
-
const preDiscountAmount = params.unitPrice * quantity;
|
|
584
|
-
const hasDiscount = params.discountAmount !== void 0 || params.discountRate !== void 0;
|
|
585
|
-
const computedDiscountByRate = hasDiscount && params.discountRate !== void 0 ? preDiscountAmount * params.discountRate : 0;
|
|
586
|
-
const discountAmount = hasDiscount && params.discountAmount !== void 0 ? params.discountAmount : computedDiscountByRate;
|
|
587
|
-
const totalTaxableAmount = Math.max(0, preDiscountAmount - (hasDiscount ? discountAmount : 0));
|
|
588
|
-
const taxAmount = params.taxPerUnitAmount * params.baseUnitMeasure;
|
|
589
|
-
return {
|
|
590
|
-
itemClassificationCode: params.itemClassificationCode,
|
|
591
|
-
itemDescription: params.itemDescription,
|
|
592
|
-
unitPrice: params.unitPrice,
|
|
593
|
-
taxType: params.taxType,
|
|
594
|
-
taxPerUnitAmount: params.taxPerUnitAmount,
|
|
595
|
-
baseUnitMeasure: params.baseUnitMeasure,
|
|
596
|
-
baseUnitMeasureCode: params.baseUnitMeasureCode,
|
|
597
|
-
...params.quantity !== void 0 ? { quantity: params.quantity } : {},
|
|
598
|
-
...params.measurement !== void 0 ? { measurement: params.measurement } : {},
|
|
599
|
-
...hasDiscount && discountAmount !== void 0 ? { discountAmount } : {},
|
|
600
|
-
...hasDiscount && params.discountRate !== void 0 ? { discountRate: params.discountRate } : {},
|
|
601
|
-
taxAmount: Math.round(taxAmount * 100) / 100,
|
|
602
|
-
totalTaxableAmountPerLine: totalTaxableAmount,
|
|
603
|
-
totalAmountPerLine: totalTaxableAmount + taxAmount
|
|
604
|
-
};
|
|
605
|
-
};
|
|
606
|
-
/**
|
|
607
|
-
* Calculates invoice totals from line items
|
|
608
|
-
*/
|
|
609
|
-
const calculateInvoiceTotals = (lineItems, payableRoundingAmount = 0) => {
|
|
610
|
-
const taxExclusiveAmount = lineItems.reduce((sum, item) => sum + item.totalTaxableAmountPerLine, 0);
|
|
611
|
-
const totalTaxAmount = lineItems.reduce((sum, item) => sum + item.taxAmount, 0);
|
|
612
|
-
const taxInclusiveAmount = taxExclusiveAmount + totalTaxAmount;
|
|
613
|
-
const payableAmount = taxInclusiveAmount + payableRoundingAmount;
|
|
614
|
-
return {
|
|
615
|
-
legalMonetaryTotal: {
|
|
616
|
-
taxExclusiveAmount: Math.round(taxExclusiveAmount * 100) / 100,
|
|
617
|
-
taxInclusiveAmount: Math.round(taxInclusiveAmount * 100) / 100,
|
|
618
|
-
payableRoundingAmount: Math.round(payableRoundingAmount * 100) / 100,
|
|
619
|
-
payableAmount: Math.round(payableAmount * 100) / 100
|
|
620
|
-
},
|
|
621
|
-
taxTotal: { taxAmount: Math.round(totalTaxAmount * 100) / 100 }
|
|
622
|
-
};
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
//#endregion
|
|
626
|
-
export { calculateCertificateDigest, calculateDocumentDigest, calculateExpectedTaxAmount, calculateInvoiceTotals, calculateSignedPropertiesDigest, canonicalizeJSON, createFixedRateTaxLineItem, createPercentageTaxLineItem, createSignedInfoAndSign, createSignedProperties, extractCertificateInfo, generateCleanInvoiceObject, generateCleanUBLDocument, generateCompleteDocument, isFixedRateTax, isPercentageTax, signDocumentString, sortObjectKeys, transformDocumentForHashing };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"documentManagement-BviJDtf2.cjs","names":["context: DocumentContext","documentUid: string","params: {\n uuid?: string\n submissionDateFrom: string\n submissionDateTo?: string\n pageSize?: number\n pageNo?: number\n issueDateFrom?: string\n issueDateTo?: string\n invoiceDirection?: 'Sent' | 'Received'\n status?: DocumentStatus\n documentType?: EInvoiceTypeCode\n searchQuery?: string\n }","doc: DocumentSummary & { longID: string }"],"sources":["../src/api/documentManagement.ts"],"sourcesContent":["import type {\n DocumentSummary,\n DocumentStatus,\n EInvoiceTypeCode,\n DocumentValidationResult,\n DocumentValidationStepResult,\n Fetch,\n} from '../types'\n\ninterface DocumentContext {\n fetch: Fetch\n}\n\nconst rawLogs = process.env.E_INV_RAW_LOGS === 'true'\n\nexport async function getDocument(\n context: DocumentContext,\n documentUid: string,\n): Promise<DocumentSummary & { document: string }> {\n const { fetch } = context\n\n const response = await fetch(`/api/v1.0/documents/${documentUid}/raw`)\n const data = await response.json()\n\n if (rawLogs) {\n console.log('Raw document:', data)\n }\n\n return { ...data, longId: data.longID ?? data.longId } as DocumentSummary & {\n document: string\n }\n}\n\nexport async function getDocumentDetails(\n context: DocumentContext,\n documentUid: string,\n): Promise<\n DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n> {\n const { fetch } = context\n\n const response = await fetch(`/api/v1.0/documents/${documentUid}/details`)\n const data = await response.json()\n const resp = {\n ...data,\n longId: data.longID ?? data.longId,\n } as DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n\n if (rawLogs) {\n console.log('Raw document details:', resp)\n }\n\n return resp\n}\n\nexport async function searchDocuments(\n context: DocumentContext,\n params: {\n uuid?: string\n submissionDateFrom: string\n submissionDateTo?: string\n pageSize?: number\n pageNo?: number\n issueDateFrom?: string\n issueDateTo?: string\n invoiceDirection?: 'Sent' | 'Received'\n status?: DocumentStatus\n documentType?: EInvoiceTypeCode\n searchQuery?: string\n },\n): Promise<DocumentSummary[]> {\n const { fetch } = context\n const {\n uuid,\n submissionDateFrom,\n submissionDateTo,\n pageSize,\n pageNo,\n issueDateFrom,\n issueDateTo,\n invoiceDirection,\n status,\n documentType,\n searchQuery,\n } = params\n\n const queryParams = new URLSearchParams()\n\n if (uuid) queryParams.set('uuid', uuid)\n if (submissionDateFrom)\n queryParams.set('submissionDateFrom', submissionDateFrom)\n if (submissionDateTo) queryParams.set('submissionDateTo', submissionDateTo)\n if (pageSize) queryParams.set('pageSize', pageSize.toString())\n if (pageNo) queryParams.set('pageNo', pageNo.toString())\n if (issueDateFrom) queryParams.set('issueDateFrom', issueDateFrom)\n if (issueDateTo) queryParams.set('issueDateTo', issueDateTo)\n if (invoiceDirection) queryParams.set('invoiceDirection', invoiceDirection)\n if (status) queryParams.set('status', status)\n if (documentType) queryParams.set('documentType', documentType)\n if (searchQuery) queryParams.set('searchQuery', searchQuery)\n\n const response = await fetch(\n `/api/v1.0/documents/search?${queryParams.toString()}`,\n )\n\n const data = await response.json()\n\n if (rawLogs) {\n console.log('Raw search documents:', data)\n }\n\n return data.map((doc: DocumentSummary & { longID: string }) => ({\n ...doc,\n longId: doc.longID ?? doc.longId,\n })) as DocumentSummary[]\n}\n"],"mappings":";;AAaA,MAAM,UAAU,QAAQ,IAAI,mBAAmB;AAE/C,eAAsB,YACpBA,SACAC,aACiD;CACjD,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,WAAW,MAAM,OAAO,sBAAsB,YAAY,MAAM;CACtE,MAAM,OAAO,MAAM,SAAS,MAAM;AAElC,KAAI,QACF,SAAQ,IAAI,iBAAiB,KAAK;AAGpC,QAAO;EAAE,GAAG;EAAM,QAAQ,KAAK,UAAU,KAAK;CAAQ;AAGvD;AAED,eAAsB,mBACpBD,SACAC,aAQA;CACA,MAAM,EAAE,OAAO,GAAG;CAElB,MAAM,WAAW,MAAM,OAAO,sBAAsB,YAAY,UAAU;CAC1E,MAAM,OAAO,MAAM,SAAS,MAAM;CAClC,MAAM,OAAO;EACX,GAAG;EACH,QAAQ,KAAK,UAAU,KAAK;CAC7B;AAOD,KAAI,QACF,SAAQ,IAAI,yBAAyB,KAAK;AAG5C,QAAO;AACR;AAED,eAAsB,gBACpBD,SACAE,QAa4B;CAC5B,MAAM,EAAE,OAAO,GAAG;CAClB,MAAM,EACJ,MACA,oBACA,kBACA,UACA,QACA,eACA,aACA,kBACA,QACA,cACA,aACD,GAAG;CAEJ,MAAM,cAAc,IAAI;AAExB,KAAI,KAAM,aAAY,IAAI,QAAQ,KAAK;AACvC,KAAI,mBACF,aAAY,IAAI,sBAAsB,mBAAmB;AAC3D,KAAI,iBAAkB,aAAY,IAAI,oBAAoB,iBAAiB;AAC3E,KAAI,SAAU,aAAY,IAAI,YAAY,SAAS,UAAU,CAAC;AAC9D,KAAI,OAAQ,aAAY,IAAI,UAAU,OAAO,UAAU,CAAC;AACxD,KAAI,cAAe,aAAY,IAAI,iBAAiB,cAAc;AAClE,KAAI,YAAa,aAAY,IAAI,eAAe,YAAY;AAC5D,KAAI,iBAAkB,aAAY,IAAI,oBAAoB,iBAAiB;AAC3E,KAAI,OAAQ,aAAY,IAAI,UAAU,OAAO;AAC7C,KAAI,aAAc,aAAY,IAAI,gBAAgB,aAAa;AAC/D,KAAI,YAAa,aAAY,IAAI,eAAe,YAAY;CAE5D,MAAM,WAAW,MAAM,OACpB,6BAA6B,YAAY,UAAU,CAAC,EACtD;CAED,MAAM,OAAO,MAAM,SAAS,MAAM;AAElC,KAAI,QACF,SAAQ,IAAI,yBAAyB,KAAK;AAG5C,QAAO,KAAK,IAAI,CAACC,SAA+C;EAC9D,GAAG;EACH,QAAQ,IAAI,UAAU,IAAI;CAC3B,GAAE;AACJ"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
//#region src/api/documentManagement.ts
|
|
2
|
-
const rawLogs = process.env.E_INV_RAW_LOGS === "true";
|
|
3
|
-
async function getDocument(context, documentUid) {
|
|
4
|
-
const { fetch } = context;
|
|
5
|
-
const response = await fetch(`/api/v1.0/documents/${documentUid}/raw`);
|
|
6
|
-
const data = await response.json();
|
|
7
|
-
if (rawLogs) console.log("Raw document:", data);
|
|
8
|
-
return {
|
|
9
|
-
...data,
|
|
10
|
-
longId: data.longID ?? data.longId
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
async function getDocumentDetails(context, documentUid) {
|
|
14
|
-
const { fetch } = context;
|
|
15
|
-
const response = await fetch(`/api/v1.0/documents/${documentUid}/details`);
|
|
16
|
-
const data = await response.json();
|
|
17
|
-
const resp = {
|
|
18
|
-
...data,
|
|
19
|
-
longId: data.longID ?? data.longId
|
|
20
|
-
};
|
|
21
|
-
if (rawLogs) console.log("Raw document details:", resp);
|
|
22
|
-
return resp;
|
|
23
|
-
}
|
|
24
|
-
async function searchDocuments(context, params) {
|
|
25
|
-
const { fetch } = context;
|
|
26
|
-
const { uuid, submissionDateFrom, submissionDateTo, pageSize, pageNo, issueDateFrom, issueDateTo, invoiceDirection, status, documentType, searchQuery } = params;
|
|
27
|
-
const queryParams = new URLSearchParams();
|
|
28
|
-
if (uuid) queryParams.set("uuid", uuid);
|
|
29
|
-
if (submissionDateFrom) queryParams.set("submissionDateFrom", submissionDateFrom);
|
|
30
|
-
if (submissionDateTo) queryParams.set("submissionDateTo", submissionDateTo);
|
|
31
|
-
if (pageSize) queryParams.set("pageSize", pageSize.toString());
|
|
32
|
-
if (pageNo) queryParams.set("pageNo", pageNo.toString());
|
|
33
|
-
if (issueDateFrom) queryParams.set("issueDateFrom", issueDateFrom);
|
|
34
|
-
if (issueDateTo) queryParams.set("issueDateTo", issueDateTo);
|
|
35
|
-
if (invoiceDirection) queryParams.set("invoiceDirection", invoiceDirection);
|
|
36
|
-
if (status) queryParams.set("status", status);
|
|
37
|
-
if (documentType) queryParams.set("documentType", documentType);
|
|
38
|
-
if (searchQuery) queryParams.set("searchQuery", searchQuery);
|
|
39
|
-
const response = await fetch(`/api/v1.0/documents/search?${queryParams.toString()}`);
|
|
40
|
-
const data = await response.json();
|
|
41
|
-
if (rawLogs) console.log("Raw search documents:", data);
|
|
42
|
-
return data.map((doc) => ({
|
|
43
|
-
...doc,
|
|
44
|
-
longId: doc.longID ?? doc.longId
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
export { getDocument, getDocumentDetails, searchDocuments };
|