@bisondesk/documents-sdk 1.0.431 → 1.0.433
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/constants/search.d.ts.map +1 -1
- package/lib/constants/search.js +1 -0
- package/lib/constants/search.js.map +1 -1
- package/lib/types/bank-accounts.d.ts +1 -1
- package/lib/types/bank-accounts.d.ts.map +1 -1
- package/lib/types/bank-accounts.js.map +1 -1
- package/lib/types/documents.d.ts +2 -0
- package/lib/types/documents.d.ts.map +1 -1
- package/lib/types/documents.js.map +1 -1
- package/lib/types/recurring-invoices.d.ts +42 -0
- package/lib/types/recurring-invoices.d.ts.map +1 -0
- package/lib/types/recurring-invoices.js +2 -0
- package/lib/types/recurring-invoices.js.map +1 -0
- package/lib/utils/finance.d.ts +2 -0
- package/lib/utils/finance.d.ts.map +1 -1
- package/lib/utils/finance.js +2 -2
- package/lib/utils/finance.js.map +1 -1
- package/package.json +1 -1
- package/src/constants/search.ts +1 -0
- package/src/types/bank-accounts.ts +1 -1
- package/src/types/documents.ts +4 -0
- package/src/types/recurring-invoices.ts +53 -0
- package/src/utils/finance.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"/","sources":["constants/search.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,EACjB,0BAA0B,EAC1B,gBAAgB,EAChB,WAAW,EACZ,MAAM,uCAAuC,CAAC;AA0H/C,eAAO,MAAM,wBAAwB,EAAE;IACrC,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAKtC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE;IACxC,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC;CAmDhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,QAAO,wBAgD9C,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"/","sources":["constants/search.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,EACjB,0BAA0B,EAC1B,gBAAgB,EAChB,WAAW,EACZ,MAAM,uCAAuC,CAAC;AA0H/C,eAAO,MAAM,wBAAwB,EAAE;IACrC,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAKtC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE;IACxC,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC;CAmDhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,QAAO,wBAgD9C,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,0BAc/C,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,YAMxC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,gBAI1C,CAAC"}
|
package/lib/constants/search.js
CHANGED
|
@@ -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,IAA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AAE,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;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAA+B;IAE3E,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};\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};\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};\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\nexport const SEARCH_DOC_DRAFT_FULL_TEXT_FIELDS: EsFullTextSearchDefinition = [\n // finance fields\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.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,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE;KAC9C;IACD,eAAe,EAAE;QACf,SAAS,EA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E,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};\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};\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};\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\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,4 +1,5 @@
|
|
|
1
1
|
export type BankAccountData = {
|
|
2
|
+
id: string;
|
|
2
3
|
name: string;
|
|
3
4
|
description: string;
|
|
4
5
|
iban: string;
|
|
@@ -9,7 +10,6 @@ export type BankAccountData = {
|
|
|
9
10
|
country: string;
|
|
10
11
|
};
|
|
11
12
|
export type BankAccount = BankAccountData & {
|
|
12
|
-
id: string;
|
|
13
13
|
branchId: string;
|
|
14
14
|
default?: boolean;
|
|
15
15
|
createdAt: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bank-accounts.d.ts","sourceRoot":"/","sources":["types/bank-accounts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IAC1C,
|
|
1
|
+
{"version":3,"file":"bank-accounts.d.ts","sourceRoot":"/","sources":["types/bank-accounts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,WAAW,EACX,IAAI,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAC7D,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bank-accounts.js","sourceRoot":"/","sources":["types/bank-accounts.ts"],"names":[],"mappings":"","sourcesContent":["export type BankAccountData = {\n name: string;\n description: string;\n iban: string;\n swift: string;\n address: string;\n city: string;\n postCode: string;\n country: string;\n};\n\nexport type BankAccount = BankAccountData & {\n
|
|
1
|
+
{"version":3,"file":"bank-accounts.js","sourceRoot":"/","sources":["types/bank-accounts.ts"],"names":[],"mappings":"","sourcesContent":["export type BankAccountData = {\n id: string;\n name: string;\n description: string;\n iban: string;\n swift: string;\n address: string;\n city: string;\n postCode: string;\n country: string;\n};\n\nexport type BankAccount = BankAccountData & {\n branchId: string;\n default?: boolean;\n\n createdAt: string;\n createdBy: string;\n updatedAt?: string;\n updatedBy?: string;\n};\n\nexport type NewBankAccount = Omit<\n BankAccount,\n 'id' | 'createdAt' | 'createdBy' | 'updatedAt' | 'updatedBy'\n>;\n\nexport type BankAccountDefaultUpdate = {\n id: string;\n};\n"]}
|
package/lib/types/documents.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ type BaseDocument = {
|
|
|
67
67
|
};
|
|
68
68
|
export type FinanceDocumentV2 = BaseDocument & {
|
|
69
69
|
version: 2.0;
|
|
70
|
+
autoGenerated?: boolean;
|
|
70
71
|
reference: string;
|
|
71
72
|
subtype: FinanceDocumentSubtype;
|
|
72
73
|
type: FinanceDocType;
|
|
@@ -102,6 +103,7 @@ export type FinanceDocumentV2 = BaseDocument & {
|
|
|
102
103
|
reportingPeriod?: string;
|
|
103
104
|
reportingYear?: string;
|
|
104
105
|
accountingDescription?: string;
|
|
106
|
+
bankAccounts?: BankAccountData[];
|
|
105
107
|
};
|
|
106
108
|
export type NewFinanceDocumentV2 = Omit<FinanceDocumentV2, 'id' | 'createdAt' | 'createdBy' | 'lines'> & {
|
|
107
109
|
lines: Omit<FinanceDocumentLine, 'id'>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.d.ts","sourceRoot":"/","sources":["types/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAEpE,MAAM,MAAM,WAAW,GAAG;IACxB,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE;QACP,gBAAgB,EAAE,iBAAiB,CAAC;QACpC,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;Q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;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\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 language: string; // needed?\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 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\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};\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 FinanceDocumentGeneratePDFEvent = {\n tenantId: string;\n doc: FinanceDocumentV2;\n request: FinanceDocumentGenerateRequest;\n};\n\nexport type FinanceDocumentSettings<M = {}> = {\n provider: string;\n meta: {\n [key in FinanceDocumentSubtype]: {\n prefix: string;\n templateId: string;\n };\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 = { documentId: string } & (\n | { paid: true; paidAt: string }\n | { paid: false; paidAt?: undefined }\n);\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":"AAkEA,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,+CAA6B,CAAA;AAC/B,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AA2ED,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,iBAA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C,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\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 language: string; // needed?\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 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\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};\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 FinanceDocumentGeneratePDFEvent = {\n tenantId: string;\n doc: FinanceDocumentV2;\n request: FinanceDocumentGenerateRequest;\n};\n\nexport type FinanceDocumentSettings<M = {}> = {\n provider: string;\n meta: {\n [key in FinanceDocumentSubtype]: {\n prefix: string;\n templateId: string;\n };\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 = { documentId: string } & (\n | { paid: true; paidAt: string }\n | { paid: false; paidAt?: undefined }\n);\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"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DocumentType, FinanceDocumentV2 } from './documents.js';
|
|
2
|
+
export type NewRecurringInvoice = {
|
|
3
|
+
originalInvoiceId: string;
|
|
4
|
+
leasingContractId?: string;
|
|
5
|
+
startPeriod: number;
|
|
6
|
+
totalExecutions?: number;
|
|
7
|
+
};
|
|
8
|
+
export type RecurringInvoiceUpdate = NewRecurringInvoice & {
|
|
9
|
+
active: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type RecurringInvoice = RecurringInvoiceUpdate & {
|
|
12
|
+
id: string;
|
|
13
|
+
country: string;
|
|
14
|
+
executions: number;
|
|
15
|
+
automationStart: string;
|
|
16
|
+
amountExcl: string;
|
|
17
|
+
organizationId: string;
|
|
18
|
+
originalInvoiceData: Pick<FinanceDocumentV2, 'category' | 'branchId' | 'tags' | 'total' | 'notes' | 'lines' | 'bankAccounts'>;
|
|
19
|
+
lastGeneratedDocumentId?: string;
|
|
20
|
+
lastExecutedAt?: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
createdBy: string;
|
|
23
|
+
modifiedAt: string;
|
|
24
|
+
modifiedBy: string;
|
|
25
|
+
};
|
|
26
|
+
export type RecurringInvoiceFilterOptions = {
|
|
27
|
+
contractId?: string;
|
|
28
|
+
onlyActive?: boolean;
|
|
29
|
+
onlyFixedPeriod?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export type RecurringDocShareData = {
|
|
32
|
+
type: DocumentType.Finance;
|
|
33
|
+
recipient?: string;
|
|
34
|
+
tenant: string;
|
|
35
|
+
message: string;
|
|
36
|
+
meta: {
|
|
37
|
+
amount?: string;
|
|
38
|
+
issueDate: string;
|
|
39
|
+
reference: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=recurring-invoices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recurring-invoices.d.ts","sourceRoot":"/","sources":["types/recurring-invoices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,MAAM,mBAAmB,GAAG;IAChC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GAAG;IACzD,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,GAAG;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IAGxB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IAEvB,mBAAmB,EAAE,IAAI,CACvB,iBAAiB,EACjB,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,CAChF,CAAC;IACF,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QACJ,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recurring-invoices.js","sourceRoot":"/","sources":["types/recurring-invoices.ts"],"names":[],"mappings":"","sourcesContent":["import { DocumentType, FinanceDocumentV2 } from './documents.js';\n\nexport type NewRecurringInvoice = {\n originalInvoiceId: string;\n leasingContractId?: string;\n startPeriod: number;\n totalExecutions?: number; // can be undefined if the recurring invoice is infinite\n};\n\nexport type RecurringInvoiceUpdate = NewRecurringInvoice & {\n active: boolean;\n};\n\nexport type RecurringInvoice = RecurringInvoiceUpdate & {\n id: string;\n country: string;\n executions: number;\n automationStart: string;\n\n // stored invoice data for display\n amountExcl: string;\n organizationId: string;\n\n originalInvoiceData: Pick<\n FinanceDocumentV2,\n 'category' | 'branchId' | 'tags' | 'total' | 'notes' | 'lines' | 'bankAccounts'\n >;\n lastGeneratedDocumentId?: string;\n lastExecutedAt?: string;\n\n createdAt: string;\n createdBy: string;\n modifiedAt: string;\n modifiedBy: string;\n};\n\nexport type RecurringInvoiceFilterOptions = {\n contractId?: string;\n onlyActive?: boolean;\n onlyFixedPeriod?: boolean;\n};\n\nexport type RecurringDocShareData = {\n type: DocumentType.Finance;\n recipient?: string;\n tenant: string;\n message: string;\n meta: {\n amount?: string;\n issueDate: string;\n reference: string;\n };\n};\n"]}
|
package/lib/utils/finance.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { Decimal } from 'decimal.js';
|
|
|
2
2
|
import { DocumentDraft, FinanceDocument, FinanceDocumentGenerateRequest, FinanceDocumentV2, NewDocumentDraft } from '../types/documents.js';
|
|
3
3
|
export declare const documentGoesToAccounting: (doc: FinanceDocumentV2 | DocumentDraft<FinanceDocumentV2> | FinanceDocumentGenerateRequest) => boolean;
|
|
4
4
|
export declare const getAccountingDescription: (doc: FinanceDocumentV2) => string;
|
|
5
|
+
export declare const getTotalExcl: <T extends FinanceDocument["lines"]>(lines: T, unitPrice: (line: T[0]) => any) => Decimal;
|
|
6
|
+
export declare const getTotalVat: <T extends FinanceDocument["lines"], L = T[0]>(lines: T, unitPrice: (doc: L) => any, vatCoefficient: (doc: L) => any) => Decimal;
|
|
5
7
|
export declare const getDocumentTotals: (doc: FinanceDocument | DocumentDraft<FinanceDocumentV2> | NewDocumentDraft<FinanceDocumentV2> | FinanceDocumentGenerateRequest) => {
|
|
6
8
|
totalExcl: Decimal;
|
|
7
9
|
totalVat: Decimal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finance.d.ts","sourceRoot":"/","sources":["utils/finance.ts"],"names":[],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B,QAE9B,eAAe,GACf,aAAa,CAAC,iBAAiB,CAAC,GAChC,gBAAgB,CAAC,iBAAiB,CAAC,GACnC,8BAA8B,iBACnB,MAAM,oBACH;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;;;;;;;;;;;;CAuBF,CAAC;AAKF,eAAO,MAAM,cAAc,kBAAmB,MAAM,YAAY,MAAM,WAAW,MAAM;;;;;CAYtF,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAS,eAAe,YACC,CAAC"}
|
package/lib/utils/finance.js
CHANGED
|
@@ -33,12 +33,12 @@ export const getAccountingDescription = (doc) => {
|
|
|
33
33
|
}
|
|
34
34
|
return doc.reference;
|
|
35
35
|
};
|
|
36
|
-
const getTotalExcl = (lines, unitPrice) => {
|
|
36
|
+
export const getTotalExcl = (lines, unitPrice) => {
|
|
37
37
|
return lines.length === 0
|
|
38
38
|
? new Decimal(0)
|
|
39
39
|
: Decimal.sum(...lines.map((line) => Decimal.mul(line.quantity, unitPrice(line))));
|
|
40
40
|
};
|
|
41
|
-
const getTotalVat = (lines, unitPrice, vatCoefficient) => {
|
|
41
|
+
export const getTotalVat = (lines, unitPrice, vatCoefficient) => {
|
|
42
42
|
return lines.length === 0
|
|
43
43
|
? new Decimal(0)
|
|
44
44
|
: Decimal.sum(...lines.map((line) => Decimal.mul(line.quantity, unitPrice(line)).mul(vatCoefficient(line))));
|
package/lib/utils/finance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,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C;SACjC,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAExC,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE;QAC5C,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;QACjC,aAAa;QACb,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE;KAChC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAoB,EAAE,EAAE,CAC7D,GAAG,CAAC,UAAU,CAAC,EAAE,KAAK,iCAAiC,CAAC,EAAE,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 NewDocumentDraft,\n isFinanceDocumentV1,\n} from '../types/documents.js';\nimport { FinanceDocumentV1, FinanceLineV1 } from '../types/legacy.js';\n\nexport const documentGoesToAccounting = (\n doc: FinanceDocumentV2 | DocumentDraft<FinanceDocumentV2> | FinanceDocumentGenerateRequest\n): boolean => {\n return (\n !!doc.subtype &&\n [FinanceDocumentSubtype.Invoice, FinanceDocumentSubtype.CreditNote].includes(doc.subtype)\n );\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\nconst getTotalExcl = <T extends FinanceDocument['lines']>(\n lines: T,\n unitPrice: (line: T[0]) => any\n) => {\n return lines.length === 0\n ? new Decimal(0)\n : Decimal.sum(...lines.map((line) => Decimal.mul(line.quantity, unitPrice(line))));\n};\n\nconst getTotalVat = <T extends FinanceDocument['lines'], L = T[0]>(\n lines: T,\n unitPrice: (doc: L) => any,\n vatCoefficient: (doc: L) => any\n) => {\n return lines.length === 0\n ? new Decimal(0)\n : Decimal.sum(\n ...lines.map((line) =>\n Decimal.mul(line.quantity, unitPrice(line)).mul(vatCoefficient(line))\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 lines = (doc as FinanceDocumentV1).lines;\n const getUnitPriceExclusive = (line: FinanceLineV1) => line.unitPriceExclusive;\n\n totalVat = getTotalVat(lines, getUnitPriceExclusive, (line) => line.vatCoefficient);\n totalExcl = getTotalExcl(lines, getUnitPriceExclusive);\n } else {\n const lines = (doc as FinanceDocumentV2).lines ?? [];\n const getUnitPriceExcl = (line: FinanceDocumentLine) => line.unitPriceExcl;\n\n totalVat = getTotalVat(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 currencyCode?: string,\n foreignCurrency?: {\n currencyCode: string;\n exchangeRate: string;\n }\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(subTotal).toString(),\n amountExcl: roundMoney(totalExcl).toString(),\n vatAmount: roundMoney(totalVat).toString(),\n currencyCode: currencyCode ?? 'EUR',\n foreign: foreignCurrency\n ? {\n amount: roundMoney(subTotalForeign).toString(),\n amountExcl: roundMoney(totalExclForeign).toString(),\n vatAmount: roundMoney(totalVatForeign).toString(),\n currencyCode: foreignCurrency.currencyCode,\n exchangeRate: foreignCurrency.exchangeRate,\n }\n : undefined,\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"]}
|
|
1
|
+
{"version":3,"file":"finance.js","sourceRoot":"/","sources":["utils/finance.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,CAAC;AAE1D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,aAAqB,EAAE,QAAgB,EAAE,OAAe,EAAE,EAAE;IACzF,MAAM,UAAU,GAAG,aAAa,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;SACpC,KAAK,CAAC,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;SACjC,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAExC,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE;QAC5C,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;QACjC,aAAa;QACb,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE;KAChC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAoB,EAAE,EAAE,CAC7D,GAAG,CAAC,UAAU,CAAC,EAAE,KAAK,iCAAiC,CAAC,EAAE,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 NewDocumentDraft,\n isFinanceDocumentV1,\n} from '../types/documents.js';\nimport { FinanceDocumentV1, FinanceLineV1 } from '../types/legacy.js';\n\nexport const documentGoesToAccounting = (\n doc: FinanceDocumentV2 | DocumentDraft<FinanceDocumentV2> | FinanceDocumentGenerateRequest\n): boolean => {\n return (\n !!doc.subtype &&\n [FinanceDocumentSubtype.Invoice, FinanceDocumentSubtype.CreditNote].includes(doc.subtype)\n );\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]) => any\n) => {\n return lines.length === 0\n ? new Decimal(0)\n : Decimal.sum(...lines.map((line) => Decimal.mul(line.quantity, unitPrice(line))));\n};\n\nexport const getTotalVat = <T extends FinanceDocument['lines'], L = T[0]>(\n lines: T,\n unitPrice: (doc: L) => any,\n vatCoefficient: (doc: L) => any\n) => {\n return lines.length === 0\n ? new Decimal(0)\n : Decimal.sum(\n ...lines.map((line) =>\n Decimal.mul(line.quantity, unitPrice(line)).mul(vatCoefficient(line))\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 lines = (doc as FinanceDocumentV1).lines;\n const getUnitPriceExclusive = (line: FinanceLineV1) => line.unitPriceExclusive;\n\n totalVat = getTotalVat(lines, getUnitPriceExclusive, (line) => line.vatCoefficient);\n totalExcl = getTotalExcl(lines, getUnitPriceExclusive);\n } else {\n const lines = (doc as FinanceDocumentV2).lines ?? [];\n const getUnitPriceExcl = (line: FinanceDocumentLine) => line.unitPriceExcl;\n\n totalVat = getTotalVat(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 currencyCode?: string,\n foreignCurrency?: {\n currencyCode: string;\n exchangeRate: string;\n }\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(subTotal).toString(),\n amountExcl: roundMoney(totalExcl).toString(),\n vatAmount: roundMoney(totalVat).toString(),\n currencyCode: currencyCode ?? 'EUR',\n foreign: foreignCurrency\n ? {\n amount: roundMoney(subTotalForeign).toString(),\n amountExcl: roundMoney(totalExclForeign).toString(),\n vatAmount: roundMoney(totalVatForeign).toString(),\n currencyCode: foreignCurrency.currencyCode,\n exchangeRate: foreignCurrency.exchangeRate,\n }\n : undefined,\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"]}
|
package/package.json
CHANGED
package/src/constants/search.ts
CHANGED
|
@@ -243,6 +243,7 @@ export const getSearchDocumentDraftsAggs = (): EsAggregationsDefinition => [
|
|
|
243
243
|
|
|
244
244
|
export const SEARCH_DOC_DRAFT_FULL_TEXT_FIELDS: EsFullTextSearchDefinition = [
|
|
245
245
|
// finance fields
|
|
246
|
+
() => 'doc.id',
|
|
246
247
|
() => 'doc.reference',
|
|
247
248
|
() => 'doc.tags',
|
|
248
249
|
() => 'doc.lines.associations.tags',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type BankAccountData = {
|
|
2
|
+
id: string;
|
|
2
3
|
name: string;
|
|
3
4
|
description: string;
|
|
4
5
|
iban: string;
|
|
@@ -10,7 +11,6 @@ export type BankAccountData = {
|
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export type BankAccount = BankAccountData & {
|
|
13
|
-
id: string;
|
|
14
14
|
branchId: string;
|
|
15
15
|
default?: boolean;
|
|
16
16
|
|
package/src/types/documents.ts
CHANGED
|
@@ -79,6 +79,7 @@ type BaseDocument = {
|
|
|
79
79
|
|
|
80
80
|
export type FinanceDocumentV2 = BaseDocument & {
|
|
81
81
|
version: 2.0;
|
|
82
|
+
autoGenerated?: boolean;
|
|
82
83
|
reference: string;
|
|
83
84
|
subtype: FinanceDocumentSubtype;
|
|
84
85
|
type: FinanceDocType;
|
|
@@ -117,6 +118,9 @@ export type FinanceDocumentV2 = BaseDocument & {
|
|
|
117
118
|
reportingPeriod?: string;
|
|
118
119
|
reportingYear?: string;
|
|
119
120
|
accountingDescription?: string;
|
|
121
|
+
|
|
122
|
+
// mostly for the case we want to regenerate the document pdf again
|
|
123
|
+
bankAccounts?: BankAccountData[];
|
|
120
124
|
};
|
|
121
125
|
|
|
122
126
|
export type NewFinanceDocumentV2 = Omit<
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { DocumentType, FinanceDocumentV2 } from './documents.js';
|
|
2
|
+
|
|
3
|
+
export type NewRecurringInvoice = {
|
|
4
|
+
originalInvoiceId: string;
|
|
5
|
+
leasingContractId?: string;
|
|
6
|
+
startPeriod: number;
|
|
7
|
+
totalExecutions?: number; // can be undefined if the recurring invoice is infinite
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type RecurringInvoiceUpdate = NewRecurringInvoice & {
|
|
11
|
+
active: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type RecurringInvoice = RecurringInvoiceUpdate & {
|
|
15
|
+
id: string;
|
|
16
|
+
country: string;
|
|
17
|
+
executions: number;
|
|
18
|
+
automationStart: string;
|
|
19
|
+
|
|
20
|
+
// stored invoice data for display
|
|
21
|
+
amountExcl: string;
|
|
22
|
+
organizationId: string;
|
|
23
|
+
|
|
24
|
+
originalInvoiceData: Pick<
|
|
25
|
+
FinanceDocumentV2,
|
|
26
|
+
'category' | 'branchId' | 'tags' | 'total' | 'notes' | 'lines' | 'bankAccounts'
|
|
27
|
+
>;
|
|
28
|
+
lastGeneratedDocumentId?: string;
|
|
29
|
+
lastExecutedAt?: string;
|
|
30
|
+
|
|
31
|
+
createdAt: string;
|
|
32
|
+
createdBy: string;
|
|
33
|
+
modifiedAt: string;
|
|
34
|
+
modifiedBy: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type RecurringInvoiceFilterOptions = {
|
|
38
|
+
contractId?: string;
|
|
39
|
+
onlyActive?: boolean;
|
|
40
|
+
onlyFixedPeriod?: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type RecurringDocShareData = {
|
|
44
|
+
type: DocumentType.Finance;
|
|
45
|
+
recipient?: string;
|
|
46
|
+
tenant: string;
|
|
47
|
+
message: string;
|
|
48
|
+
meta: {
|
|
49
|
+
amount?: string;
|
|
50
|
+
issueDate: string;
|
|
51
|
+
reference: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
package/src/utils/finance.ts
CHANGED
|
@@ -63,7 +63,7 @@ export const getAccountingDescription = (doc: FinanceDocumentV2): string => {
|
|
|
63
63
|
return doc.reference;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
const getTotalExcl = <T extends FinanceDocument['lines']>(
|
|
66
|
+
export const getTotalExcl = <T extends FinanceDocument['lines']>(
|
|
67
67
|
lines: T,
|
|
68
68
|
unitPrice: (line: T[0]) => any
|
|
69
69
|
) => {
|
|
@@ -72,7 +72,7 @@ const getTotalExcl = <T extends FinanceDocument['lines']>(
|
|
|
72
72
|
: Decimal.sum(...lines.map((line) => Decimal.mul(line.quantity, unitPrice(line))));
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
-
const getTotalVat = <T extends FinanceDocument['lines'], L = T[0]>(
|
|
75
|
+
export const getTotalVat = <T extends FinanceDocument['lines'], L = T[0]>(
|
|
76
76
|
lines: T,
|
|
77
77
|
unitPrice: (doc: L) => any,
|
|
78
78
|
vatCoefficient: (doc: L) => any
|