@provis/provis-common-be-module 2.6.95 → 3.0.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.
@@ -103,4 +103,33 @@ declare const specificCoa: {
103
103
  };
104
104
  };
105
105
  };
106
- export { generalCoa, specificCoa, coaStatus, invoiceCoaType, coaType, };
106
+ declare const coaEvent: {
107
+ INITIAL: string;
108
+ PAID: string;
109
+ INSURANCE_PAYMENT: string;
110
+ CANCEL: string;
111
+ CANCEL_PAID: string;
112
+ CANCEL_INSURANCE_PAYMENT: string;
113
+ };
114
+ declare const coaRefStatus: {
115
+ INITIAL: string;
116
+ PAID: string;
117
+ INSURANCE_PAYMENT: string;
118
+ CANCEL: string;
119
+ CANCEL_PAID: string;
120
+ CANCEL_INSURANCE_PAYMENT: string;
121
+ };
122
+ declare const coaRefStatusToEvent: {
123
+ [refStatus: string]: string;
124
+ };
125
+ declare const coaErrorCode: {
126
+ MAPPING_NOT_FOUND: string;
127
+ SOURCE_JOURNAL_NOT_READY: string;
128
+ MANUAL_POSTING_REQUIRED: string;
129
+ METADATA_INVALID: string;
130
+ UNBALANCED_JOURNAL: string;
131
+ AMOUNT_MISMATCH: string;
132
+ UNSUPPORTED_EVENT: string;
133
+ EMPTY_JOURNAL: string;
134
+ };
135
+ export { generalCoa, specificCoa, coaStatus, invoiceCoaType, coaType, coaEvent, coaRefStatus, coaRefStatusToEvent, coaErrorCode, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.coaType = exports.invoiceCoaType = exports.coaStatus = exports.specificCoa = exports.generalCoa = void 0;
3
+ exports.coaErrorCode = exports.coaRefStatusToEvent = exports.coaRefStatus = exports.coaEvent = exports.coaType = exports.invoiceCoaType = exports.coaStatus = exports.specificCoa = exports.generalCoa = void 0;
4
4
  const invoiceCoaType = {
5
5
  INVOICE: 'INVOICE',
6
6
  CREDIT_NOTE: 'CREDIT_NOTE',
@@ -112,3 +112,47 @@ const specificCoa = {
112
112
  },
113
113
  };
114
114
  exports.specificCoa = specificCoa;
115
+ // jenis jurnal COA, mengikuti blok di Contoh_Jurnal_Provis.xlsx
116
+ const coaEvent = {
117
+ INITIAL: 'INITIAL',
118
+ PAID: 'PAID',
119
+ INSURANCE_PAYMENT: 'INSURANCE_PAYMENT',
120
+ CANCEL: 'CANCEL',
121
+ CANCEL_PAID: 'CANCEL_PAID',
122
+ CANCEL_INSURANCE_PAYMENT: 'CANCEL_INSURANCE_PAYMENT', // net off, diproses manual
123
+ };
124
+ exports.coaEvent = coaEvent;
125
+ // refStatus yang dikirim ke COA API. 0/100/300 ikut status invoice, sisanya khusus COA:
126
+ // 150 / 310 / 350 cuma penanda jenis jurnal di payload, TIDAK disimpan sebagai status invoice,
127
+ // jadi tabel/alur invoice tidak perlu diubah.
128
+ // 110 JANGAN dipakai, itu invoiceStatusCode.INSTALLMENT
129
+ const coaRefStatus = {
130
+ INITIAL: '0',
131
+ PAID: '100',
132
+ INSURANCE_PAYMENT: '150',
133
+ CANCEL: '300',
134
+ CANCEL_PAID: '310',
135
+ CANCEL_INSURANCE_PAYMENT: '350',
136
+ };
137
+ exports.coaRefStatus = coaRefStatus;
138
+ const coaRefStatusToEvent = {
139
+ [coaRefStatus.INITIAL]: coaEvent.INITIAL,
140
+ [coaRefStatus.PAID]: coaEvent.PAID,
141
+ [coaRefStatus.INSURANCE_PAYMENT]: coaEvent.INSURANCE_PAYMENT,
142
+ [coaRefStatus.CANCEL]: coaEvent.CANCEL,
143
+ [coaRefStatus.CANCEL_PAID]: coaEvent.CANCEL_PAID,
144
+ [coaRefStatus.CANCEL_INSURANCE_PAYMENT]: coaEvent.CANCEL_INSURANCE_PAYMENT,
145
+ };
146
+ exports.coaRefStatusToEvent = coaRefStatusToEvent;
147
+ // kode error jurnal, disimpan di invoiceCoa.message biar penyebab gagalnya bisa dicari
148
+ const coaErrorCode = {
149
+ MAPPING_NOT_FOUND: 'COA_MAPPING_NOT_FOUND',
150
+ SOURCE_JOURNAL_NOT_READY: 'COA_SOURCE_JOURNAL_NOT_READY',
151
+ MANUAL_POSTING_REQUIRED: 'COA_MANUAL_POSTING_REQUIRED',
152
+ METADATA_INVALID: 'COA_METADATA_INVALID',
153
+ UNBALANCED_JOURNAL: 'COA_UNBALANCED_JOURNAL',
154
+ AMOUNT_MISMATCH: 'COA_AMOUNT_MISMATCH',
155
+ UNSUPPORTED_EVENT: 'COA_UNSUPPORTED_EVENT',
156
+ EMPTY_JOURNAL: 'COA_EMPTY_JOURNAL',
157
+ };
158
+ exports.coaErrorCode = coaErrorCode;
@@ -3,6 +3,6 @@ declare const reconStatus: {
3
3
  GENERATED: string;
4
4
  EXPORTED: string;
5
5
  DELIVERED: string;
6
- LIST_STATUS: any[];
6
+ LIST_STATUS: string[];
7
7
  };
8
8
  export default reconStatus;
@@ -1,46 +1,17 @@
1
- declare const report: {
2
- INITIAL: {
3
- code: number;
4
- desc: {
5
- en: string;
6
- id: string;
7
- };
8
- };
9
- SUCCESS: {
10
- code: number;
11
- desc: {
12
- en: string;
13
- id: string;
14
- };
15
- };
16
- SUBMIT: {
17
- code: number;
18
- desc: {
19
- en: string;
20
- id: string;
21
- };
22
- };
23
- CANCEL: {
24
- code: number;
25
- desc: {
26
- en: string;
27
- id: string;
28
- };
1
+ type ReportStatus = {
2
+ code: number;
3
+ desc: {
4
+ en: string;
5
+ id: string;
29
6
  };
30
- FAILED: {
31
- code: number;
32
- desc: {
33
- en: string;
34
- id: string;
35
- };
36
- };
37
- LIST_ACTIVE: any[];
38
- LIST_ALL: {
39
- code: number;
40
- desc: {
41
- en: string;
42
- id: string;
43
- };
44
- }[];
7
+ };
8
+ declare const report: {
9
+ INITIAL: ReportStatus;
10
+ SUCCESS: ReportStatus;
11
+ SUBMIT: ReportStatus;
12
+ CANCEL: ReportStatus;
13
+ FAILED: ReportStatus;
14
+ LIST_ACTIVE: ReportStatus[];
15
+ LIST_ALL: ReportStatus[];
45
16
  };
46
17
  export default report;
@@ -0,0 +1,11 @@
1
+ export declare const AMOUNT_SCALE = 4;
2
+ export declare function toUnits(value: string | number | null | undefined): number;
3
+ export declare function fromUnits(units: number): string;
4
+ export declare function sumUnits(...values: number[]): number;
5
+ declare const _default: {
6
+ AMOUNT_SCALE: number;
7
+ toUnits: typeof toUnits;
8
+ fromUnits: typeof fromUnits;
9
+ sumUnits: typeof sumUnits;
10
+ };
11
+ export default _default;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sumUnits = exports.fromUnits = exports.toUnits = exports.AMOUNT_SCALE = void 0;
4
+ // Untuk nilai uang yang dipakai ledger (kolom decimal(16,4)): semua hitungan dilakukan
5
+ // dalam integer (nilai * 10^4) biar debit dan kredit tidak pernah beda gara-gara float.
6
+ // Konversi ke string cuma sekali, waktu mau disimpan.
7
+ exports.AMOUNT_SCALE = 4;
8
+ const FACTOR = 10 ** exports.AMOUNT_SCALE;
9
+ function toUnits(value) {
10
+ if (value === null || value === undefined || value === '')
11
+ return 0;
12
+ const numberValue = Number(value);
13
+ if (!Number.isFinite(numberValue)) {
14
+ throw new Error(`Amount "${value}" is not a valid number`);
15
+ }
16
+ const units = Math.round(numberValue * FACTOR);
17
+ if (!Number.isSafeInteger(units)) {
18
+ throw new Error(`Amount "${value}" is out of safe range for decimal(16,4)`);
19
+ }
20
+ return units;
21
+ }
22
+ exports.toUnits = toUnits;
23
+ function fromUnits(units) {
24
+ return (units / FACTOR).toFixed(exports.AMOUNT_SCALE);
25
+ }
26
+ exports.fromUnits = fromUnits;
27
+ function sumUnits(...values) {
28
+ return values.reduce((total, value) => total + value, 0);
29
+ }
30
+ exports.sumUnits = sumUnits;
31
+ exports.default = {
32
+ AMOUNT_SCALE: exports.AMOUNT_SCALE,
33
+ toUnits,
34
+ fromUnits,
35
+ sumUnits,
36
+ };
@@ -28,4 +28,5 @@ import findObjectByParams from "./findObjectByParams";
28
28
  import alphaNumericCleansing from "./alphaNumericCleansing";
29
29
  import coretaxDppCalculate from "./coretaxDppCalculate";
30
30
  import getEmailContent, { initEmailTemplates } from "./getEmailContent";
31
- export { addDateTime, amountDescription, axiosGet, axiosPost, axiosPut, compareDiffObj, convertCurrencySymbol, convertDateTimeFormat, convertObjToNumber, convertToCurrency, filterObj, generateRelationId, getCurrentDate, getDiffValue, getObjByKeys, loop, loopBackward, searchValue, readExcel, generateHashString, mergeObj, combineObj, calculateByType, getCargoType, getHeaderUser, setHeaderUser, alphaNumericCleansing, findObjectByParams, coretaxDppCalculate, getEmailContent, initEmailTemplates, };
31
+ import { AMOUNT_SCALE, toUnits, fromUnits, sumUnits } from "./decimalAmount";
32
+ export { addDateTime, amountDescription, axiosGet, axiosPost, axiosPut, compareDiffObj, convertCurrencySymbol, convertDateTimeFormat, convertObjToNumber, convertToCurrency, filterObj, generateRelationId, getCurrentDate, getDiffValue, getObjByKeys, loop, loopBackward, searchValue, readExcel, generateHashString, mergeObj, combineObj, calculateByType, getCargoType, getHeaderUser, setHeaderUser, alphaNumericCleansing, findObjectByParams, coretaxDppCalculate, getEmailContent, initEmailTemplates, AMOUNT_SCALE, toUnits, fromUnits, sumUnits, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initEmailTemplates = exports.getEmailContent = exports.coretaxDppCalculate = exports.findObjectByParams = exports.alphaNumericCleansing = exports.setHeaderUser = exports.getHeaderUser = exports.getCargoType = exports.calculateByType = exports.combineObj = exports.mergeObj = exports.generateHashString = exports.readExcel = exports.searchValue = exports.loopBackward = exports.loop = exports.getObjByKeys = exports.getDiffValue = exports.getCurrentDate = exports.generateRelationId = exports.filterObj = exports.convertToCurrency = exports.convertObjToNumber = exports.convertDateTimeFormat = exports.convertCurrencySymbol = exports.compareDiffObj = exports.axiosPut = exports.axiosPost = exports.axiosGet = exports.amountDescription = exports.addDateTime = void 0;
3
+ exports.sumUnits = exports.fromUnits = exports.toUnits = exports.AMOUNT_SCALE = exports.initEmailTemplates = exports.getEmailContent = exports.coretaxDppCalculate = exports.findObjectByParams = exports.alphaNumericCleansing = exports.setHeaderUser = exports.getHeaderUser = exports.getCargoType = exports.calculateByType = exports.combineObj = exports.mergeObj = exports.generateHashString = exports.readExcel = exports.searchValue = exports.loopBackward = exports.loop = exports.getObjByKeys = exports.getDiffValue = exports.getCurrentDate = exports.generateRelationId = exports.filterObj = exports.convertToCurrency = exports.convertObjToNumber = exports.convertDateTimeFormat = exports.convertCurrencySymbol = exports.compareDiffObj = exports.axiosPut = exports.axiosPost = exports.axiosGet = exports.amountDescription = exports.addDateTime = void 0;
4
4
  const addDateTime_1 = require("./addDateTime");
5
5
  exports.addDateTime = addDateTime_1.default;
6
6
  const amountDescription_1 = require("./amountDescription");
@@ -62,3 +62,8 @@ exports.coretaxDppCalculate = coretaxDppCalculate_1.default;
62
62
  const getEmailContent_1 = require("./getEmailContent");
63
63
  exports.getEmailContent = getEmailContent_1.default;
64
64
  Object.defineProperty(exports, "initEmailTemplates", { enumerable: true, get: function () { return getEmailContent_1.initEmailTemplates; } });
65
+ const decimalAmount_1 = require("./decimalAmount");
66
+ Object.defineProperty(exports, "AMOUNT_SCALE", { enumerable: true, get: function () { return decimalAmount_1.AMOUNT_SCALE; } });
67
+ Object.defineProperty(exports, "toUnits", { enumerable: true, get: function () { return decimalAmount_1.toUnits; } });
68
+ Object.defineProperty(exports, "fromUnits", { enumerable: true, get: function () { return decimalAmount_1.fromUnits; } });
69
+ Object.defineProperty(exports, "sumUnits", { enumerable: true, get: function () { return decimalAmount_1.sumUnits; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@provis/provis-common-be-module",
3
- "version": "2.6.95",
3
+ "version": "3.0.0",
4
4
  "description": "This common module for Provis internal backend use lib",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {