@provis/provis-common-be-module 2.6.96 → 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.
Files changed (40) hide show
  1. package/dist/class/main.repository.js +4 -4
  2. package/dist/constants/bankAccount.d.ts +8 -0
  3. package/dist/constants/bankAccount.js +54 -0
  4. package/dist/constants/claim/general.js +1 -1
  5. package/dist/constants/claim/kalog.js +1 -1
  6. package/dist/constants/claim/life.d.ts +2 -2
  7. package/dist/constants/claim/life.js +1 -1
  8. package/dist/constants/claim/loket.js +40 -40
  9. package/dist/constants/claim/motorVehicle.js +1 -1
  10. package/dist/constants/claim/travel.js +1 -1
  11. package/dist/constants/config.js +2 -2
  12. package/dist/constants/invoice/coa.js +5 -5
  13. package/dist/constants/product/cargo/quotation.js +1 -1
  14. package/dist/constants/product/cargo.d.ts +39 -0
  15. package/dist/constants/product/cargo.js +41 -0
  16. package/dist/constants/product/coretax.d.ts +12 -0
  17. package/dist/constants/product/coretax.js +14 -0
  18. package/dist/constants/product/mv.d.ts +30 -0
  19. package/dist/constants/product/mv.js +158 -0
  20. package/dist/constants/product/property/occupation.d.ts +5 -0
  21. package/dist/constants/product/property/occupation.js +1725 -0
  22. package/dist/constants/product.js +14 -14
  23. package/dist/constants/recon.d.ts +1 -1
  24. package/dist/constants/report.d.ts +14 -43
  25. package/dist/constants/source.js +1 -1
  26. package/dist/helpers/alphaNumericCleansing.js +1 -1
  27. package/dist/helpers/amountDescription.js +1 -1
  28. package/dist/helpers/axiosGet.js +1 -1
  29. package/dist/helpers/axiosPost.js +1 -1
  30. package/dist/helpers/axiosPut.js +1 -1
  31. package/dist/helpers/calculateByType.js +1 -1
  32. package/dist/helpers/calculateForNullable.js +6 -6
  33. package/dist/helpers/decimalAmount.js +4 -4
  34. package/dist/helpers/getHeaderUser.js +4 -4
  35. package/dist/helpers/loop.js +2 -2
  36. package/dist/helpers/loopBackward.js +2 -2
  37. package/dist/helpers/readExcel.d.ts +2 -0
  38. package/package.json +1 -1
  39. package/dist/helpers/invoicePeriod.d.ts +0 -11
  40. package/dist/helpers/invoicePeriod.js +0 -66
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const occupation_simple_1 = require("./product/property/occupation-simple");
4
4
  const product = {
5
- LIST: {}, // ini buat semua product
6
- MANUAL_LIST: [], // ini buat product yang bisa diadd manual -> di form quotation / policy
7
- CARGO_BY_SYSTEM_LIST: [], // ini buat product yang by sistem
5
+ LIST: {},
6
+ MANUAL_LIST: [],
7
+ CARGO_BY_SYSTEM_LIST: [],
8
8
  PRODUCT_CODE_PROPERTY_ALL_RISK: 'polismall-property-allrisk',
9
9
  PRODUCT_CODE_EARTHQUAKE: 'polismall-earthquake',
10
10
  PRODUCT_CODE_VEHICLE: 'polismall-vehicle',
@@ -46,7 +46,7 @@ const product = {
46
46
  PRODUCT_CODE_ERECTION_ALL_RISK: 'polismall-erection-all-risk',
47
47
  PRODUCT_CODE_PA_SOGO_ELI_DAYIN: 'polismall-eli',
48
48
  PRODUCT_CODE_PRODUCT_LIABILITY: 'polismall-product-liability',
49
- PRODUCT_POLISMALL_CARGO_QUOTATION: 'polismall-cargo-quotation', // buat quotation
49
+ PRODUCT_POLISMALL_CARGO_QUOTATION: 'polismall-cargo-quotation',
50
50
  // CARGO
51
51
  PRODUCT_POLISMALL_CARGO_MERATUS: 'polismall-cargo-meratus-paliside',
52
52
  PRODUCT_POLISMALL_CARGO: 'polismall-cargo',
@@ -54,17 +54,17 @@ const product = {
54
54
  PRODUCT_CODE_CARGO_BUNDLE: 'polismall-cargo-bundle',
55
55
  PRODUCT_CODE_MERIMEN_CARGO: 'polismall-merimen-cargo',
56
56
  PRODUCT_CODE_CARGO_TEMAS: 'polismall-cargo-temas',
57
- PRODUCT_CODE_CARGO_SINGLE_SHIPMENT: 'polismall-cargo-single-shipment', // Marine Cargo Single Shipment, buat add manual di policy
57
+ PRODUCT_CODE_CARGO_SINGLE_SHIPMENT: 'polismall-cargo-single-shipment',
58
58
  // OTTO
59
- PRODUCT_CODE_OTTO_CI: 'polismall-otto-critical-illness', // ELI
60
- PRODUCT_CODE_OTTO_FLEXAS: 'polismall-otto-flexas', // MNC
61
- PRODUCT_CODE_OTTO_CRACK_SCREEN: 'polismall-otto-crack', // MNC
62
- PRODUCT_CODE_OTTO_AUM_GP: 'polismall-otto-aum-gp', // AUM Gamers Protection
63
- PRODUCT_CODE_OTTO_AUM_PLN: 'polismall-otto-aum-pln', // AUM Biller Protection PLN
64
- PRODUCT_CODE_OTTO_AUM_PDAM: 'polismall-otto-aum-pdam', // AUM Biller Protection PDAM
65
- PRODUCT_CODE_OTTO_AUM_SB: 'polismall-otto-aum-sb', // AUM Merchant Protection Stock Barang
66
- PRODUCT_CODE_OTTO_AUM_FB: 'polismall-otto-aum-fb', // AUM Merchant Protection FLEXAS+BANJIR
67
- PRODUCT_CODE_OTTO_AUM_FBK: 'polismall-otto-aum-fbk', // AUM Merchant Protection FLEXAS+BANJIR+KEBONGKARAN
59
+ PRODUCT_CODE_OTTO_CI: 'polismall-otto-critical-illness',
60
+ PRODUCT_CODE_OTTO_FLEXAS: 'polismall-otto-flexas',
61
+ PRODUCT_CODE_OTTO_CRACK_SCREEN: 'polismall-otto-crack',
62
+ PRODUCT_CODE_OTTO_AUM_GP: 'polismall-otto-aum-gp',
63
+ PRODUCT_CODE_OTTO_AUM_PLN: 'polismall-otto-aum-pln',
64
+ PRODUCT_CODE_OTTO_AUM_PDAM: 'polismall-otto-aum-pdam',
65
+ PRODUCT_CODE_OTTO_AUM_SB: 'polismall-otto-aum-sb',
66
+ PRODUCT_CODE_OTTO_AUM_FB: 'polismall-otto-aum-fb',
67
+ PRODUCT_CODE_OTTO_AUM_FBK: 'polismall-otto-aum-fbk',
68
68
  // BDKI
69
69
  PRODUCT_CODE_BDKI_MOTOR: 'polismall-bdki-motor',
70
70
  PRODUCT_CODE_BDKI_RUMAH: 'polismall-bdki-rumah',
@@ -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;
@@ -6,7 +6,7 @@ const source = {
6
6
  SOURCE_TANTO: 'TANTO',
7
7
  SOURCE_MERATUS_PALISIDE: 'MERATUS-PALISIDE',
8
8
  SOURCE_TEMAS: 'TEMAS',
9
- SOURCE_DOMESTIK: 'DOMESTIK', // Cargo Revamp - Domestix
9
+ SOURCE_DOMESTIK: 'DOMESTIK',
10
10
  SOURCE_YUDHA_EXCEL: 'YUDHA',
11
11
  SOURCE_EXIM: 'EXIM',
12
12
  SOURCE_UPLOAD_BUNDLE: 'UPLOAD-BUNDLE',
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = alphaNumericCleansing;
4
3
  function alphaNumericCleansing(text) {
5
4
  if (typeof text !== 'string')
6
5
  return '';
@@ -8,3 +7,4 @@ function alphaNumericCleansing(text) {
8
7
  .toLowerCase()
9
8
  .replace(/[^a-z0-9]/g, '');
10
9
  }
10
+ exports.default = alphaNumericCleansing;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = terbilang;
4
3
  function terbilang(value) {
5
4
  const satuan = ['', 'satu', 'dua', 'tiga', 'empat', 'lima', 'enam', 'tujuh', 'delapan', 'sembilan'];
6
5
  const belasan = ['sepuluh', 'sebelas', 'dua belas', 'tiga belas', 'empat belas', 'lima belas', 'enam belas', 'tujuh belas', 'delapan belas', 'sembilan belas'];
@@ -42,3 +41,4 @@ function terbilang(value) {
42
41
  // Menghilangkan spasi yang double
43
42
  return result.replace(/\s+/g, ' ').trim();
44
43
  }
44
+ exports.default = terbilang;
@@ -13,7 +13,7 @@ const axios_1 = require("axios");
13
13
  const generateRelationId_1 = require("./generateRelationId");
14
14
  const getCurrentDate_1 = require("./getCurrentDate");
15
15
  const constants_1 = require("../constants");
16
- exports.default = (_a) => __awaiter(void 0, [_a], void 0, function* ({ url, headers, params, callback, }) {
16
+ exports.default = ({ url, headers, params, callback, }) => __awaiter(void 0, void 0, void 0, function* () {
17
17
  return yield axios_1.default.get(url, {
18
18
  params,
19
19
  headers: Object.assign({ 'Content-Type': 'application/json', 'X-Correlation-Id': (0, generateRelationId_1.default)(24), 'X-Transmission-Date-Time': (0, getCurrentDate_1.default)() }, headers),
@@ -13,7 +13,7 @@ const axios_1 = require("axios");
13
13
  const generateRelationId_1 = require("./generateRelationId");
14
14
  const getCurrentDate_1 = require("./getCurrentDate");
15
15
  const constants_1 = require("../constants");
16
- exports.default = (_a) => __awaiter(void 0, [_a], void 0, function* ({ url, headers, body, callback, }) {
16
+ exports.default = ({ url, headers, body, callback, }) => __awaiter(void 0, void 0, void 0, function* () {
17
17
  return yield axios_1.default.post(url, body, {
18
18
  headers: Object.assign({ 'Content-Type': 'application/json', 'X-Correlation-Id': (0, generateRelationId_1.default)(24), 'X-Transmission-Date-Time': (0, getCurrentDate_1.default)() }, headers),
19
19
  }).then((result) => __awaiter(void 0, void 0, void 0, function* () {
@@ -13,7 +13,7 @@ const axios_1 = require("axios");
13
13
  const constants_1 = require("../constants");
14
14
  const generateRelationId_1 = require("./generateRelationId");
15
15
  const getCurrentDate_1 = require("./getCurrentDate");
16
- exports.default = (_a) => __awaiter(void 0, [_a], void 0, function* ({ url, headers, body, callback, }) {
16
+ exports.default = ({ url, headers, body, callback, }) => __awaiter(void 0, void 0, void 0, function* () {
17
17
  return yield axios_1.default.put(url, body, {
18
18
  headers: Object.assign({ 'Content-Type': 'application/json', 'X-Correlation-Id': (0, generateRelationId_1.default)(24), 'X-Transmission-Date-Time': (0, getCurrentDate_1.default)() }, headers),
19
19
  }).then((result) => __awaiter(void 0, void 0, void 0, function* () {
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
3
  const brokerage_1 = require("../constants/brokerage");
5
4
  function default_1(request) {
6
5
  try {
@@ -17,3 +16,4 @@ function default_1(request) {
17
16
  return null;
18
17
  }
19
18
  }
19
+ exports.default = default_1;
@@ -1,11 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.minusN = exports.sumN = void 0;
4
- exports.sum = sum;
5
- exports.minus = minus;
6
- exports.multiple = multiple;
7
- exports.divide = divide;
8
- exports.roundTo = roundTo;
3
+ exports.roundTo = exports.minusN = exports.sumN = exports.divide = exports.multiple = exports.minus = exports.sum = void 0;
9
4
  function sum(a, b) {
10
5
  try {
11
6
  if (a == null && b == null)
@@ -16,6 +11,7 @@ function sum(a, b) {
16
11
  return null;
17
12
  }
18
13
  }
14
+ exports.sum = sum;
19
15
  function minus(a, b) {
20
16
  try {
21
17
  if (a == null && b == null)
@@ -26,6 +22,7 @@ function minus(a, b) {
26
22
  return null;
27
23
  }
28
24
  }
25
+ exports.minus = minus;
29
26
  function multiple(a, b) {
30
27
  try {
31
28
  if (a == null && b == null)
@@ -36,6 +33,7 @@ function multiple(a, b) {
36
33
  return null;
37
34
  }
38
35
  }
36
+ exports.multiple = multiple;
39
37
  function roundTo(num, precision = 2) {
40
38
  try {
41
39
  if (num == null && precision == null)
@@ -47,6 +45,7 @@ function roundTo(num, precision = 2) {
47
45
  return null;
48
46
  }
49
47
  }
48
+ exports.roundTo = roundTo;
50
49
  function divide(a, b) {
51
50
  try {
52
51
  if (a == null && b == null)
@@ -59,6 +58,7 @@ function divide(a, b) {
59
58
  return null;
60
59
  }
61
60
  }
61
+ exports.divide = divide;
62
62
  const sumN = (...numbers) => {
63
63
  let result = null;
64
64
  numbers.forEach(each => {
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AMOUNT_SCALE = void 0;
4
- exports.toUnits = toUnits;
5
- exports.fromUnits = fromUnits;
6
- exports.sumUnits = sumUnits;
3
+ exports.sumUnits = exports.fromUnits = exports.toUnits = exports.AMOUNT_SCALE = void 0;
7
4
  // Untuk nilai uang yang dipakai ledger (kolom decimal(16,4)): semua hitungan dilakukan
8
5
  // dalam integer (nilai * 10^4) biar debit dan kredit tidak pernah beda gara-gara float.
9
6
  // Konversi ke string cuma sekali, waktu mau disimpan.
@@ -22,12 +19,15 @@ function toUnits(value) {
22
19
  }
23
20
  return units;
24
21
  }
22
+ exports.toUnits = toUnits;
25
23
  function fromUnits(units) {
26
24
  return (units / FACTOR).toFixed(exports.AMOUNT_SCALE);
27
25
  }
26
+ exports.fromUnits = fromUnits;
28
27
  function sumUnits(...values) {
29
28
  return values.reduce((total, value) => total + value, 0);
30
29
  }
30
+ exports.sumUnits = sumUnits;
31
31
  exports.default = {
32
32
  AMOUNT_SCALE: exports.AMOUNT_SCALE,
33
33
  toUnits,
@@ -5,10 +5,10 @@ exports.default = (req, { isUserCodeMandatory = true } = {}) => {
5
5
  if (!userCode && isUserCodeMandatory)
6
6
  throw new Error('Usercode is not found');
7
7
  return {
8
- userCode: req.headers['x-user'] || req.headers['userCode'], //x-user -> isinya userCode
9
- username: req.headers['x-username'] || req.headers['username'], //x-username -> isinya auth.username
10
- userEmail: req.headers['x-useremail'] || req.headers['x-user-email'] || req.headers['userEmail'], //x-useremail -> isinya auth.username
11
- isAdmin: req.headers['x-admin'] || req.headers['isAdmin'], //x-admin // isi 1/undefined -> jika 1 berarti admin
8
+ userCode: req.headers['x-user'] || req.headers['userCode'],
9
+ username: req.headers['x-username'] || req.headers['username'],
10
+ userEmail: req.headers['x-useremail'] || req.headers['x-user-email'] || req.headers['userEmail'],
11
+ isAdmin: req.headers['x-admin'] || req.headers['isAdmin'],
12
12
  isPublic: req.headers['x-public'], //x-public isi 1/undefined -> jika 1 berarti akses public
13
13
  };
14
14
  };
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- function loop(list_1, callback_1) {
13
- return __awaiter(this, arguments, void 0, function* (list, callback, result = []) {
12
+ function loop(list, callback, result = []) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
14
  if (list && list.length > 0) {
15
15
  const [head, ...tail] = list;
16
16
  return loop(tail, callback, [yield callback(head), ...result]);
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- function loop(list_1, callback_1) {
13
- return __awaiter(this, arguments, void 0, function* (list, callback, result = []) {
12
+ function loop(list, callback, result = []) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
14
  if (list && list.length > 0) {
15
15
  const [head, ...tail] = list;
16
16
  return loop(tail, callback, [...result, yield callback(head)]);
@@ -1,3 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import IReadExcel from '../interface/read.excel.interface';
2
4
  declare function readExcel(file: Buffer, data: IReadExcel): Promise<any>;
3
5
  export default readExcel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@provis/provis-common-be-module",
3
- "version": "2.6.96",
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": {
@@ -1,11 +0,0 @@
1
- export declare const CUTOFF_DAY = 15;
2
- export declare const monthsBetween: (issueDate: string | Date, actionDate: string | Date) => number | null;
3
- export declare const requiresCreditNote: (issueDate: string | Date, actionDate: string | Date) => boolean;
4
- export declare const canReviseInPlace: (issueDate: string | Date, actionDate: string | Date) => boolean;
5
- declare const _default: {
6
- CUTOFF_DAY: number;
7
- monthsBetween: (issueDate: string | Date, actionDate: string | Date) => number | null;
8
- requiresCreditNote: (issueDate: string | Date, actionDate: string | Date) => boolean;
9
- canReviseInPlace: (issueDate: string | Date, actionDate: string | Date) => boolean;
10
- };
11
- export default _default;
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.canReviseInPlace = exports.requiresCreditNote = exports.monthsBetween = exports.CUTOFF_DAY = void 0;
4
- // Buku bulan N ditutup tanggal 15 bulan N+1. Selama periode invoice masih terbuka, revisi dan
5
- // cancel boleh langsung ubah invoice yang sama. Kalau sudah ditutup, invoice lama harus dicancel
6
- // dan terbit Credit Note (untuk revisi: plus invoice baru dengan nomor baru).
7
- //
8
- // contoh invoice terbit 1 Januari 2026:
9
- // 31 Januari -> boleh langsung, bulannya sama
10
- // 14 Februari -> boleh langsung, buku Januari belum ditutup
11
- // 15 Februari -> wajib CN, buku Januari sudah ditutup
12
- // 10 Maret -> wajib CN
13
- exports.CUTOFF_DAY = 15;
14
- // ambil komponen tanggalnya saja biar tidak kena geser zona waktu.
15
- // terima Date maupun string 'YYYY-MM-DD...' seperti yang disimpan di database
16
- const toDateParts = (value) => {
17
- if (!value)
18
- return null;
19
- if (value instanceof Date) {
20
- if (isNaN(value.getTime()))
21
- return null;
22
- return {
23
- year: value.getFullYear(),
24
- month: value.getMonth() + 1,
25
- day: value.getDate(),
26
- };
27
- }
28
- const matched = /^(\d{4})-(\d{2})-(\d{2})/.exec(`${value}`.trim());
29
- if (!matched)
30
- return null;
31
- return {
32
- year: parseInt(matched[1], 10),
33
- month: parseInt(matched[2], 10),
34
- day: parseInt(matched[3], 10),
35
- };
36
- };
37
- const monthsBetween = (issueDate, actionDate) => {
38
- const issue = toDateParts(issueDate);
39
- const action = toDateParts(actionDate);
40
- if (!issue || !action)
41
- return null;
42
- return ((action.year - issue.year) * 12) + (action.month - issue.month);
43
- };
44
- exports.monthsBetween = monthsBetween;
45
- // true = tidak boleh diubah langsung, wajib terbitkan Credit Note.
46
- // kalau tanggalnya tidak kebaca, balikin false biar perilaku lama (revisi langsung) tetap jalan
47
- const requiresCreditNote = (issueDate, actionDate) => {
48
- const monthsDiff = (0, exports.monthsBetween)(issueDate, actionDate);
49
- const action = toDateParts(actionDate);
50
- if (monthsDiff === null || !action)
51
- return false;
52
- if (monthsDiff <= 0)
53
- return false; // masih bulan yang sama
54
- if (monthsDiff === 1)
55
- return action.day >= exports.CUTOFF_DAY; // buku bulan lalu ditutup tanggal 15
56
- return true; // dua bulan atau lebih, periodenya pasti sudah tutup
57
- };
58
- exports.requiresCreditNote = requiresCreditNote;
59
- const canReviseInPlace = (issueDate, actionDate) => !(0, exports.requiresCreditNote)(issueDate, actionDate);
60
- exports.canReviseInPlace = canReviseInPlace;
61
- exports.default = {
62
- CUTOFF_DAY: exports.CUTOFF_DAY,
63
- monthsBetween: exports.monthsBetween,
64
- requiresCreditNote: exports.requiresCreditNote,
65
- canReviseInPlace: exports.canReviseInPlace,
66
- };