@bisondesk/documents-sdk 1.0.588 → 1.0.590
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/lib/apis/document-drafts.js.map +1 -1
- package/lib/apis/documents-search.js.map +1 -1
- package/lib/apis/documents.js.map +1 -1
- package/lib/constants/search.d.ts +473 -9
- package/lib/constants/search.d.ts.map +1 -1
- package/lib/constants/search.js +0 -18
- package/lib/constants/search.js.map +1 -1
- package/lib/types/ai.js.map +1 -1
- package/lib/types/documents.js.map +1 -1
- package/lib/utils/associations.js.map +1 -1
- package/lib/utils/finance-legacy.d.ts.map +1 -1
- package/lib/utils/finance-legacy.js.map +1 -1
- package/lib/utils/finance.js.map +1 -1
- package/lib/utils/vat.js.map +1 -1
- package/lib/utils/visibility.js.map +1 -1
- package/package.json +14 -10
- package/src/apis/document-drafts.ts +20 -20
- package/src/apis/documents-search.ts +2 -2
- package/src/apis/documents.ts +14 -14
- package/src/constants/index.js +45 -0
- package/src/constants/index.js.map +1 -0
- package/src/constants/search.js +240 -0
- package/src/constants/search.js.map +1 -0
- package/src/types/ai.ts +1 -1
- package/src/types/bank-accounts.js +2 -0
- package/src/types/bank-accounts.js.map +1 -0
- package/src/types/booking.js +2 -0
- package/src/types/booking.js.map +1 -0
- package/src/types/document-categories.js +11 -0
- package/src/types/document-categories.js.map +1 -0
- package/src/types/documents.js +68 -0
- package/src/types/documents.js.map +1 -0
- package/src/types/documents.ts +5 -5
- package/src/types/legacy.js +2 -0
- package/src/types/legacy.js.map +1 -0
- package/src/types/rules.js +15 -0
- package/src/types/rules.js.map +1 -0
- package/src/types/search.js +13 -0
- package/src/types/search.js.map +1 -0
- package/src/types/vat.js +2 -0
- package/src/types/vat.js.map +1 -0
- package/src/utils/associations.ts +3 -3
- package/src/utils/finance-legacy.ts +7 -7
- package/src/utils/finance.ts +20 -20
- package/src/utils/previews.js +2 -0
- package/src/utils/previews.js.map +1 -0
- package/src/utils/vat.ts +5 -5
- package/src/utils/visibility.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/schemas.d.ts +0 -6
- package/lib/schemas.d.ts.map +0 -1
- package/lib/schemas.js +0 -127
- package/lib/schemas.js.map +0 -1
- package/src/constants/search.ts +0 -290
- package/src/schemas.ts +0 -144
package/lib/constants/search.js
CHANGED
|
@@ -38,9 +38,6 @@ const BASE_DOC_DRAFT_MAPPING_FIELDS = {
|
|
|
38
38
|
'custom.validationRulesStatus': {
|
|
39
39
|
esMapping: { type: 'keyword' },
|
|
40
40
|
},
|
|
41
|
-
'custom.businessValidationAt': {
|
|
42
|
-
esMapping: { type: 'date' },
|
|
43
|
-
},
|
|
44
41
|
};
|
|
45
42
|
const FINANCE_DOC_DRAFT_MAPPING_FIELDS = {
|
|
46
43
|
'doc.type': {
|
|
@@ -91,9 +88,6 @@ const FINANCE_DOC_DRAFT_MAPPING_FIELDS = {
|
|
|
91
88
|
'custom.validators': {
|
|
92
89
|
esMapping: { type: 'keyword' },
|
|
93
90
|
},
|
|
94
|
-
'custom.restrictedDraftUsers': {
|
|
95
|
-
esMapping: { type: 'keyword' },
|
|
96
|
-
},
|
|
97
91
|
};
|
|
98
92
|
const ADMIN_DOC_DRAFT_MAPPING_FIELDS = {
|
|
99
93
|
'doc.tags': {
|
|
@@ -169,11 +163,6 @@ export const DOC_DRAFT_DEFINITION_FIELDS = {
|
|
|
169
163
|
titles: getTranslatedTitles('aggs.draft.rejected'),
|
|
170
164
|
type: FieldTypes.checkbox,
|
|
171
165
|
},
|
|
172
|
-
'custom.restrictedDraftUsers': {
|
|
173
|
-
id: 'custom.restrictedDraftUsers',
|
|
174
|
-
titles: getTranslatedTitles('agg.drafts.restrictedDraftUsers'),
|
|
175
|
-
type: FieldTypes.text,
|
|
176
|
-
},
|
|
177
166
|
};
|
|
178
167
|
export const getSearchDocumentDraftsAggs = () => [
|
|
179
168
|
{
|
|
@@ -223,13 +212,6 @@ export const getSearchDocumentDraftsAggs = () => [
|
|
|
223
212
|
},
|
|
224
213
|
],
|
|
225
214
|
},
|
|
226
|
-
{
|
|
227
|
-
titles: getTranslatedTitles('aggs.draft.restrictedDraftUsers'),
|
|
228
|
-
fieldId: 'custom.restrictedDraftUsers',
|
|
229
|
-
fieldType: FieldTypes.text,
|
|
230
|
-
type: AggregationType.term,
|
|
231
|
-
orderBy: 'count',
|
|
232
|
-
},
|
|
233
215
|
];
|
|
234
216
|
export const SEARCH_DOC_DRAFT_FULL_TEXT_FIELDS = [
|
|
235
217
|
() => 'doc.id',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"/","sources":["constants/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAStE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE/E,MAAM,6BAA6B,GAE/B;IACF,QAAQ,EAAE;QACR,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,yBAAyB,EAAE;KACjE;IACD,YAAY,EAAE;QACZ,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC/B;IACD,kBAAkB,EAAE;QAClB,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC/B;IACD,cAAc,EAAE;QACd,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC/B;IACD,cAAc,EAAE;QACd,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC/B;IACD,gBAAgB,EAAE;QAChB,SAA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C;QAChD,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,eAAe,CAAC,KAAK;QAC3B,MAAM,EAAE;YACN;gBACE,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;gBACtC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;aAC1E;SACF;KACF;IACD;QACE,MAAM,EAAE,mBAAmB,CAAC,iCAAiC,CAAC;QAC9D,OAAO,EAAE,6BAA6B;QACtC,SAAS,EAAE,UAAU,CAAC,IAAI;QAC1B,IAAI,EAAE,eAAe,CAAC,IAAI;QAC1B,OAAO,EAAE,OAAO;KACjB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAA+B;IAE3E,GAAG,EAAE,CAAC,QAAQ;IACd,GAAG,EAAE,CAAC,eAAe;IACrB,GAAG,EAAE,CAAC,UAAU;IAChB,GAAG,EAAE,CAAC,6BAA6B;IAEnC,GAAG,EAAE,CAAC,UAAU;IAChB,GAAG,EAAE,CAAC,uBAAuB;IAE7B,GAAG,EAAE,CAAC,8BAA8B;IACpC,GAAG,EAAE,CAAC,4BAA4B;IAClC,GAAG,EAAE,CAAC,8BAA8B;IACpC,GAAG,EAAE,CAAC,mCAAmC;CAC1C,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAiB;IACtD,IAAI,EAAE,iBAAiB;IACvB,aAAa,EAAE,EAAE;IACjB,MAAM,EAAE;QACN,GAAG,wBAAwB;KAC5B;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAqB;IAC5D,MAAM,EAAE;QACN,GAAG,2BAA2B;KAC/B;CACF,CAAC","sourcesContent":["import { DEFAULT_EXACT_MATCH_BOOST } from '@bisondesk/commons/es';\nimport { getTranslatedTitles } from '@bisondesk/commons/translations';\nimport {\n EsAggregationsDefinition,\n EsDefinition,\n EsDefinitionField,\n EsFullTextSearchDefinition,\n SearchDefinition,\n SearchField,\n} from '@bisondesk/core-sdk/types/definitions';\nimport { DateGranularity, FieldTypes } from '@bisondesk/core-sdk/types/fields';\nimport { AggregationType } from '@bisondesk/core-sdk/types/search';\nimport { UTCDate } from '@date-fns/utc';\nimport { getTime, parseISO, setHours, setMinutes, setSeconds } from 'date-fns';\n\nconst BASE_DOC_DRAFT_MAPPING_FIELDS: {\n [fieldId: string]: EsDefinitionField;\n} = {\n 'doc.id': {\n esMapping: { type: 'keyword', boost: DEFAULT_EXACT_MATCH_BOOST },\n },\n 'doc.status': {\n esMapping: { type: 'keyword' },\n },\n 'doc.documentType': {\n esMapping: { type: 'keyword' },\n },\n 'doc.category': {\n esMapping: { type: 'keyword' },\n },\n 'doc.branchId': {\n esMapping: { type: 'keyword' },\n },\n 'doc.attachment': {\n esMapping: { type: 'object', enabled: false },\n },\n 'doc.createdAt': {\n esMapping: { type: 'date' },\n },\n 'doc.createdBy': {\n esMapping: { type: 'keyword' },\n },\n 'custom.stage': {\n esMapping: { type: 'keyword' },\n },\n 'custom.rejected': {\n esMapping: { type: 'boolean' },\n },\n 'custom.validationRulesStatus': {\n esMapping: { type: 'keyword' },\n },\n 'custom.businessValidationAt': {\n esMapping: { type: 'date' },\n },\n};\n\nconst FINANCE_DOC_DRAFT_MAPPING_FIELDS: {\n [fieldId: string]: EsDefinitionField;\n} = {\n 'doc.type': {\n esMapping: { type: 'keyword' },\n },\n 'doc.subtype': {\n esMapping: { type: 'keyword' },\n },\n 'doc.reference': {\n esMapping: { type: 'keyword', boost: DEFAULT_EXACT_MATCH_BOOST },\n },\n 'doc.issueDate': {\n esMapping: { type: 'date', ignore_malformed: true },\n },\n 'doc.dueDate': {\n esMapping: { type: 'date', ignore_malformed: true },\n },\n\n 'doc.organizationSummary.name': {\n esMapping: { type: 'text' },\n },\n 'doc.organizationSummary.id': {\n esMapping: { type: 'keyword' },\n },\n 'doc.organizationSummary.code': {\n esMapping: { type: 'keyword' },\n },\n 'doc.organizationSummary.vatNumber': {\n esMapping: { type: 'text' },\n },\n\n 'doc.lines.associations.businessEntityId': {\n esMapping: { type: 'keyword' },\n },\n 'doc.lines.associations.recordId': {\n esMapping: { type: 'keyword' },\n },\n 'doc.lines.associations.title': {\n esMapping: { type: 'text' },\n },\n 'doc.lines.associations.description': {\n esMapping: { type: 'text' },\n },\n 'doc.lines.associations.tags': {\n esMapping: { type: 'keyword' },\n },\n 'doc.invoiceId': {\n esMapping: { type: 'keyword' },\n },\n 'custom.validators': {\n esMapping: { type: 'keyword' },\n },\n 'custom.restrictedDraftUsers': {\n esMapping: { type: 'keyword' },\n },\n};\n\nconst ADMIN_DOC_DRAFT_MAPPING_FIELDS: {\n [fieldId: string]: EsDefinitionField;\n} = {\n 'doc.tags': {\n esMapping: { type: 'text' },\n },\n 'doc.associations.businessEntityId': {\n esMapping: { type: 'keyword' },\n },\n 'doc.associations.recordId': {\n esMapping: { type: 'keyword' },\n },\n 'doc.associations.title': {\n esMapping: { type: 'text' },\n },\n 'doc.associations.description': {\n esMapping: { type: 'text' },\n },\n 'doc.associations.tags': {\n esMapping: { type: 'keyword' },\n },\n};\n\nexport const DOC_DRAFT_MAPPING_FIELDS: {\n [fieldId: string]: EsDefinitionField;\n} = {\n ...BASE_DOC_DRAFT_MAPPING_FIELDS,\n ...FINANCE_DOC_DRAFT_MAPPING_FIELDS,\n ...ADMIN_DOC_DRAFT_MAPPING_FIELDS,\n};\n\nexport const DOC_DRAFT_DEFINITION_FIELDS: {\n [fieldId: string]: SearchField;\n} = {\n 'doc.id': {\n id: 'doc.id',\n titles: getTranslatedTitles('id'),\n type: FieldTypes.text,\n },\n 'custom.stage': {\n id: 'custom.stage',\n titles: getTranslatedTitles('aggs.draft.stage'),\n type: FieldTypes.text,\n },\n 'doc.documentType': {\n id: 'doc.documentType',\n titles: getTranslatedTitles('aggs.draft.documentType'),\n type: FieldTypes.text,\n },\n 'doc.branchId': {\n id: 'doc.branchId',\n titles: getTranslatedTitles('branch'),\n type: FieldTypes.text,\n },\n 'doc.createdAt': {\n id: 'doc.createdAt',\n titles: getTranslatedTitles('aggs.creationDate'),\n type: FieldTypes.date,\n meta: {\n granularity: DateGranularity.yearMonthDayTime,\n },\n },\n 'custom.validationRulesStatus': {\n id: 'custom.validationRulesStatus',\n titles: getTranslatedTitles('aggs.draft.validationRules'),\n type: FieldTypes.text,\n },\n 'doc.createdBy': {\n id: 'doc.createdBy',\n titles: getTranslatedTitles('aggs.createdBy'),\n type: FieldTypes.collaborator,\n },\n // Finance fields\n 'doc.subtype': {\n id: 'doc.subtype',\n titles: getTranslatedTitles('type'),\n type: FieldTypes.text,\n },\n 'custom.rejected': {\n id: 'custom.rejected',\n titles: getTranslatedTitles('aggs.draft.rejected'),\n type: FieldTypes.checkbox,\n },\n 'custom.restrictedDraftUsers': {\n id: 'custom.restrictedDraftUsers',\n titles: getTranslatedTitles('agg.drafts.restrictedDraftUsers'),\n type: FieldTypes.text,\n },\n};\n\nexport const getSearchDocumentDraftsAggs = (): EsAggregationsDefinition => [\n {\n titles: getTranslatedTitles('aggs.draft.stage'),\n fieldId: 'custom.stage',\n fieldType: FieldTypes.text,\n type: AggregationType.term,\n orderBy: 'count',\n },\n {\n titles: getTranslatedTitles('aggs.draft.documentType'),\n fieldId: 'doc.documentType',\n fieldType: FieldTypes.text,\n type: AggregationType.term,\n orderBy: 'count',\n },\n {\n titles: getTranslatedTitles('type'),\n fieldId: 'doc.subtype',\n fieldType: FieldTypes.text,\n type: AggregationType.term,\n orderBy: 'count',\n },\n {\n titles: getTranslatedTitles('aggs.draft.rejected'),\n fieldId: 'custom.rejected',\n fieldType: FieldTypes.checkbox,\n type: AggregationType.term,\n orderBy: 'count',\n },\n {\n titles: getTranslatedTitles('aggs.draft.validationRules'),\n fieldId: 'custom.validationRulesStatus',\n fieldType: FieldTypes.text,\n type: AggregationType.term,\n orderBy: 'count',\n },\n {\n titles: getTranslatedTitles('aggs.creationDate'),\n fieldId: 'doc.createdAt',\n step: 1,\n type: AggregationType.range,\n ranges: [\n {\n start: getTime(parseISO('2015-01-01')),\n end: getTime(setSeconds(setMinutes(setHours(new UTCDate(), 23), 59), 59)),\n },\n ],\n },\n {\n titles: getTranslatedTitles('aggs.draft.restrictedDraftUsers'),\n fieldId: 'custom.restrictedDraftUsers',\n fieldType: FieldTypes.text,\n type: AggregationType.term,\n orderBy: 'count',\n },\n];\n\nexport const SEARCH_DOC_DRAFT_FULL_TEXT_FIELDS: EsFullTextSearchDefinition = [\n // finance fields\n () => 'doc.id',\n () => 'doc.reference',\n () => 'doc.tags',\n () => 'doc.lines.associations.tags',\n // administrative fields\n () => 'doc.tags',\n () => 'doc.associations.tags',\n // OrgSummary fields\n () => 'doc.organizationSummary.name',\n () => 'doc.organizationSummary.id',\n () => 'doc.organizationSummary.code',\n () => 'doc.organizationSummary.vatNumber',\n];\n\nexport const SEARCH_DOC_DRAFTS_MAPPINGS: EsDefinition = {\n name: 'document_drafts',\n nestedEsPaths: [],\n fields: {\n ...DOC_DRAFT_MAPPING_FIELDS,\n },\n};\n\nexport const SEARCH_DOC_DRAFTS_DEFINITION: SearchDefinition = {\n fields: {\n ...DOC_DRAFT_DEFINITION_FIELDS,\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"/","sources":["constants/search.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM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,EAAE,UAAU,CAAC,IAAI;QAC1B,IAAI,EAAE,eAAe,CAAC,IAAI;QAC1B,OAAO,EAAE,OAAO;KACnB;IACD;QACI,MAAM,EAAE,mBAAmB,CAAC,mBAAmB,CAAC;QAChD,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,eAAe,CAAC,KAAK;QAC3B,MAAM,EAAE;YACJ;gBACI,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;gBACtC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;aAC5E;SACJ;KACJ;CACJ,CAAC;AACF,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC7C,GAAG,EAAE,CAAC,QAAQ;IACd,GAAG,EAAE,CAAC,eAAe;IACrB,GAAG,EAAE,CAAC,UAAU;IAChB,GAAG,EAAE,CAAC,6BAA6B;IACnC,GAAG,EAAE,CAAC,UAAU;IAChB,GAAG,EAAE,CAAC,uBAAuB;IAC7B,GAAG,EAAE,CAAC,8BAA8B;IACpC,GAAG,EAAE,CAAC,4BAA4B;IAClC,GAAG,EAAE,CAAC,8BAA8B;IACpC,GAAG,EAAE,CAAC,mCAAmC;CAC5C,CAAC;AACF,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACtC,IAAI,EAAE,iBAAiB;IACvB,aAAa,EAAE,EAAE;IACjB,MAAM,EAAE;QACJ,GAAG,wBAAwB;KAC9B;CACJ,CAAC;AACF,MAAM,CAAC,MAAM,4BAA4B,GAAG;IACxC,MAAM,EAAE;QACJ,GAAG,2BAA2B;KACjC;CACJ,CAAC","sourcesContent":["import { DEFAULT_EXACT_MATCH_BOOST } from '@bisondesk/commons/es';\nimport { getTranslatedTitles } from '@bisondesk/commons/translations';\nimport { DateGranularity, FieldTypes } from '@bisondesk/core-sdk/types/fields';\nimport { AggregationType } from '@bisondesk/core-sdk/types/search';\nimport { UTCDate } from '@date-fns/utc';\nimport { getTime, parseISO, setHours, setMinutes, setSeconds } from 'date-fns';\nconst BASE_DOC_DRAFT_MAPPING_FIELDS = {\n 'doc.id': {\n esMapping: { type: 'keyword', boost: DEFAULT_EXACT_MATCH_BOOST },\n },\n 'doc.status': {\n esMapping: { type: 'keyword' },\n },\n 'doc.documentType': {\n esMapping: { type: 'keyword' },\n },\n 'doc.category': {\n esMapping: { type: 'keyword' },\n },\n 'doc.branchId': {\n esMapping: { type: 'keyword' },\n },\n 'doc.attachment': {\n esMapping: { type: 'object', enabled: false },\n },\n 'doc.createdAt': {\n esMapping: { type: 'date' },\n },\n 'doc.createdBy': {\n esMapping: { type: 'keyword' },\n },\n 'custom.stage': {\n esMapping: { type: 'keyword' },\n },\n 'custom.rejected': {\n esMapping: { type: 'boolean' },\n },\n 'custom.validationRulesStatus': {\n esMapping: { type: 'keyword' },\n },\n};\nconst FINANCE_DOC_DRAFT_MAPPING_FIELDS = {\n 'doc.type': {\n esMapping: { type: 'keyword' },\n },\n 'doc.subtype': {\n esMapping: { type: 'keyword' },\n },\n 'doc.reference': {\n esMapping: { type: 'keyword', boost: DEFAULT_EXACT_MATCH_BOOST },\n },\n 'doc.issueDate': {\n esMapping: { type: 'date', ignore_malformed: true },\n },\n 'doc.dueDate': {\n esMapping: { type: 'date', ignore_malformed: true },\n },\n 'doc.organizationSummary.name': {\n esMapping: { type: 'text' },\n },\n 'doc.organizationSummary.id': {\n esMapping: { type: 'keyword' },\n },\n 'doc.organizationSummary.code': {\n esMapping: { type: 'keyword' },\n },\n 'doc.organizationSummary.vatNumber': {\n esMapping: { type: 'text' },\n },\n 'doc.lines.associations.businessEntityId': {\n esMapping: { type: 'keyword' },\n },\n 'doc.lines.associations.recordId': {\n esMapping: { type: 'keyword' },\n },\n 'doc.lines.associations.title': {\n esMapping: { type: 'text' },\n },\n 'doc.lines.associations.description': {\n esMapping: { type: 'text' },\n },\n 'doc.lines.associations.tags': {\n esMapping: { type: 'keyword' },\n },\n 'doc.invoiceId': {\n esMapping: { type: 'keyword' },\n },\n 'custom.validators': {\n esMapping: { type: 'keyword' },\n },\n};\nconst ADMIN_DOC_DRAFT_MAPPING_FIELDS = {\n 'doc.tags': {\n esMapping: { type: 'text' },\n },\n 'doc.associations.businessEntityId': {\n esMapping: { type: 'keyword' },\n },\n 'doc.associations.recordId': {\n esMapping: { type: 'keyword' },\n },\n 'doc.associations.title': {\n esMapping: { type: 'text' },\n },\n 'doc.associations.description': {\n esMapping: { type: 'text' },\n },\n 'doc.associations.tags': {\n esMapping: { type: 'keyword' },\n },\n};\nexport const DOC_DRAFT_MAPPING_FIELDS = {\n ...BASE_DOC_DRAFT_MAPPING_FIELDS,\n ...FINANCE_DOC_DRAFT_MAPPING_FIELDS,\n ...ADMIN_DOC_DRAFT_MAPPING_FIELDS,\n};\nexport const DOC_DRAFT_DEFINITION_FIELDS = {\n 'doc.id': {\n id: 'doc.id',\n titles: getTranslatedTitles('id'),\n type: FieldTypes.text,\n },\n 'custom.stage': {\n id: 'custom.stage',\n titles: getTranslatedTitles('aggs.draft.stage'),\n type: FieldTypes.text,\n },\n 'doc.documentType': {\n id: 'doc.documentType',\n titles: getTranslatedTitles('aggs.draft.documentType'),\n type: FieldTypes.text,\n },\n 'doc.branchId': {\n id: 'doc.branchId',\n titles: getTranslatedTitles('branch'),\n type: FieldTypes.text,\n },\n 'doc.createdAt': {\n id: 'doc.createdAt',\n titles: getTranslatedTitles('aggs.creationDate'),\n type: FieldTypes.date,\n meta: {\n granularity: DateGranularity.yearMonthDayTime,\n },\n },\n 'custom.validationRulesStatus': {\n id: 'custom.validationRulesStatus',\n titles: getTranslatedTitles('aggs.draft.validationRules'),\n type: FieldTypes.text,\n },\n 'doc.createdBy': {\n id: 'doc.createdBy',\n titles: getTranslatedTitles('aggs.createdBy'),\n type: FieldTypes.collaborator,\n },\n 'doc.subtype': {\n id: 'doc.subtype',\n titles: getTranslatedTitles('type'),\n type: FieldTypes.text,\n },\n 'custom.rejected': {\n id: 'custom.rejected',\n titles: getTranslatedTitles('aggs.draft.rejected'),\n type: FieldTypes.checkbox,\n },\n};\nexport const getSearchDocumentDraftsAggs = () => [\n {\n titles: getTranslatedTitles('aggs.draft.stage'),\n fieldId: 'custom.stage',\n fieldType: FieldTypes.text,\n type: AggregationType.term,\n orderBy: 'count',\n },\n {\n titles: getTranslatedTitles('aggs.draft.documentType'),\n fieldId: 'doc.documentType',\n fieldType: FieldTypes.text,\n type: AggregationType.term,\n orderBy: 'count',\n },\n {\n titles: getTranslatedTitles('type'),\n fieldId: 'doc.subtype',\n fieldType: FieldTypes.text,\n type: AggregationType.term,\n orderBy: 'count',\n },\n {\n titles: getTranslatedTitles('aggs.draft.rejected'),\n fieldId: 'custom.rejected',\n fieldType: FieldTypes.checkbox,\n type: AggregationType.term,\n orderBy: 'count',\n },\n {\n titles: getTranslatedTitles('aggs.draft.validationRules'),\n fieldId: 'custom.validationRulesStatus',\n fieldType: FieldTypes.text,\n type: AggregationType.term,\n orderBy: 'count',\n },\n {\n titles: getTranslatedTitles('aggs.creationDate'),\n fieldId: 'doc.createdAt',\n step: 1,\n type: AggregationType.range,\n ranges: [\n {\n start: getTime(parseISO('2015-01-01')),\n end: getTime(setSeconds(setMinutes(setHours(new UTCDate(), 23), 59), 59)),\n },\n ],\n },\n];\nexport const SEARCH_DOC_DRAFT_FULL_TEXT_FIELDS = [\n () => 'doc.id',\n () => 'doc.reference',\n () => 'doc.tags',\n () => 'doc.lines.associations.tags',\n () => 'doc.tags',\n () => 'doc.associations.tags',\n () => 'doc.organizationSummary.name',\n () => 'doc.organizationSummary.id',\n () => 'doc.organizationSummary.code',\n () => 'doc.organizationSummary.vatNumber',\n];\nexport const SEARCH_DOC_DRAFTS_MAPPINGS = {\n name: 'document_drafts',\n nestedEsPaths: [],\n fields: {\n ...DOC_DRAFT_MAPPING_FIELDS,\n },\n};\nexport const SEARCH_DOC_DRAFTS_DEFINITION = {\n fields: {\n ...DOC_DRAFT_DEFINITION_FIELDS,\n },\n};\n//# sourceMappingURL=search.js.map"]}
|
package/lib/types/ai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.js","sourceRoot":"/","sources":["types/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,MAAM,CAAN,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,wCAA4B,CAAA;IAC5B,gDAAoC,CAAA;IACpC,oEAAwD,CAAA;IACxD,8EAAkE,CAAA;IAClE,4EAAgE,CAAA;AAClE,CAAC,EANW,QAAQ,KAAR,QAAQ,QAMnB;AAED,MAAM,CAAN,IAAY,OAEX;AAFD,WAAY,OAAO;IACjB,oCAAyB,CAAA;AAC3B,CAAC,EAFW,OAAO,KAAP,OAAO,QAElB;AAED,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,oDAAiC,CAAA;IACjC,mDAAgC,CAAA;AAClC,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAyDD,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,GAA4D,EACxB,EAAE;IACtC,OAAO,GAAG,CAAC,IAAI,KAAK,oBAAoB,CAAC,OAAO,CAAC;AACnD,CAAC,CAAC","sourcesContent":["import { DocumentCategoryType } from './document-categories.js';\nimport { AdministrativeDocument, DocumentDraft, FinanceDocumentV2 } from './documents.js';\n\nexport enum LLMModel {\n gpt35Turbo = 'gpt-3.5-turbo',\n gpt4oMini = 'gpt-4o-mini-2024-07-18',\n anthropicClaudeInstantV1 = 'anthropic.claude-instant-v1',\n anthropicClaude3Sonnet = 'anthropic.claude-3-sonnet-20240229-v1:0',\n anthropicClaude3Haiku = 'anthropic.claude-3-haiku-20240307-v1:0',\n}\n\nexport enum OCRType {\n DocumentAI = 'documentai',\n}\n\nexport enum EmbeddingsModel {\n ada002 = 'text-embedding-ada-002',\n small = 'text-embedding-3-small',\n}\n\nexport type SummaryInvoiceData = {\n supplierName: string;\n supplierVATNumber: string;\n supplierISO2CountryCode: string;\n supplierEmail: string | null;\n\n clientVATNumber: string;\n clientName: string;\n clientId?: string | null;\n\n category?: string;\n\n totalAmountWithoutVAT: string | number;\n totalVatAmount: string | number;\n invoiceCurrency: string;\n\n invoiceDate: string;\n invoiceDueDate: string;\n invoiceNumber: string;\n\n lines: {\n id: string;\n productDescription: string;\n totalAmountWithoutVat: string | number;\n category?: string;\n }[];\n};\n\ntype BaseDocumentDraftPrefill = {\n id: string;\n createdAt: string;\n type: DocumentCategoryType;\n ocr: {\n provider: OCRType;\n };\n embeddings: {\n // not defined in the case of api failure but we continue the prefill process\n model?: EmbeddingsModel;\n };\n};\n\nexport type FinanceDocumentDraftPrefill = BaseDocumentDraftPrefill & {\n llm: {\n model: LLMModel;\n summary: SummaryInvoiceData;\n };\n draft: DocumentDraft<FinanceDocumentV2>;\n};\n\nexport type AdminDocumentDraftPrefill = BaseDocumentDraftPrefill & {\n draft: DocumentDraft<AdministrativeDocument>;\n};\n\nexport type DocumentDraftPrefill = FinanceDocumentDraftPrefill | AdminDocumentDraftPrefill;\n\nexport const isFinanceDocumentDraftPrefill = (\n doc: FinanceDocumentDraftPrefill | AdminDocumentDraftPrefill
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"/","sources":["types/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,MAAM,CAAN,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,wCAA4B,CAAA;IAC5B,gDAAoC,CAAA;IACpC,oEAAwD,CAAA;IACxD,8EAAkE,CAAA;IAClE,4EAAgE,CAAA;AAClE,CAAC,EANW,QAAQ,KAAR,QAAQ,QAMnB;AAED,MAAM,CAAN,IAAY,OAEX;AAFD,WAAY,OAAO;IACjB,oCAAyB,CAAA;AAC3B,CAAC,EAFW,OAAO,KAAP,OAAO,QAElB;AAED,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,oDAAiC,CAAA;IACjC,mDAAgC,CAAA;AAClC,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAyDD,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,GAA4D,EACxB,EAAE;IACtC,OAAO,GAAG,CAAC,IAAI,KAAK,oBAAoB,CAAC,OAAO,CAAC;AACnD,CAAC,CAAC","sourcesContent":["import { DocumentCategoryType } from './document-categories.js';\nimport { AdministrativeDocument, DocumentDraft, FinanceDocumentV2 } from './documents.js';\n\nexport enum LLMModel {\n gpt35Turbo = 'gpt-3.5-turbo',\n gpt4oMini = 'gpt-4o-mini-2024-07-18',\n anthropicClaudeInstantV1 = 'anthropic.claude-instant-v1',\n anthropicClaude3Sonnet = 'anthropic.claude-3-sonnet-20240229-v1:0',\n anthropicClaude3Haiku = 'anthropic.claude-3-haiku-20240307-v1:0',\n}\n\nexport enum OCRType {\n DocumentAI = 'documentai',\n}\n\nexport enum EmbeddingsModel {\n ada002 = 'text-embedding-ada-002',\n small = 'text-embedding-3-small',\n}\n\nexport type SummaryInvoiceData = {\n supplierName: string;\n supplierVATNumber: string;\n supplierISO2CountryCode: string;\n supplierEmail: string | null;\n\n clientVATNumber: string;\n clientName: string;\n clientId?: string | null;\n\n category?: string;\n\n totalAmountWithoutVAT: string | number;\n totalVatAmount: string | number;\n invoiceCurrency: string;\n\n invoiceDate: string;\n invoiceDueDate: string;\n invoiceNumber: string;\n\n lines: {\n id: string;\n productDescription: string;\n totalAmountWithoutVat: string | number;\n category?: string;\n }[];\n};\n\ntype BaseDocumentDraftPrefill = {\n id: string;\n createdAt: string;\n type: DocumentCategoryType;\n ocr: {\n provider: OCRType;\n };\n embeddings: {\n // not defined in the case of api failure but we continue the prefill process\n model?: EmbeddingsModel;\n };\n};\n\nexport type FinanceDocumentDraftPrefill = BaseDocumentDraftPrefill & {\n llm: {\n model: LLMModel;\n summary: SummaryInvoiceData;\n };\n draft: DocumentDraft<FinanceDocumentV2>;\n};\n\nexport type AdminDocumentDraftPrefill = BaseDocumentDraftPrefill & {\n draft: DocumentDraft<AdministrativeDocument>;\n};\n\nexport type DocumentDraftPrefill = FinanceDocumentDraftPrefill | AdminDocumentDraftPrefill;\n\nexport const isFinanceDocumentDraftPrefill = (\n doc: FinanceDocumentDraftPrefill | AdminDocumentDraftPrefill,\n): doc is FinanceDocumentDraftPrefill => {\n return doc.type === DocumentCategoryType.Finance;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.js","sourceRoot":"/","sources":["types/documents.ts"],"names":[],"mappings":"AAmEA,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,+CAA6B,CAAA;AAC/B,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAwFD,MAAM,CAAN,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,iDAA2B,CAAA;IAC3B,6CAAuB,CAAA;IACvB,qDAA+B,CAAA;IAC/B,yDAAmC,CAAA;IACnC,6CAAuB,CAAA;AACzB,CAAC,EAPW,kBAAkB,KAAlB,kBAAkB,QAO7B;AAED,MAAM,CAAN,IAAY,iBAOX;AAPD,WAAY,iBAAiB;IAC3B,kDAA6B,CAAA;IAC7B,8CAAyB,CAAA;IACzB,8DAAyC,CAAA;IACzC,kEAA6C,CAAA;IAC7C,0DAAqC,CAAA;IACrC,kCAAa,CAAA;AACf,CAAC,EAPW,iBAAiB,KAAjB,iBAAiB,QAO5B;AAsCD,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,4CAA4B,CAAA;IAC5B,0DAA0C,CAAA;AAC5C,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AA6BD,MAAM,CAAN,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,qCAAqB,CA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6B;IACvC,2FAA0D,CAAA;AAC5D,CAAC,EAFW,6BAA6B,KAA7B,6BAA6B,QAExC","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport { AttachmentValue, PhoneNumberValue } from '@bisondesk/commons-sdk/types';\nimport { BankAccountData } from './bank-accounts.js';\nimport { DocumentCategoryVisibility } from './document-categories.js';\nimport { FinanceDocumentV1 } from './legacy.js';\n\nexport type FinanceDocument = FinanceDocumentV1 | FinanceDocumentV2;\n\nexport type Association = {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n title: string;\n description: string;\n tags?: string[];\n linkTo?: {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n };\n};\n\nexport type FinanceDocumentLine = {\n id: string;\n category: string; // abstraction used to map lines to GL accounts (e.g., deposit, insurance)\n amount: string;\n amountExcl: string; // quantity * unit price\n description: string;\n foreign?: {\n amount: string;\n amountExcl: string;\n unitPriceExcl: string;\n vatAmount: string;\n };\n invoiceLineId?: string; // used by credit notes\n quantity: string;\n associations?: Association[];\n unitPriceExcl: string;\n vatAmount: string;\n vatCode: string;\n vatPercentage: string;\n vatReason?: string;\n\n costCenterId?: string; // optional override of the category's cost center\n externalId?: string; // id used by external systems (e.g., accounting integration)\n};\n\ntype OrgSummary = {\n id: string;\n code: number;\n name: string;\n vatNumber?: string;\n\n addressLine1?: string;\n addressLine2?: string;\n postcode?: string;\n city?: string;\n country: string;\n\n emails?: string[];\n phone?: PhoneNumberValue;\n\n // TODO person name?\n contact?: {\n name: string;\n username: string;\n };\n};\n\nexport enum FinanceDocType {\n Sale = 'Sale Finance',\n Purchase = 'Purchase Finance',\n}\n\ntype BaseDocument = {\n id: string;\n branchId: string;\n attachment: AttachmentValue;\n createdAt: string;\n createdBy: string;\n};\n\nexport type FinanceDocumentV2 = BaseDocument & {\n version: 2.0;\n language?: string;\n autoGenerated?: boolean;\n reference: string;\n subtype: FinanceDocumentSubtype;\n type: FinanceDocType;\n category: string;\n visibility?: DocumentCategoryVisibility;\n organizationSummary: OrgSummary;\n\n dueDate?: string;\n transferDescription?: string; // we ask clients to put this as description of the transfer\n invoiceId?: string; // mandatory in credit notes but optional in invoices on invoices represents a reissued invoice\n issueDate: string;\n lines: FinanceDocumentLine[];\n accountingLines?: FinanceDocumentLine[];\n notes?: string;\n salesperson?: {\n name: string;\n username: string;\n };\n tags: string[]; // optional values used to improve document search\n total: {\n amountExcl: string;\n amount: string;\n currencyCode: string; // from the branch\n foreign?: {\n amount: string;\n amountExcl: string;\n vatAmount: string;\n currencyCode: string;\n exchangeRate: string;\n };\n vatAmount: string;\n };\n\n paidAt?: string; // ONLY for when accounting integration is not used. Otherwise ALWAYS look at the Finance Booking paidAt\n\n reportingPeriod?: string;\n reportingYear?: string;\n accountingDescription?: string;\n\n // mostly for the case we want to regenerate the document pdf again\n bankAccounts?: BankAccountData[];\n\n externalQrCodeUrl?: string; // QR code data to be rendered on the document\n externalId?: string; // id used by external systems (e.g., accounting integration, storecove)\n\n peppol?: {\n extraAttachments?: AttachmentValue[];\n // per-line snapshot of what was sent to Peppol via Storecove; keyed by FinanceDocumentLine.id\n additionalItemProperties?: {\n lineId: string;\n properties: { name: string; value: string }[];\n }[];\n };\n};\n\nexport type NewFinanceDocumentV2 = Omit<\n FinanceDocumentV2,\n 'id' | 'createdAt' | 'createdBy' | 'lines'\n> & {\n lines: Omit<FinanceDocumentLine, 'id'>[];\n};\n\nexport type AdministrativeDocument = BaseDocument & {\n tags?: string[];\n category: string;\n associations?: Association[];\n displayName?: string;\n};\n\nexport type NewAdministrativeDocument = Omit<\n AdministrativeDocument,\n 'id' | 'createdAt' | 'createdBy'\n>;\n\nexport enum DraftProcessStatus {\n Prefill = 'Prefill',\n Unprocessed = 'Unprocessed',\n Processed = 'Processed',\n BusinessValid = 'BusinessValid',\n AccountingValid = 'AccountingValid',\n Completed = 'Completed',\n}\n\nexport enum DraftProcessStage {\n AIProcessing = 'aiProcessing',\n Processing = 'processing',\n BusinessValidation = 'businessValidation',\n AccountingValidation = 'accountingValidation',\n DocumentCreation = 'documentCreation',\n Edit = 'edit',\n}\n\nexport type ValidationRulesResult = {\n failed?: string[];\n passed?: string[];\n skipped?: string[];\n details?: Record<string, string[]>;\n};\n\nexport type DocumentValidationRulesResults = {\n [DraftProcessStatus.BusinessValid]: ValidationRulesResult | undefined;\n [DraftProcessStatus.AccountingValid]: ValidationRulesResult | undefined;\n};\n\nexport type NewDraftRemarks = {\n accounting?: string;\n business?: string;\n};\n\nexport type DraftRemarks = NewDraftRemarks & {\n at: string;\n by: string;\n};\n\ntype DraftProcessing = {\n status: DraftProcessStatus;\n documentType?: DocumentType;\n vatTotalCheck?: string;\n totalCheck?: string;\n rejectedAt?: string;\n rejectedBy?: string;\n rejectionReason?: string;\n lastCompletedAt?: string;\n\n validationRulesResult?: ValidationRulesResult;\n remarks?: DraftRemarks;\n};\n\nexport enum DocumentType {\n Finance = 'Finance Document',\n Administrative = 'Administrative Document',\n}\n\nexport type DocumentStatusLogEntry = {\n status: DraftProcessStatus;\n at: string;\n by: string;\n\n rejectionReason?: string;\n validationRulesResult?: ValidationRulesResult;\n};\n\nexport type DocumentStatusLogEntryWithDraft = DocumentStatusLogEntry & {\n draftData: DocumentDraft;\n};\n\ntype AssociationSuggestion = {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n};\n\ntype BaseDocumentDraft = (BaseDocument & DraftProcessing) & {\n associationSuggestions?: AssociationSuggestion[];\n};\n\nexport type DocumentDraft<T = FinanceDocumentV2 | AdministrativeDocument> = Partial<T> &\n BaseDocumentDraft;\n\nexport type DocumentDraftListMeta = { status: DraftProcessStatus; count: number }[];\n\nexport enum DraftActions {\n Delete = 'delete',\n Validate = 'validate',\n Reject = 'reject',\n SaveChanges = 'save_changes',\n Submit = 'submit',\n ValidateBusinessRules = 'validate_business_rules',\n ValidateAccountingRules = 'validate_accounting_rules',\n}\n\nexport type RejectDraftRequest = {\n reason?: string;\n};\n\nexport type NewDocumentDraft<T = NewFinanceDocumentV2 | NewAdministrativeDocument> = Partial<T> &\n Omit<BaseDocumentDraft, 'id' | 'createdAt' | 'createdBy' | 'subtype'> & {\n subtype?: string;\n documentType?: DocumentType;\n };\n\nexport const isFinanceDocumentV2 = (\n arg: FinanceDocumentV2 | FinanceDocumentV1\n): arg is FinanceDocumentV2 => {\n return (arg as FinanceDocumentV2).version == 2;\n};\n\nexport const isFinanceDocumentV1 = (\n arg: FinanceDocumentV2 | FinanceDocumentV1\n): arg is FinanceDocumentV1 => {\n return (arg as FinanceDocumentV2).version == null;\n};\n\nexport const isFinanceDocument = (\n arg: FinanceDocument | AdministrativeDocument | NewAdministrativeDocument | NewFinanceDocumentV2\n): arg is FinanceDocument => {\n return ['Sale Finance', 'Purchase Finance'].includes((arg as FinanceDocument).type);\n};\n\nexport const isAdministrativeDocumentDraft = (\n draft: DocumentDraft | NewDocumentDraft\n): draft is DocumentDraft<AdministrativeDocument> | NewDocumentDraft<AdministrativeDocument> =>\n draft.documentType === DocumentType.Administrative;\n\nexport const isFinanceDocumentDraft = (\n arg: DocumentDraft | NewDocumentDraft\n): arg is DocumentDraft<FinanceDocumentV2> | NewDocumentDraft<FinanceDocumentV2> => {\n return arg.documentType === DocumentType.Finance;\n};\n\nexport type NewFinanceDocumentLine = Omit<FinanceDocumentLine, 'id'>;\n\nexport type FinanceDocumentGenerateRequest = Omit<\n FinanceDocumentV2,\n | 'id'\n | 'attachment'\n | 'createdAt'\n | 'createdBy'\n | 'version'\n | 'reference'\n | 'lines'\n | 'accountingLines'\n> & {\n lines: NewFinanceDocumentLine[];\n accountingLines?: NewFinanceDocumentLine[];\n bankAccounts: BankAccountData[];\n\n relatedContract?: {\n contractId: string;\n period: number;\n };\n};\n\nexport type DocumentGenerateRequestEvent = {\n tenantId: string;\n userId: string;\n docId: string;\n request: FinanceDocumentGenerateRequest;\n};\n\nexport type GenerateFinanceDocumentResult = {\n docId: string;\n completedPartially?: boolean;\n};\n\nexport type FinanceDocumentGeneratePDFEvent = {\n tenantId: string;\n doc: FinanceDocumentV2;\n request: FinanceDocumentGenerateRequest;\n};\n\nexport type FinanceDocumentSettings<M = {}> = {\n provider: string;\n // whether the provider enforces credit notes to be linked to an invoice\n // lines. Eg can't change description of line values\n strictCreditNotes?: boolean;\n // whether the companies from the same country of the branch must provide\n // a vat number to generate sale finance documents\n mandatoryLocalOrganizationVatNumber?: boolean;\n meta: M;\n};\n\nexport type BisondeskMetaFinanceDocumentSettings = {\n [key in FinanceDocumentSubtype]: {\n templateId: string;\n };\n};\n\nexport type FinanceDocumentBisondeskSettings = {\n [FinanceDocumentSubtype.Invoice]: {\n prefix: string;\n templateId: string;\n };\n [FinanceDocumentSubtype.CreditNote]: {\n prefix: string;\n templateId: string;\n };\n};\n\nexport type FinanceDocumentPayment = {\n documentId: string;\n reference: string;\n attachment: AttachmentValue;\n} & ({ paid: true; paidAt: string } | { paid: false; paidAt?: undefined });\n\nexport enum FinanceDocumentSubtype {\n Invoice = 'Invoice',\n CreditNote = 'Credit Note',\n Proforma = 'Proforma',\n PurchaseOrder = 'Purchase Order',\n}\n\nexport enum FinanceDocumentActions {\n PAY_FINANCE_DOCUMENT = 'pay_finance_document',\n DELETE_FINANCE_DOCUMENT = 'delete_finance_document',\n}\n\nexport enum AdministrativeDocumentActions {\n DELETE_ADMINISTRATIVE_DOCUMENT = 'delete_finance_document',\n}\n\nexport type AdministrativeUpdateOperation =\n | {\n association?: undefined;\n doc: AdministrativeDocument;\n op: 'replace';\n }\n | {\n association?: undefined;\n doc: NewAdministrativeDocument;\n op: 'add';\n }\n | {\n association: {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n documentId: string;\n };\n doc?: undefined;\n op: 'remove-association';\n };\n"]}
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"/","sources":["types/documents.ts"],"names":[],"mappings":"AAmEA,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,+CAA6B,CAAA;AAC/B,CAAC,EAHW,cAAc,K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,CAAE,GAAuB,CAAC,IAAI,CAAC,CAAC;AACtF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,KAAuC,EACoD,EAAE,CAC7F,KAAK,CAAC,YAAY,KAAK,YAAY,CAAC,cAAc,CAAC;AAErD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,GAAqC,EAC0C,EAAE;IACjF,OAAO,GAAG,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO,CAAC;AACnD,CAAC,CAAC;AA6EF,MAAM,CAAN,IAAY,sBAKX;AALD,WAAY,sBAAsB;IAChC,6CAAmB,CAAA;IACnB,oDAA0B,CAAA;IAC1B,+CAAqB,CAAA;IACrB,0DAAgC,CAAA;AAClC,CAAC,EALW,sBAAsB,KAAtB,sBAAsB,QAKjC;AAED,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,uEAA6C,CAAA;IAC7C,6EAAmD,CAAA;AACrD,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAED,MAAM,CAAN,IAAY,6BAEX;AAFD,WAAY,6BAA6B;IACvC,2FAA0D,CAAA;AAC5D,CAAC,EAFW,6BAA6B,KAA7B,6BAA6B,QAExC","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport { AttachmentValue, PhoneNumberValue } from '@bisondesk/commons-sdk/types';\nimport { BankAccountData } from './bank-accounts.js';\nimport { DocumentCategoryVisibility } from './document-categories.js';\nimport { FinanceDocumentV1 } from './legacy.js';\n\nexport type FinanceDocument = FinanceDocumentV1 | FinanceDocumentV2;\n\nexport type Association = {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n title: string;\n description: string;\n tags?: string[];\n linkTo?: {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n };\n};\n\nexport type FinanceDocumentLine = {\n id: string;\n category: string; // abstraction used to map lines to GL accounts (e.g., deposit, insurance)\n amount: string;\n amountExcl: string; // quantity * unit price\n description: string;\n foreign?: {\n amount: string;\n amountExcl: string;\n unitPriceExcl: string;\n vatAmount: string;\n };\n invoiceLineId?: string; // used by credit notes\n quantity: string;\n associations?: Association[];\n unitPriceExcl: string;\n vatAmount: string;\n vatCode: string;\n vatPercentage: string;\n vatReason?: string;\n\n costCenterId?: string; // optional override of the category's cost center\n externalId?: string; // id used by external systems (e.g., accounting integration)\n};\n\ntype OrgSummary = {\n id: string;\n code: number;\n name: string;\n vatNumber?: string;\n\n addressLine1?: string;\n addressLine2?: string;\n postcode?: string;\n city?: string;\n country: string;\n\n emails?: string[];\n phone?: PhoneNumberValue;\n\n // TODO person name?\n contact?: {\n name: string;\n username: string;\n };\n};\n\nexport enum FinanceDocType {\n Sale = 'Sale Finance',\n Purchase = 'Purchase Finance',\n}\n\ntype BaseDocument = {\n id: string;\n branchId: string;\n attachment: AttachmentValue;\n createdAt: string;\n createdBy: string;\n};\n\nexport type FinanceDocumentV2 = BaseDocument & {\n version: 2.0;\n language?: string;\n autoGenerated?: boolean;\n reference: string;\n subtype: FinanceDocumentSubtype;\n type: FinanceDocType;\n category: string;\n visibility?: DocumentCategoryVisibility;\n organizationSummary: OrgSummary;\n\n dueDate?: string;\n transferDescription?: string; // we ask clients to put this as description of the transfer\n invoiceId?: string; // mandatory in credit notes but optional in invoices on invoices represents a reissued invoice\n issueDate: string;\n lines: FinanceDocumentLine[];\n accountingLines?: FinanceDocumentLine[];\n notes?: string;\n salesperson?: {\n name: string;\n username: string;\n };\n tags: string[]; // optional values used to improve document search\n total: {\n amountExcl: string;\n amount: string;\n currencyCode: string; // from the branch\n foreign?: {\n amount: string;\n amountExcl: string;\n vatAmount: string;\n currencyCode: string;\n exchangeRate: string;\n };\n vatAmount: string;\n };\n\n paidAt?: string; // ONLY for when accounting integration is not used. Otherwise ALWAYS look at the Finance Booking paidAt\n\n reportingPeriod?: string;\n reportingYear?: string;\n accountingDescription?: string;\n\n // mostly for the case we want to regenerate the document pdf again\n bankAccounts?: BankAccountData[];\n\n externalQrCodeUrl?: string; // QR code data to be rendered on the document\n externalId?: string; // id used by external systems (e.g., accounting integration, storecove)\n\n peppol?: {\n extraAttachments?: AttachmentValue[];\n // per-line snapshot of what was sent to Peppol via Storecove; keyed by FinanceDocumentLine.id\n additionalItemProperties?: {\n lineId: string;\n properties: { name: string; value: string }[];\n }[];\n };\n};\n\nexport type NewFinanceDocumentV2 = Omit<\n FinanceDocumentV2,\n 'id' | 'createdAt' | 'createdBy' | 'lines'\n> & {\n lines: Omit<FinanceDocumentLine, 'id'>[];\n};\n\nexport type AdministrativeDocument = BaseDocument & {\n tags?: string[];\n category: string;\n associations?: Association[];\n displayName?: string;\n};\n\nexport type NewAdministrativeDocument = Omit<\n AdministrativeDocument,\n 'id' | 'createdAt' | 'createdBy'\n>;\n\nexport enum DraftProcessStatus {\n Prefill = 'Prefill',\n Unprocessed = 'Unprocessed',\n Processed = 'Processed',\n BusinessValid = 'BusinessValid',\n AccountingValid = 'AccountingValid',\n Completed = 'Completed',\n}\n\nexport enum DraftProcessStage {\n AIProcessing = 'aiProcessing',\n Processing = 'processing',\n BusinessValidation = 'businessValidation',\n AccountingValidation = 'accountingValidation',\n DocumentCreation = 'documentCreation',\n Edit = 'edit',\n}\n\nexport type ValidationRulesResult = {\n failed?: string[];\n passed?: string[];\n skipped?: string[];\n details?: Record<string, string[]>;\n};\n\nexport type DocumentValidationRulesResults = {\n [DraftProcessStatus.BusinessValid]: ValidationRulesResult | undefined;\n [DraftProcessStatus.AccountingValid]: ValidationRulesResult | undefined;\n};\n\nexport type NewDraftRemarks = {\n accounting?: string;\n business?: string;\n};\n\nexport type DraftRemarks = NewDraftRemarks & {\n at: string;\n by: string;\n};\n\ntype DraftProcessing = {\n status: DraftProcessStatus;\n documentType?: DocumentType;\n vatTotalCheck?: string;\n totalCheck?: string;\n rejectedAt?: string;\n rejectedBy?: string;\n rejectionReason?: string;\n lastCompletedAt?: string;\n\n validationRulesResult?: ValidationRulesResult;\n remarks?: DraftRemarks;\n};\n\nexport enum DocumentType {\n Finance = 'Finance Document',\n Administrative = 'Administrative Document',\n}\n\nexport type DocumentStatusLogEntry = {\n status: DraftProcessStatus;\n at: string;\n by: string;\n\n rejectionReason?: string;\n validationRulesResult?: ValidationRulesResult;\n};\n\nexport type DocumentStatusLogEntryWithDraft = DocumentStatusLogEntry & {\n draftData: DocumentDraft;\n};\n\ntype AssociationSuggestion = {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n};\n\ntype BaseDocumentDraft = (BaseDocument & DraftProcessing) & {\n associationSuggestions?: AssociationSuggestion[];\n};\n\nexport type DocumentDraft<T = FinanceDocumentV2 | AdministrativeDocument> = Partial<T> &\n BaseDocumentDraft;\n\nexport type DocumentDraftListMeta = { status: DraftProcessStatus; count: number }[];\n\nexport enum DraftActions {\n Delete = 'delete',\n Validate = 'validate',\n Reject = 'reject',\n SaveChanges = 'save_changes',\n Submit = 'submit',\n ValidateBusinessRules = 'validate_business_rules',\n ValidateAccountingRules = 'validate_accounting_rules',\n}\n\nexport type RejectDraftRequest = {\n reason?: string;\n};\n\nexport type NewDocumentDraft<T = NewFinanceDocumentV2 | NewAdministrativeDocument> = Partial<T> &\n Omit<BaseDocumentDraft, 'id' | 'createdAt' | 'createdBy' | 'subtype'> & {\n subtype?: string;\n documentType?: DocumentType;\n };\n\nexport const isFinanceDocumentV2 = (\n arg: FinanceDocumentV2 | FinanceDocumentV1,\n): arg is FinanceDocumentV2 => {\n return (arg as FinanceDocumentV2).version == 2;\n};\n\nexport const isFinanceDocumentV1 = (\n arg: FinanceDocumentV2 | FinanceDocumentV1,\n): arg is FinanceDocumentV1 => {\n return (arg as FinanceDocumentV2).version == null;\n};\n\nexport const isFinanceDocument = (\n arg: FinanceDocument | AdministrativeDocument | NewAdministrativeDocument | NewFinanceDocumentV2,\n): arg is FinanceDocument => {\n return ['Sale Finance', 'Purchase Finance'].includes((arg as FinanceDocument).type);\n};\n\nexport const isAdministrativeDocumentDraft = (\n draft: DocumentDraft | NewDocumentDraft,\n): draft is DocumentDraft<AdministrativeDocument> | NewDocumentDraft<AdministrativeDocument> =>\n draft.documentType === DocumentType.Administrative;\n\nexport const isFinanceDocumentDraft = (\n arg: DocumentDraft | NewDocumentDraft,\n): arg is DocumentDraft<FinanceDocumentV2> | NewDocumentDraft<FinanceDocumentV2> => {\n return arg.documentType === DocumentType.Finance;\n};\n\nexport type NewFinanceDocumentLine = Omit<FinanceDocumentLine, 'id'>;\n\nexport type FinanceDocumentGenerateRequest = Omit<\n FinanceDocumentV2,\n | 'id'\n | 'attachment'\n | 'createdAt'\n | 'createdBy'\n | 'version'\n | 'reference'\n | 'lines'\n | 'accountingLines'\n> & {\n lines: NewFinanceDocumentLine[];\n accountingLines?: NewFinanceDocumentLine[];\n bankAccounts: BankAccountData[];\n\n relatedContract?: {\n contractId: string;\n period: number;\n };\n};\n\nexport type DocumentGenerateRequestEvent = {\n tenantId: string;\n userId: string;\n docId: string;\n request: FinanceDocumentGenerateRequest;\n};\n\nexport type GenerateFinanceDocumentResult = {\n docId: string;\n completedPartially?: boolean;\n};\n\nexport type FinanceDocumentGeneratePDFEvent = {\n tenantId: string;\n doc: FinanceDocumentV2;\n request: FinanceDocumentGenerateRequest;\n};\n\nexport type FinanceDocumentSettings<M = {}> = {\n provider: string;\n // whether the provider enforces credit notes to be linked to an invoice\n // lines. Eg can't change description of line values\n strictCreditNotes?: boolean;\n // whether the companies from the same country of the branch must provide\n // a vat number to generate sale finance documents\n mandatoryLocalOrganizationVatNumber?: boolean;\n meta: M;\n};\n\nexport type BisondeskMetaFinanceDocumentSettings = {\n [key in FinanceDocumentSubtype]: {\n templateId: string;\n };\n};\n\nexport type FinanceDocumentBisondeskSettings = {\n [FinanceDocumentSubtype.Invoice]: {\n prefix: string;\n templateId: string;\n };\n [FinanceDocumentSubtype.CreditNote]: {\n prefix: string;\n templateId: string;\n };\n};\n\nexport type FinanceDocumentPayment = {\n documentId: string;\n reference: string;\n attachment: AttachmentValue;\n} & ({ paid: true; paidAt: string } | { paid: false; paidAt?: undefined });\n\nexport enum FinanceDocumentSubtype {\n Invoice = 'Invoice',\n CreditNote = 'Credit Note',\n Proforma = 'Proforma',\n PurchaseOrder = 'Purchase Order',\n}\n\nexport enum FinanceDocumentActions {\n PAY_FINANCE_DOCUMENT = 'pay_finance_document',\n DELETE_FINANCE_DOCUMENT = 'delete_finance_document',\n}\n\nexport enum AdministrativeDocumentActions {\n DELETE_ADMINISTRATIVE_DOCUMENT = 'delete_finance_document',\n}\n\nexport type AdministrativeUpdateOperation =\n | {\n association?: undefined;\n doc: AdministrativeDocument;\n op: 'replace';\n }\n | {\n association?: undefined;\n doc: NewAdministrativeDocument;\n op: 'add';\n }\n | {\n association: {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n documentId: string;\n };\n doc?: undefined;\n op: 'remove-association';\n };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"associations.js","sourceRoot":"/","sources":["utils/associations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAGL,+BAA+B,EAC/B,qCAAqC,EACrC,6BAA6B,EAC7B,wBAAwB,EACxB,8BAA8B,EAC9B,yBAAyB,EACzB,+BAA+B,GAChC,MAAM,kCAAkC,CAAC;AAK1C,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,gBAAmC,EACnC,MAAkC,EACrB,EAAE,CAAC,CAAC;IACjB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC,EAAE;IACnB,KAAK,EAAE,yBAAyB,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAC1D,WAAW,EAAE,+BAA+B,CAAC,gBAAgB,EAAE,MAAM,CAAC;IACtE,IAAI,EAAE,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACzD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qCAAqC,GAAG,CACnD,gBAAmC,EACnC,MAA0B,EACb,EAAE;IACf,MAAM,MAAM,GAAG,6BAA6B,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACvE,OAAO;QACL,gBAAgB;QAChB,QAAQ,EAAE,MAAM,CAAC,EAAE;QACnB,KAAK,EAAE,+BAA+B,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAChE,WAAW,EAAE,qCAAqC,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAC5E,IAAI,EAAE,8BAA8B,CAAC,gBAAgB,EAAE,MAAM,CAAC;KAC/D,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC/C,OAAgB,EAChB,cAAsB,EACT,EAAE,CAAC,CAAC;IACjB,GAAG,+BAA+B,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC;IACvE,gBAAgB,EAAE,iBAAiB,CAAC,mBAAmB;IACvD,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE;QACN,gBAAgB,EAAE,iBAAiB,CAAC,QAAQ;QAC5C,QAAQ,EAAE,OAAO,CAAC,EAAE;KACrB;CACF,CAAC,CAAC","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport { Vehicle } from '@bisondesk/core-sdk/types/vehicles';\nimport {\n GlobalBusinessEntity,\n GlobalSearchEntity,\n getDescriptionForBusinessEntity,\n getDescriptionForSearchBusinessEntity,\n getMainEntityFromSearchEntity,\n getTagsForBusinessEntity,\n getTagsForSearchBusinessEntity,\n getTitleForBusinessEntity,\n getTitleForSearchBusinessEntity,\n} from '@bisondesk/core-sdk/utils/search';\nimport { Association } from '../types/documents.js';\n\nexport type SupportedAssociationEntity = GlobalBusinessEntity;\n\nexport const getAssociationForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n record: SupportedAssociationEntity
|
|
1
|
+
{"version":3,"file":"associations.js","sourceRoot":"/","sources":["utils/associations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAA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AAC","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport { Vehicle } from '@bisondesk/core-sdk/types/vehicles';\nimport {\n GlobalBusinessEntity,\n GlobalSearchEntity,\n getDescriptionForBusinessEntity,\n getDescriptionForSearchBusinessEntity,\n getMainEntityFromSearchEntity,\n getTagsForBusinessEntity,\n getTagsForSearchBusinessEntity,\n getTitleForBusinessEntity,\n getTitleForSearchBusinessEntity,\n} from '@bisondesk/core-sdk/utils/search';\nimport { Association } from '../types/documents.js';\n\nexport type SupportedAssociationEntity = GlobalBusinessEntity;\n\nexport const getAssociationForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n record: SupportedAssociationEntity,\n): Association => ({\n businessEntityId,\n recordId: record.id,\n title: getTitleForBusinessEntity(businessEntityId, record),\n description: getDescriptionForBusinessEntity(businessEntityId, record),\n tags: getTagsForBusinessEntity(businessEntityId, record),\n});\n\nexport const getAssociationForSearchBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n entity: GlobalSearchEntity,\n): Association => {\n const record = getMainEntityFromSearchEntity(businessEntityId, entity);\n return {\n businessEntityId,\n recordId: record.id,\n title: getTitleForSearchBusinessEntity(businessEntityId, entity),\n description: getDescriptionForSearchBusinessEntity(businessEntityId, entity),\n tags: getTagsForSearchBusinessEntity(businessEntityId, entity),\n };\n};\n\nexport const getExternalVehicleSaleAssociation = (\n vehicle: Vehicle,\n externalSaleId: string,\n): Association => ({\n ...getAssociationForBusinessEntity(BusinessEntityIds.Vehicles, vehicle),\n businessEntityId: BusinessEntityIds.ExternalVehicleSale,\n recordId: externalSaleId,\n linkTo: {\n businessEntityId: BusinessEntityIds.Vehicles,\n recordId: vehicle.id,\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finance-legacy.d.ts","sourceRoot":"/","sources":["utils/finance-legacy.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"finance-legacy.d.ts","sourceRoot":"/","sources":["utils/finance-legacy.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAmC,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAIhG,MAAM,MAAM,iBAAiB,GAAG,sBAAsB,GAAG;IACvD,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,KAAK,WAAW,GAAG,mBAAmB,GAAG,aAAa,CAAC;AAmDvD,eAAO,MAAM,cAAc,GACzB,SAAS,sBAAsB,EAC/B,MAAM,WAAW,EACjB,WAAU,OAAO,EAAO,KACvB,iBAIF,CAAC;AAMF,eAAO,MAAM,yBAAyB,GAAI,OAAO,iBAAiB,EAAE,KAAG,MAAM,EAWzD,CAAC;AAMrB,eAAO,MAAM,0BAA0B,GAAI,CAAC,SAAS,iBAAiB,EACpE,OAAO,CAAC,EAAE,EACV,YAAY,GAAG,CAAC,MAAM,EAAE,0BAA0B,CAAC,KAClD,CAAC,EA0BC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finance-legacy.js","sourceRoot":"/","sources":["utils/finance-legacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"finance-legacy.js","sourceRoot":"/","sources":["utils/finance-legacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAOrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D,OAAO,EAAE,+BAA+B,EAA8B,MAAM,mBAAmB,CAAC;AACh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":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport {\n Association,\n FinanceDocumentLine,\n FinanceDocumentSubtype,\n NewFinanceDocumentLine,\n} from '../types/documents.js';\nimport { LeasingFinanceLineCode } from '../types/leasing.js';\nimport { FinanceLineV1 } from '../types/legacy.js';\nimport { VatCode } from '../types/vat.js';\nimport { getAssociationForBusinessEntity, SupportedAssociationEntity } from './associations.js';\nimport { getLineAmounts } from './finance.js';\nimport { getAccountingCodeForV1VatCode, getVatCodeLineData } from './vat.js';\n\nexport type MappedFinanceLine = NewFinanceDocumentLine & {\n invoiceLineId: string;\n};\n\ntype FinanceLine = FinanceDocumentLine | FinanceLineV1;\n\nconst isV1Line = (line: FinanceLine): line is FinanceLineV1 => 'lineCode' in line;\n\nconst hasValidLeasingLineCode = (code: string) =>\n Object.values(LeasingFinanceLineCode).includes(code as LeasingFinanceLineCode);\n\nconst mapFinanceDocumentLineToMappedLine = (\n subtype: FinanceDocumentSubtype,\n line: FinanceDocumentLine,\n vatCodes: VatCode[] = [],\n): MappedFinanceLine => {\n const vatCode = vatCodes.find((c) => c.code === line.vatCode);\n const vatData = getVatCodeLineData(subtype, vatCode);\n return {\n ...line,\n ...vatData,\n ...getLineAmounts(line.unitPriceExcl, line.quantity, vatData.vatPercentage),\n invoiceLineId: line.id,\n category: line.category ?? '',\n };\n};\n\nconst mapFinanceLineV1ToMappedLine = (\n subtype: FinanceDocumentSubtype,\n line: FinanceLineV1,\n vatCodes: VatCode[],\n): MappedFinanceLine => {\n const v2Code = getAccountingCodeForV1VatCode(line.vatCode);\n const vatCode = vatCodes.find((c) => c.code === v2Code);\n const vatData = getVatCodeLineData(subtype, vatCode);\n return {\n ...vatData,\n ...getLineAmounts(line.unitPriceExclusive, line.quantity, vatData.vatPercentage),\n invoiceLineId: line.id,\n description: line.description,\n quantity: line.quantity,\n category: hasValidLeasingLineCode(line.lineCode) ? line.lineCode : '',\n associations: line.associations.sales.map<Association>((sale) => ({\n businessEntityId: BusinessEntityIds.ExternalVehicleSale,\n recordId: sale.id,\n title: sale.label,\n description: sale.label,\n linkTo: {\n businessEntityId: BusinessEntityIds.Vehicles,\n recordId: sale.vehicleId,\n },\n })),\n };\n};\n\nexport const mapFinanceLine = (\n subtype: FinanceDocumentSubtype,\n line: FinanceLine,\n vatCodes: VatCode[] = [],\n): MappedFinanceLine => {\n return isV1Line(line)\n ? mapFinanceLineV1ToMappedLine(subtype, line, vatCodes)\n : mapFinanceDocumentLineToMappedLine(subtype, line, vatCodes);\n};\n\n/**\n * Returns the vehicle IDs that need to be fetched to enrich ExternalVehicleSale\n * associations that are missing tags (produced by V1 line mapping).\n */\nexport const getExternalSaleVehicleIds = (lines: MappedFinanceLine[]): string[] =>\n lines.reduce((acc, line) => {\n return [\n ...acc,\n ...(line.associations\n ?.filter(\n ({ businessEntityId, tags }) =>\n BusinessEntityIds.ExternalVehicleSale === businessEntityId && tags == null,\n )\n .map(({ recordId, linkTo }) => linkTo?.recordId ?? recordId) ?? []),\n ];\n }, [] as string[]);\n\n/**\n * Patches ExternalVehicleSale associations that are missing tags with the vehicle's\n * title, description and tags fetched via `vehicleMap`.\n */\nexport const enrichLinesWithVehicleTags = <T extends MappedFinanceLine>(\n lines: T[],\n vehicleMap: Map<string, SupportedAssociationEntity>,\n): T[] =>\n lines.map((line) => ({\n ...line,\n associations: line.associations?.map((association) => {\n if (\n association.businessEntityId !== BusinessEntityIds.ExternalVehicleSale ||\n association.tags != null\n ) {\n return association;\n }\n const vehicleId = association.linkTo?.recordId ?? association.recordId;\n const vehicle = vehicleMap.get(vehicleId);\n if (!vehicle) {\n return association;\n }\n const vehicleAssociation = getAssociationForBusinessEntity(\n BusinessEntityIds.Vehicles,\n vehicle,\n );\n return {\n ...association,\n title: vehicleAssociation.title,\n description: vehicleAssociation.description,\n tags: vehicleAssociation.tags,\n };\n }),\n }));\n"]}
|
package/lib/utils/finance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finance.js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undMoney } from '@bisondesk/commons-sdk/money';\nimport { Decimal } from 'decimal.js';\nimport { uniqBy } from 'lodash-es';\nimport { GENERATING_PLACEHOLDER_ATTACHMENT } from '../constants/index.js';\nimport {\n Association,\n DocumentDraft,\n FinanceDocument,\n FinanceDocumentGenerateRequest,\n FinanceDocumentLine,\n FinanceDocumentSubtype,\n FinanceDocumentV2,\n isFinanceDocumentDraft,\n isFinanceDocumentV1,\n isFinanceDocumentV2,\n NewDocumentDraft,\n} from '../types/documents.js';\nimport { FinanceDocumentV1, FinanceLineV1 } from '../types/legacy.js';\n\nexport const documentGoesToAccounting = (\n doc:\n | FinanceDocumentV2\n | DocumentDraft<FinanceDocumentV2>\n | FinanceDocumentGenerateRequest\n | FinanceDocumentV1\n): boolean => {\n return (\n !!doc.subtype &&\n [FinanceDocumentSubtype.Invoice, FinanceDocumentSubtype.CreditNote].includes(\n doc.subtype as FinanceDocumentSubtype\n )\n );\n};\n\nexport const documentGoesToStorecove = (\n doc:\n | FinanceDocumentV2\n | DocumentDraft<FinanceDocumentV2>\n | FinanceDocumentGenerateRequest\n | FinanceDocumentV1\n): boolean => {\n if (!doc.organizationSummary) {\n return false;\n }\n const vatNumber = doc.organizationSummary.vatNumber;\n const isBeCountry = doc.organizationSummary.country === 'be';\n const isBEVAT = (isBeCountry && vatNumber?.toLowerCase().startsWith('be')) || false;\n return isBEVAT && documentGoesToAccounting(doc);\n};\n\nexport const getAccountingDescription = (doc: FinanceDocumentV2): string => {\n if (!!doc.accountingDescription) {\n return doc.accountingDescription;\n }\n\n const associations = doc.lines\n ?.flatMap((line) => line.associations ?? [])\n .filter(Boolean) as Association[];\n\n // In the UI the user can only select one vehicle associations\n const equivalentEntityIds = {\n [BusinessEntityIds.ExternalVehicleSale]: BusinessEntityIds.Vehicles,\n };\n\n const uniqueAssociations = uniqBy(\n associations,\n (a) => `${equivalentEntityIds[a.businessEntityId] ?? a.businessEntityId}_${a.recordId}`\n );\n\n if (uniqueAssociations.length !== 1) {\n return doc.reference;\n }\n\n const firstAssociation = associations[0];\n if (\n [\n BusinessEntityIds.Vehicles,\n BusinessEntityIds.Opportunities,\n BusinessEntityIds.ExternalVehicleSale,\n ].includes(firstAssociation.businessEntityId) &&\n firstAssociation.tags != null\n ) {\n return `${firstAssociation.tags?.slice(0, 3).join(' ')} ${doc.reference}`.trim();\n }\n\n return doc.reference;\n};\n\nexport const getTotalExcl = <T extends FinanceDocument['lines']>(\n lines: T,\n unitPrice: (line: T[0], index: number) => any\n) => {\n return lines.length === 0\n ? new Decimal(0)\n : Decimal.sum(...lines.map((line, i) => Decimal.mul(line.quantity, unitPrice(line, i))));\n};\n\nexport const getTotalVat = <T extends FinanceDocument['lines'], L = T[0]>(\n currency: string,\n lines: T,\n unitPrice: (doc: L, index: number) => any,\n vatCoefficient: (doc: L, index: number) => any\n) => {\n return lines.length === 0\n ? new Decimal(0)\n : roundMoney(\n currency,\n Decimal.sum(\n ...lines.map((line, i) =>\n Decimal.mul(line.quantity, unitPrice(line, i)).mul(vatCoefficient(line, i))\n )\n )\n );\n};\n\nexport const getDocumentTotals = (\n doc:\n | FinanceDocument\n | DocumentDraft<FinanceDocumentV2>\n | NewDocumentDraft<FinanceDocumentV2>\n | FinanceDocumentGenerateRequest\n) => {\n let totalVat: Decimal;\n let totalExcl: Decimal;\n\n if (isFinanceDocumentV1(doc as FinanceDocumentV1)) {\n const v1Currency = 'EUR';\n const lines = (doc as FinanceDocumentV1).lines;\n const getUnitPriceExclusive = (line: FinanceLineV1) => line.unitPriceExclusive;\n\n totalVat = getTotalVat(v1Currency, lines, getUnitPriceExclusive, (line) => line.vatCoefficient);\n totalExcl = getTotalExcl(lines, getUnitPriceExclusive);\n } else {\n const docCurrency = (doc as FinanceDocumentV2)?.total?.currencyCode; // careful with this cast, misleading\n const currency = docCurrency ?? 'EUR';\n const lines = (doc as FinanceDocumentV2).lines ?? [];\n const getUnitPriceExcl = (line: FinanceDocumentLine) => line.unitPriceExcl;\n\n totalVat = getTotalVat(currency, lines, getUnitPriceExcl, (line) =>\n new Decimal(line.vatPercentage).div(100)\n );\n totalExcl = getTotalExcl(lines, getUnitPriceExcl);\n }\n\n return {\n totalExcl,\n totalVat,\n subTotal: totalExcl.add(totalVat),\n };\n};\n\nexport const getRoundedDocumentTotal = (\n doc:\n | FinanceDocument\n | DocumentDraft<FinanceDocumentV2>\n | NewDocumentDraft<FinanceDocumentV2>\n | FinanceDocumentGenerateRequest\n) => {\n let total: FinanceDocumentV2['total'] | undefined;\n\n if (isFinanceDocumentV2(doc as FinanceDocument) || isFinanceDocumentDraft(doc as DocumentDraft)) {\n total = (doc as FinanceDocumentV2 | DocumentDraft<FinanceDocumentV2>).total;\n }\n\n const currencyCode = total?.currencyCode ?? 'EUR';\n const foreignCurrency = total?.foreign;\n\n const { subTotal, totalExcl, totalVat } = getDocumentTotals(doc);\n const rate = foreignCurrency?.exchangeRate ?? '1';\n const subTotalForeign = subTotal.div(rate).toString();\n const totalExclForeign = totalExcl.div(rate).toString();\n const totalVatForeign = totalVat.div(rate).toString();\n\n return {\n amount: roundMoney(currencyCode, subTotal).toString(),\n amountExcl: roundMoney(currencyCode, totalExcl).toString(),\n vatAmount: roundMoney(currencyCode, totalVat).toString(),\n currencyCode: currencyCode,\n foreign: foreignCurrency\n ? {\n amount: roundMoney(foreignCurrency.currencyCode, subTotalForeign).toString(),\n amountExcl: roundMoney(foreignCurrency.currencyCode, totalExclForeign).toString(),\n vatAmount: roundMoney(foreignCurrency.currencyCode, totalVatForeign).toString(),\n currencyCode: foreignCurrency.currencyCode,\n exchangeRate: foreignCurrency.exchangeRate,\n }\n : undefined,\n };\n};\n\nexport const getRoundedLinesTotals = (\n currency: string,\n lines: { quantity: string; unitPriceExcl: string; vatPercentage: string }[],\n rate = '1'\n) => {\n let totalWithoutVat = new Decimal('0');\n let vatTotal = new Decimal('0');\n for (const line of lines) {\n const lineTotal = new Decimal(line.unitPriceExcl).times(new Decimal(line.quantity));\n totalWithoutVat = totalWithoutVat.add(lineTotal);\n vatTotal = vatTotal.add(lineTotal.mul(line.vatPercentage).div(100));\n }\n\n totalWithoutVat = totalWithoutVat.div(rate);\n vatTotal = vatTotal.div(rate);\n\n return {\n totalWithoutVat: roundMoney(currency, totalWithoutVat),\n vatTotal: roundMoney(currency, vatTotal),\n total: roundMoney(currency, vatTotal.add(totalWithoutVat)),\n };\n};\n\nconst getAmountExcl = (unitPriceExcl: string, quantity: string) =>\n new Decimal(unitPriceExcl).times(new Decimal(quantity));\n\nexport const getLineAmounts = (unitPriceExcl: string, quantity: string, vatRate: string) => {\n const amountExcl = getAmountExcl(unitPriceExcl, quantity);\n const vatAmount = new Decimal(quantity)\n .times(new Decimal(unitPriceExcl))\n .times(new Decimal(vatRate).div(100));\n\n return {\n amount: amountExcl.add(vatAmount).toString(),\n amountExcl: amountExcl.toString(),\n unitPriceExcl,\n vatAmount: vatAmount.toString(),\n };\n};\n\nexport const isGeneratingAttachment = (doc: FinanceDocument) =>\n doc.attachment.id === GENERATING_PLACEHOLDER_ATTACHMENT.id;\n\n// returns a new finance document where\n// - all lines are filtered by the recordId\n// - the unit price is divided by the number of associations\nexport const filterDocumentLinesForRecord = (\n doc: FinanceDocument,\n recordId: string // vehicleId, opportunityId, or externalVehicleSaleId\n): FinanceDocument => {\n const filteredLines = isFinanceDocumentV2(doc)\n ? doc.lines\n .filter((line) =>\n line.associations?.some(\n (assoc) => assoc.recordId === recordId || assoc.linkTo?.recordId === recordId\n )\n )\n .map((line) => ({\n ...line,\n amount: calculateDistributedPrice(line.amount, line.associations?.length || 1),\n amountExcl: calculateDistributedPrice(line.amountExcl, line.associations?.length || 1),\n unitPriceExcl: calculateDistributedPrice(\n line.unitPriceExcl,\n line.associations?.length || 1\n ),\n }))\n : doc.lines\n .filter((line) =>\n getAllV1Associations(line.associations).some((assoc) => {\n const v1Ass = assoc as FinanceLineV1['associations']['sales'][0];\n return (\n assoc.vehicleId === recordId ||\n v1Ass.opportunityId === recordId ||\n v1Ass.id === recordId\n );\n })\n )\n .map((line) => ({\n ...line,\n unitPriceExclusive: calculateDistributedPrice(\n line.unitPriceExclusive,\n getAllV1Associations(line.associations).length || 1\n ),\n }));\n\n return {\n ...doc,\n lines: filteredLines,\n } as FinanceDocument;\n};\n\nconst calculateDistributedPrice = (price: string, count: number): string => {\n return new Decimal(price).div(Math.max(1, count)).toString();\n};\n\nconst getAllV1Associations = (ass: FinanceLineV1['associations']) => {\n const allAss = uniqBy(\n [...(ass?.sales ?? []), ...(ass?.purchases ?? []), ...(ass.others ?? [])],\n (ass) => ass.vehicleId\n );\n return allAss;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"finance.js","sourceRoot":"/","sources":["utils/finance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAML,sBAAsB,EAEtB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,uBAAuB,CAAC;AAG/B,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,GAIqB,EACZ,EAAE;IACX,OAAO,CACL,CAAC,CAAC,GAAG,CAAC,OAAO;QACb,CAAC,sBAAsB,CAAC,OAAO,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC,QAAQ,CAC1E,GAAG,CAAC,OAAiC,CACtC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,GAIqB,EACZ,EAAE;IACX,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,SAAS,GAAG,GAAG,CAAC,mBAAm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GAAG,CAAC,GAAkC,EAAE,EAAE;IAClE,MAAM,MAAM,GAAG,MAAM,CACnB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,EACzE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CACvB,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport { roundMoney } from '@bisondesk/commons-sdk/money';\nimport { Decimal } from 'decimal.js';\nimport { uniqBy } from 'lodash-es';\nimport { GENERATING_PLACEHOLDER_ATTACHMENT } from '../constants/index.js';\nimport {\n Association,\n DocumentDraft,\n FinanceDocument,\n FinanceDocumentGenerateRequest,\n FinanceDocumentLine,\n FinanceDocumentSubtype,\n FinanceDocumentV2,\n isFinanceDocumentDraft,\n isFinanceDocumentV1,\n isFinanceDocumentV2,\n NewDocumentDraft,\n} from '../types/documents.js';\nimport { FinanceDocumentV1, FinanceLineV1 } from '../types/legacy.js';\n\nexport const documentGoesToAccounting = (\n doc:\n | FinanceDocumentV2\n | DocumentDraft<FinanceDocumentV2>\n | FinanceDocumentGenerateRequest\n | FinanceDocumentV1,\n): boolean => {\n return (\n !!doc.subtype &&\n [FinanceDocumentSubtype.Invoice, FinanceDocumentSubtype.CreditNote].includes(\n doc.subtype as FinanceDocumentSubtype,\n )\n );\n};\n\nexport const documentGoesToStorecove = (\n doc:\n | FinanceDocumentV2\n | DocumentDraft<FinanceDocumentV2>\n | FinanceDocumentGenerateRequest\n | FinanceDocumentV1,\n): boolean => {\n if (!doc.organizationSummary) {\n return false;\n }\n const vatNumber = doc.organizationSummary.vatNumber;\n const isBeCountry = doc.organizationSummary.country === 'be';\n const isBEVAT = (isBeCountry && vatNumber?.toLowerCase().startsWith('be')) || false;\n return isBEVAT && documentGoesToAccounting(doc);\n};\n\nexport const getAccountingDescription = (doc: FinanceDocumentV2): string => {\n if (!!doc.accountingDescription) {\n return doc.accountingDescription;\n }\n\n const associations = doc.lines\n ?.flatMap((line) => line.associations ?? [])\n .filter(Boolean) as Association[];\n\n // In the UI the user can only select one vehicle associations\n const equivalentEntityIds = {\n [BusinessEntityIds.ExternalVehicleSale]: BusinessEntityIds.Vehicles,\n };\n\n const uniqueAssociations = uniqBy(\n associations,\n (a) => `${equivalentEntityIds[a.businessEntityId] ?? a.businessEntityId}_${a.recordId}`,\n );\n\n if (uniqueAssociations.length !== 1) {\n return doc.reference;\n }\n\n const firstAssociation = associations[0];\n if (\n [\n BusinessEntityIds.Vehicles,\n BusinessEntityIds.Opportunities,\n BusinessEntityIds.ExternalVehicleSale,\n ].includes(firstAssociation.businessEntityId) &&\n firstAssociation.tags != null\n ) {\n return `${firstAssociation.tags?.slice(0, 3).join(' ')} ${doc.reference}`.trim();\n }\n\n return doc.reference;\n};\n\nexport const getTotalExcl = <T extends FinanceDocument['lines']>(\n lines: T,\n unitPrice: (line: T[0], index: number) => any,\n) => {\n return lines.length === 0\n ? new Decimal(0)\n : Decimal.sum(...lines.map((line, i) => Decimal.mul(line.quantity, unitPrice(line, i))));\n};\n\nexport const getTotalVat = <T extends FinanceDocument['lines'], L = T[0]>(\n currency: string,\n lines: T,\n unitPrice: (doc: L, index: number) => any,\n vatCoefficient: (doc: L, index: number) => any,\n) => {\n return lines.length === 0\n ? new Decimal(0)\n : roundMoney(\n currency,\n Decimal.sum(\n ...lines.map((line, i) =>\n Decimal.mul(line.quantity, unitPrice(line, i)).mul(vatCoefficient(line, i)),\n ),\n ),\n );\n};\n\nexport const getDocumentTotals = (\n doc:\n | FinanceDocument\n | DocumentDraft<FinanceDocumentV2>\n | NewDocumentDraft<FinanceDocumentV2>\n | FinanceDocumentGenerateRequest,\n) => {\n let totalVat: Decimal;\n let totalExcl: Decimal;\n\n if (isFinanceDocumentV1(doc as FinanceDocumentV1)) {\n const v1Currency = 'EUR';\n const lines = (doc as FinanceDocumentV1).lines;\n const getUnitPriceExclusive = (line: FinanceLineV1) => line.unitPriceExclusive;\n\n totalVat = getTotalVat(v1Currency, lines, getUnitPriceExclusive, (line) => line.vatCoefficient);\n totalExcl = getTotalExcl(lines, getUnitPriceExclusive);\n } else {\n const docCurrency = (doc as FinanceDocumentV2)?.total?.currencyCode; // careful with this cast, misleading\n const currency = docCurrency ?? 'EUR';\n const lines = (doc as FinanceDocumentV2).lines ?? [];\n const getUnitPriceExcl = (line: FinanceDocumentLine) => line.unitPriceExcl;\n\n totalVat = getTotalVat(currency, lines, getUnitPriceExcl, (line) =>\n new Decimal(line.vatPercentage).div(100),\n );\n totalExcl = getTotalExcl(lines, getUnitPriceExcl);\n }\n\n return {\n totalExcl,\n totalVat,\n subTotal: totalExcl.add(totalVat),\n };\n};\n\nexport const getRoundedDocumentTotal = (\n doc:\n | FinanceDocument\n | DocumentDraft<FinanceDocumentV2>\n | NewDocumentDraft<FinanceDocumentV2>\n | FinanceDocumentGenerateRequest,\n) => {\n let total: FinanceDocumentV2['total'] | undefined;\n\n if (isFinanceDocumentV2(doc as FinanceDocument) || isFinanceDocumentDraft(doc as DocumentDraft)) {\n total = (doc as FinanceDocumentV2 | DocumentDraft<FinanceDocumentV2>).total;\n }\n\n const currencyCode = total?.currencyCode ?? 'EUR';\n const foreignCurrency = total?.foreign;\n\n const { subTotal, totalExcl, totalVat } = getDocumentTotals(doc);\n const rate = foreignCurrency?.exchangeRate ?? '1';\n const subTotalForeign = subTotal.div(rate).toString();\n const totalExclForeign = totalExcl.div(rate).toString();\n const totalVatForeign = totalVat.div(rate).toString();\n\n return {\n amount: roundMoney(currencyCode, subTotal).toString(),\n amountExcl: roundMoney(currencyCode, totalExcl).toString(),\n vatAmount: roundMoney(currencyCode, totalVat).toString(),\n currencyCode: currencyCode,\n foreign: foreignCurrency\n ? {\n amount: roundMoney(foreignCurrency.currencyCode, subTotalForeign).toString(),\n amountExcl: roundMoney(foreignCurrency.currencyCode, totalExclForeign).toString(),\n vatAmount: roundMoney(foreignCurrency.currencyCode, totalVatForeign).toString(),\n currencyCode: foreignCurrency.currencyCode,\n exchangeRate: foreignCurrency.exchangeRate,\n }\n : undefined,\n };\n};\n\nexport const getRoundedLinesTotals = (\n currency: string,\n lines: { quantity: string; unitPriceExcl: string; vatPercentage: string }[],\n rate = '1',\n) => {\n let totalWithoutVat = new Decimal('0');\n let vatTotal = new Decimal('0');\n for (const line of lines) {\n const lineTotal = new Decimal(line.unitPriceExcl).times(new Decimal(line.quantity));\n totalWithoutVat = totalWithoutVat.add(lineTotal);\n vatTotal = vatTotal.add(lineTotal.mul(line.vatPercentage).div(100));\n }\n\n totalWithoutVat = totalWithoutVat.div(rate);\n vatTotal = vatTotal.div(rate);\n\n return {\n totalWithoutVat: roundMoney(currency, totalWithoutVat),\n vatTotal: roundMoney(currency, vatTotal),\n total: roundMoney(currency, vatTotal.add(totalWithoutVat)),\n };\n};\n\nconst getAmountExcl = (unitPriceExcl: string, quantity: string) =>\n new Decimal(unitPriceExcl).times(new Decimal(quantity));\n\nexport const getLineAmounts = (unitPriceExcl: string, quantity: string, vatRate: string) => {\n const amountExcl = getAmountExcl(unitPriceExcl, quantity);\n const vatAmount = new Decimal(quantity)\n .times(new Decimal(unitPriceExcl))\n .times(new Decimal(vatRate).div(100));\n\n return {\n amount: amountExcl.add(vatAmount).toString(),\n amountExcl: amountExcl.toString(),\n unitPriceExcl,\n vatAmount: vatAmount.toString(),\n };\n};\n\nexport const isGeneratingAttachment = (doc: FinanceDocument) =>\n doc.attachment.id === GENERATING_PLACEHOLDER_ATTACHMENT.id;\n\n// returns a new finance document where\n// - all lines are filtered by the recordId\n// - the unit price is divided by the number of associations\nexport const filterDocumentLinesForRecord = (\n doc: FinanceDocument,\n recordId: string, // vehicleId, opportunityId, or externalVehicleSaleId\n): FinanceDocument => {\n const filteredLines = isFinanceDocumentV2(doc)\n ? doc.lines\n .filter((line) =>\n line.associations?.some(\n (assoc) => assoc.recordId === recordId || assoc.linkTo?.recordId === recordId,\n ),\n )\n .map((line) => ({\n ...line,\n amount: calculateDistributedPrice(line.amount, line.associations?.length || 1),\n amountExcl: calculateDistributedPrice(line.amountExcl, line.associations?.length || 1),\n unitPriceExcl: calculateDistributedPrice(\n line.unitPriceExcl,\n line.associations?.length || 1,\n ),\n }))\n : doc.lines\n .filter((line) =>\n getAllV1Associations(line.associations).some((assoc) => {\n const v1Ass = assoc as FinanceLineV1['associations']['sales'][0];\n return (\n assoc.vehicleId === recordId ||\n v1Ass.opportunityId === recordId ||\n v1Ass.id === recordId\n );\n }),\n )\n .map((line) => ({\n ...line,\n unitPriceExclusive: calculateDistributedPrice(\n line.unitPriceExclusive,\n getAllV1Associations(line.associations).length || 1,\n ),\n }));\n\n return {\n ...doc,\n lines: filteredLines,\n } as FinanceDocument;\n};\n\nconst calculateDistributedPrice = (price: string, count: number): string => {\n return new Decimal(price).div(Math.max(1, count)).toString();\n};\n\nconst getAllV1Associations = (ass: FinanceLineV1['associations']) => {\n const allAss = uniqBy(\n [...(ass?.sales ?? []), ...(ass?.purchases ?? []), ...(ass.others ?? [])],\n (ass) => ass.vehicleId,\n );\n return allAss;\n};\n"]}
|
package/lib/utils/vat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vat.js","sourceRoot":"/","sources":["utils/vat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EACL,mCAAmC,EACnC,mCAAmC,EACnC,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,OAA+B,EAC/B,OAA4B,EAC5B,EAAE;IACF,MAAM,MAAM,GACV,OAAO,KAAK,sBAAsB,CAAC,UAAU;QAC3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IAChE,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,OAA+B,EAC/B,aAAqB,EACrB,eAAuB,EACvB,QAAmB,EACnB,EAAE;IACF,MAAM,OAAO,GAAG,yBAAyB,CAAC,aAAa,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;IACpF,OAAO,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["import { isEUCountry } from '@bisondesk/commons-sdk/locations';\nimport {\n SALE_EU_EXTRA_COMMUNITY_VAT_CODE_ID,\n SALE_EU_INTRA_COMMUNITY_VAT_CODE_ID,\n STANDARD_VAT_CODE_ID,\n} from '../constants/index.js';\nimport { FinanceDocumentSubtype } from '../types/documents.js';\nimport { VatCode } from '../types/vat.js';\n\nexport const getVatCodeLineData = (\n subtype: FinanceDocumentSubtype,\n vatCode: VatCode | undefined,\n) => {\n const reason =\n subtype === FinanceDocumentSubtype.CreditNote\n ? vatCode?.reasons?.creditNote\n : vatCode?.reasons?.invoice;\n return {\n vatCode: vatCode?.code ?? '',\n vatReason: reason ?? '',\n vatPercentage: vatCode?.rate ?? '0',\n };\n};\n\nconst v1VatCodeMappings = {\n EU_CLIENTS_GOODS: 'B',\n EU_CLIENTS_SERVICES: 'F',\n MARGIN_VAT: 'MAR',\n BE_ORG_REDUCED_1: '3',\n BE_ORG_0: '0%',\n BE_ORG_1: '1',\n BE_ORG_2: '5',\n EXPORT_SALE: 'E',\n};\n\nexport const getAccountingCodeForV1VatCode = (vatCode: string): string | undefined =>\n v1VatCodeMappings[vatCode];\n\nexport const getSaleVatCodeForCustomer = (\n branchCountry: string,\n customerCountry: string,\n vatCodes: VatCode[],\n) => {\n const isSameCountry = branchCountry.toUpperCase() === customerCountry.toUpperCase();\n const isSaleInEU = isEUCountry(customerCountry);\n const vatCodeId =\n isSameCountry || !branchCountry\n ? STANDARD_VAT_CODE_ID\n : isSaleInEU\n ? SALE_EU_INTRA_COMMUNITY_VAT_CODE_ID\n : SALE_EU_EXTRA_COMMUNITY_VAT_CODE_ID;\n\n const vatCode = vatCodes?.find((code) => code.id === vatCodeId);\n return vatCode;\n};\n\nexport const getSaleVatCodeDataForCustomer = (\n subtype: FinanceDocumentSubtype,\n branchCountry: string,\n customerCountry: string,\n vatCodes: VatCode[],\n) => {\n const vatCode = getSaleVatCodeForCustomer(branchCountry, customerCountry, vatCodes);\n return getVatCodeLineData(subtype, vatCode);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visibility.js","sourceRoot":"/","sources":["utils/visibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAI/F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,QAIoC,EACpC,EAAE,CAAC,YAAY,IAAI,QAAQ,IAAI,QAAQ,CAAC,UAAU,KAAK,0BAA0B,CAAC,OAAO,CAAC","sourcesContent":["import { DocumentCategory, DocumentCategoryVisibility } from '../types/document-categories.js';\nimport { DocumentDraft, FinanceDocumentV2 } from '../types/documents.js';\nimport { FinanceDocumentV1 } from '../types/legacy.js';\n\nexport const isPrivateVisibility = (\n catOrDoc:\n | DocumentCategory\n | FinanceDocumentV1\n | FinanceDocumentV2\n | DocumentDraft<FinanceDocumentV2
|
|
1
|
+
{"version":3,"file":"visibility.js","sourceRoot":"/","sources":["utils/visibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAI/F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,QAIoC,EACpC,EAAE,CAAC,YAAY,IAAI,QAAQ,IAAI,QAAQ,CAAC,UAAU,KAAK,0BAA0B,CAAC,OAAO,CAAC","sourcesContent":["import { DocumentCategory, DocumentCategoryVisibility } from '../types/document-categories.js';\nimport { DocumentDraft, FinanceDocumentV2 } from '../types/documents.js';\nimport { FinanceDocumentV1 } from '../types/legacy.js';\n\nexport const isPrivateVisibility = (\n catOrDoc:\n | DocumentCategory\n | FinanceDocumentV1\n | FinanceDocumentV2\n | DocumentDraft<FinanceDocumentV2>,\n) => 'visibility' in catOrDoc && catOrDoc.visibility === DocumentCategoryVisibility.Private;\n"]}
|
package/package.json
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bisondesk/documents-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.590",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "npx tsc --build tsconfig.json",
|
|
8
|
-
"clean": "rm -rf lib *.tsbuildinfo",
|
|
9
|
-
"unittest": "echo \"No test specified\"",
|
|
10
|
-
"integrationtest": "echo \"No test specified\"",
|
|
11
|
-
"watch": "npx tsc --build --watch"
|
|
12
|
-
},
|
|
13
6
|
"author": "TheTruckCompany",
|
|
14
7
|
"dependencies": {
|
|
15
8
|
"@bisondesk/commons-sdk": "*",
|
|
16
9
|
"@bisondesk/core-sdk": "*",
|
|
10
|
+
"@date-fns/utc": "1.1.1",
|
|
11
|
+
"date-fns": "3.2.0",
|
|
17
12
|
"decimal.js": "10.4.3",
|
|
18
|
-
"joi": "17.13.3"
|
|
13
|
+
"joi": "17.13.3",
|
|
14
|
+
"lodash-es": "4.17.23"
|
|
19
15
|
},
|
|
20
16
|
"peerDependencies": {
|
|
21
17
|
"node-fetch": "3.3.2"
|
|
22
18
|
},
|
|
23
19
|
"devDependencies": {
|
|
20
|
+
"@types/lodash-es": "4.17.12",
|
|
24
21
|
"@types/node": "24.1.0",
|
|
25
22
|
"typescript": "5.9.3"
|
|
26
23
|
},
|
|
@@ -33,5 +30,12 @@
|
|
|
33
30
|
},
|
|
34
31
|
"exports": {
|
|
35
32
|
"./*": "./lib/*.js"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "npx tsc --build tsconfig.json",
|
|
36
|
+
"clean": "rm -rf lib *.tsbuildinfo",
|
|
37
|
+
"unittest": "echo \"No test specified\"",
|
|
38
|
+
"integrationtest": "echo \"No test specified\"",
|
|
39
|
+
"watch": "npx tsc --build --watch"
|
|
36
40
|
}
|
|
37
|
-
}
|
|
41
|
+
}
|
|
@@ -19,7 +19,7 @@ import { StorecoveEvidenceStatus } from '../types/storecove.js';
|
|
|
19
19
|
export const getDocumentCategory = async <T extends DocumentCategory>(
|
|
20
20
|
tenantId: string,
|
|
21
21
|
branchId: string,
|
|
22
|
-
docCategoryId: string
|
|
22
|
+
docCategoryId: string,
|
|
23
23
|
): Promise<T | undefined> => {
|
|
24
24
|
const auth = await getAdminAuth();
|
|
25
25
|
const response: Response = await fetch(
|
|
@@ -29,7 +29,7 @@ export const getDocumentCategory = async <T extends DocumentCategory>(
|
|
|
29
29
|
Authorization: auth,
|
|
30
30
|
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
31
31
|
},
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
33
|
);
|
|
34
34
|
|
|
35
35
|
if (response.status === 200) {
|
|
@@ -52,7 +52,7 @@ export const listDocumentCategories = async <T extends DocumentCategory>(
|
|
|
52
52
|
filter: {
|
|
53
53
|
type: DocumentCategoryType;
|
|
54
54
|
transactionType?: TransactionType;
|
|
55
|
-
}
|
|
55
|
+
},
|
|
56
56
|
): Promise<T[]> => {
|
|
57
57
|
const auth = await getAdminAuth();
|
|
58
58
|
const response: Response = await fetch(
|
|
@@ -66,7 +66,7 @@ export const listDocumentCategories = async <T extends DocumentCategory>(
|
|
|
66
66
|
Authorization: auth,
|
|
67
67
|
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
68
68
|
},
|
|
69
|
-
}
|
|
69
|
+
},
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
if (response.status === 200) {
|
|
@@ -85,7 +85,7 @@ export const listDocumentCategories = async <T extends DocumentCategory>(
|
|
|
85
85
|
export const listFinanceLineCategories = async (
|
|
86
86
|
tenantId: string,
|
|
87
87
|
branchId: string,
|
|
88
|
-
docCategoryId: string
|
|
88
|
+
docCategoryId: string,
|
|
89
89
|
): Promise<FinanceDocumentLineCategory[]> => {
|
|
90
90
|
const auth = await getAdminAuth();
|
|
91
91
|
const response: Response = await fetch(
|
|
@@ -95,7 +95,7 @@ export const listFinanceLineCategories = async (
|
|
|
95
95
|
Authorization: auth,
|
|
96
96
|
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
97
97
|
},
|
|
98
|
-
}
|
|
98
|
+
},
|
|
99
99
|
);
|
|
100
100
|
|
|
101
101
|
if (response.status === 200) {
|
|
@@ -114,7 +114,7 @@ export const listFinanceLineCategories = async (
|
|
|
114
114
|
|
|
115
115
|
export const listVehicleFinanceLineCategories = async (
|
|
116
116
|
tenantId: string,
|
|
117
|
-
branchId: string
|
|
117
|
+
branchId: string,
|
|
118
118
|
): Promise<FinanceDocumentLineCategory[]> => {
|
|
119
119
|
const auth = await getAdminAuth();
|
|
120
120
|
const response: Response = await fetch(
|
|
@@ -124,7 +124,7 @@ export const listVehicleFinanceLineCategories = async (
|
|
|
124
124
|
Authorization: auth,
|
|
125
125
|
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
126
126
|
},
|
|
127
|
-
}
|
|
127
|
+
},
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
if (response.status === 200) {
|
|
@@ -142,7 +142,7 @@ export const listVehicleFinanceLineCategories = async (
|
|
|
142
142
|
|
|
143
143
|
export const listCostCenters = async (
|
|
144
144
|
tenantId: string,
|
|
145
|
-
branchId: string
|
|
145
|
+
branchId: string,
|
|
146
146
|
): Promise<CostCenter[]> => {
|
|
147
147
|
const auth = await getAdminAuth();
|
|
148
148
|
const response: Response = await fetch(
|
|
@@ -152,7 +152,7 @@ export const listCostCenters = async (
|
|
|
152
152
|
Authorization: auth,
|
|
153
153
|
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
154
154
|
},
|
|
155
|
-
}
|
|
155
|
+
},
|
|
156
156
|
);
|
|
157
157
|
|
|
158
158
|
if (response.status === 200) {
|
|
@@ -170,7 +170,7 @@ export const listCostCenters = async (
|
|
|
170
170
|
|
|
171
171
|
export const getLastValidationRulesResults = async (
|
|
172
172
|
tenantId: string,
|
|
173
|
-
documentId: string
|
|
173
|
+
documentId: string,
|
|
174
174
|
): Promise<DocumentValidationRulesResults> => {
|
|
175
175
|
const auth = await getAdminAuth();
|
|
176
176
|
const response: Response = await fetch(
|
|
@@ -180,7 +180,7 @@ export const getLastValidationRulesResults = async (
|
|
|
180
180
|
Authorization: auth,
|
|
181
181
|
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
182
182
|
},
|
|
183
|
-
}
|
|
183
|
+
},
|
|
184
184
|
);
|
|
185
185
|
|
|
186
186
|
if (response.status === 200) {
|
|
@@ -198,7 +198,7 @@ export const getLastValidationRulesResults = async (
|
|
|
198
198
|
|
|
199
199
|
export const disableAnyActiveRecurringInvoices = async (
|
|
200
200
|
tenantId: string,
|
|
201
|
-
contractId: string
|
|
201
|
+
contractId: string,
|
|
202
202
|
): Promise<void> => {
|
|
203
203
|
const auth = await getAdminAuth();
|
|
204
204
|
const response: Response = await fetch(
|
|
@@ -209,7 +209,7 @@ export const disableAnyActiveRecurringInvoices = async (
|
|
|
209
209
|
Authorization: auth,
|
|
210
210
|
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
211
211
|
}),
|
|
212
|
-
}
|
|
212
|
+
},
|
|
213
213
|
);
|
|
214
214
|
|
|
215
215
|
if (response.status === 204) {
|
|
@@ -227,7 +227,7 @@ export const disableAnyActiveRecurringInvoices = async (
|
|
|
227
227
|
|
|
228
228
|
export const createDocumentDraft = async (
|
|
229
229
|
tenantId: string,
|
|
230
|
-
draft: NewDocumentDraft
|
|
230
|
+
draft: NewDocumentDraft,
|
|
231
231
|
): Promise<DocumentDraft> => {
|
|
232
232
|
const auth = await getAdminAuth();
|
|
233
233
|
const response: Response = await fetch(
|
|
@@ -240,7 +240,7 @@ export const createDocumentDraft = async (
|
|
|
240
240
|
'Content-Type': 'application/json',
|
|
241
241
|
}),
|
|
242
242
|
body: JSON.stringify(draft),
|
|
243
|
-
}
|
|
243
|
+
},
|
|
244
244
|
);
|
|
245
245
|
|
|
246
246
|
if (response.status === 200) {
|
|
@@ -265,7 +265,7 @@ export const sartProcessing = async (tenantId: string, draftId: string): Promise
|
|
|
265
265
|
Authorization: auth,
|
|
266
266
|
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
267
267
|
}),
|
|
268
|
-
}
|
|
268
|
+
},
|
|
269
269
|
);
|
|
270
270
|
|
|
271
271
|
if (response.status === 204) {
|
|
@@ -293,7 +293,7 @@ export const ocrDocument = async (tenantId: string, fileKey: string): Promise<Do
|
|
|
293
293
|
'Content-Type': 'application/json',
|
|
294
294
|
}),
|
|
295
295
|
body: JSON.stringify({ fileKey }),
|
|
296
|
-
}
|
|
296
|
+
},
|
|
297
297
|
);
|
|
298
298
|
|
|
299
299
|
if (response.status === 200) {
|
|
@@ -312,7 +312,7 @@ export const ocrDocument = async (tenantId: string, fileKey: string): Promise<Do
|
|
|
312
312
|
export const getStorecoveEvidenceStatus = async (
|
|
313
313
|
tenantId: string,
|
|
314
314
|
branchId: string,
|
|
315
|
-
storecoveId: string
|
|
315
|
+
storecoveId: string,
|
|
316
316
|
): Promise<StorecoveEvidenceStatus | undefined> => {
|
|
317
317
|
const auth = await getAdminAuth();
|
|
318
318
|
const response: Response = await fetch(
|
|
@@ -322,7 +322,7 @@ export const getStorecoveEvidenceStatus = async (
|
|
|
322
322
|
Authorization: auth,
|
|
323
323
|
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
324
324
|
},
|
|
325
|
-
}
|
|
325
|
+
},
|
|
326
326
|
);
|
|
327
327
|
|
|
328
328
|
if (response.status === 200) {
|
|
@@ -7,7 +7,7 @@ import { SearchFinanceDocument } from '../types/search.js';
|
|
|
7
7
|
|
|
8
8
|
export const searchFinanceDocs = async (
|
|
9
9
|
tenantId: string,
|
|
10
|
-
request: SearchRequest
|
|
10
|
+
request: SearchRequest,
|
|
11
11
|
): Promise<PaginatedList<SearchFinanceDocument> | NextList<SearchFinanceDocument>> => {
|
|
12
12
|
const auth = await getAdminAuth();
|
|
13
13
|
const response: Response = await fetch(
|
|
@@ -20,7 +20,7 @@ export const searchFinanceDocs = async (
|
|
|
20
20
|
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
21
21
|
},
|
|
22
22
|
body: JSON.stringify(request),
|
|
23
|
-
}
|
|
23
|
+
},
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
if (response.status === 200) {
|