@bisondesk/documents-sdk 1.0.548 → 1.0.550

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.
@@ -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;AA6H/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;CAwDhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,QAAO,wBAuD9C,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,0BAc/C,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,YAMxC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,gBAI1C,CAAC"}
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;AAgI/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;CAwDhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,QAAO,wBAuD9C,CAAC;AAEF,eAAO,MAAM,iCAAiC,EAAE,0BAc/C,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,YAMxC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,gBAI1C,CAAC"}
@@ -38,6 +38,9 @@ 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
+ },
41
44
  };
42
45
  const FINANCE_DOC_DRAFT_MAPPING_FIELDS = {
43
46
  'doc.type': {
@@ -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,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE;KAC9C;IACD,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,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};\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.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,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AAa,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"]}
@@ -44,6 +44,7 @@ export type FinanceDocumentLineCategory = {
44
44
  associationMandatory: boolean;
45
45
  glAccount: string;
46
46
  externalId?: string;
47
+ defaultVatCodeId?: string;
47
48
  isVehicleCategory?: boolean;
48
49
  validationRulesConfigs?: ValidationRulesConfigs;
49
50
  };
@@ -1 +1 @@
1
- {"version":3,"file":"document-categories.d.ts","sourceRoot":"/","sources":["types/document-categories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,oBAAY,0BAA0B;IACpC,QAAQ,aAAa;IACrB,OAAO,YAAY;CACpB;AAED,oBAAY,oBAAoB;IAC9B,cAAc,mBAAmB;IACjC,OAAO,YAAY;CACpB;AAED,KAAK,oBAAoB,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,oBAAoB,GAAG;IAClE,IAAI,EAAE,oBAAoB,CAAC,cAAc,CAAC;IAC1C,OAAO,EAAE,SAAS,GAAG,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GAAG;IAC3D,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,0BAA0B,CAAC;IACvC,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,8BAA8B,GAAG,uBAAuB,CAAC;AAExF,MAAM,MAAM,mBAAmB,GAAG,CAC9B,IAAI,CAAC,uBAAuB,EAAE,IAAI,GAAG,WAAW,CAAC,GACjD,IAAI,CAAC,8BAA8B,EAAE,IAAI,GAAG,WAAW,CAAC,CAC3D,GAAG;IACF,SAAS,CAAC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CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,2BAA2B,EAAE,IAAI,GAAG,WAAW,CAAC,CAAC;AAEnG,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG;IAC3C,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,SAAS,CAAC;CAChB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"document-categories.js","sourceRoot":"/","sources":["types/document-categories.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,mDAAqB,CAAA;IACrB,iDAAmB,CAAA;AACrB,CAAC,EAHW,0BAA0B,KAA1B,0BAA0B,QAGrC;AAED,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,yDAAiC,CAAA;IACjC,2CAAmB,CAAA;AACrB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B","sourcesContent":["import { TransactionType } from '@bisondesk/commons-sdk/types';\nimport { ValidationRulesConfigs } from './rules.js';\n\nexport enum DocumentCategoryVisibility {\n Standard = 'standard',\n Private = 'private',\n}\n\nexport enum DocumentCategoryType {\n Administrative = 'administrative',\n Finance = 'finance',\n}\n\ntype BaseDocumentCategory = {\n createdAt: string;\n branchId: string;\n id: string;\n type: DocumentCategoryType;\n title: string;\n};\n\nexport type AdministrativeDocumentCategory = BaseDocumentCategory & {\n type: DocumentCategoryType.Administrative;\n subtype: 'generic' | 'deal';\n validators?: undefined;\n};\n\nexport type FinanceDocumentCategory = BaseDocumentCategory & {\n type: DocumentCategoryType.Finance;\n journal: string;\n visibility: DocumentCategoryVisibility;\n transactionType: TransactionType;\n validators?: string[];\n bankAccounts?: string[];\n};\n\nexport type DocumentCategory = AdministrativeDocumentCategory | FinanceDocumentCategory;\n\nexport type NewDocumentCategory = (\n | Omit<FinanceDocumentCategory, 'id' | 'createdAt'>\n | Omit<AdministrativeDocumentCategory, 'id' | 'createdAt'>\n) & {\n createdAt?: undefined;\n id?: undefined;\n};\n\nexport type FinanceDocumentLineCategory = {\n createdAt: string;\n branchId: string;\n categoryId: string;\n costCenterId?: string;\n id: string;\n title: string;\n description: string;\n associationMandatory: boolean;\n glAccount: string;\n externalId?: string;\n\n isVehicleCategory?: boolean;\n validationRulesConfigs?: ValidationRulesConfigs;\n};\n\nexport type NewFinanceDocumentLineCategory = Omit<FinanceDocumentLineCategory, 'id' | 'createdAt'>;\n\ntype BaseCostCenter = {\n branchId: string;\n name: string;\n accountingCode?: string;\n};\n\nexport type CostCenter = BaseCostCenter & {\n createdAt: string;\n createdBy: string;\n id: string;\n};\n\nexport type NewCostCenter = BaseCostCenter & {\n createdAt?: undefined;\n createdBy?: string;\n id?: undefined;\n};\n"]}
1
+ {"version":3,"file":"document-categories.js","sourceRoot":"/","sources":["types/document-categories.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,mDAAqB,CAAA;IACrB,iDAAmB,CAAA;AACrB,CAAC,EAHW,0BAA0B,KAA1B,0BAA0B,QAGrC;AAED,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,yDAAiC,CAAA;IACjC,2CAAmB,CAAA;AACrB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B","sourcesContent":["import { TransactionType } from '@bisondesk/commons-sdk/types';\nimport { ValidationRulesConfigs } from './rules.js';\n\nexport enum DocumentCategoryVisibility {\n Standard = 'standard',\n Private = 'private',\n}\n\nexport enum DocumentCategoryType {\n Administrative = 'administrative',\n Finance = 'finance',\n}\n\ntype BaseDocumentCategory = {\n createdAt: string;\n branchId: string;\n id: string;\n type: DocumentCategoryType;\n title: string;\n};\n\nexport type AdministrativeDocumentCategory = BaseDocumentCategory & {\n type: DocumentCategoryType.Administrative;\n subtype: 'generic' | 'deal';\n validators?: undefined;\n};\n\nexport type FinanceDocumentCategory = BaseDocumentCategory & {\n type: DocumentCategoryType.Finance;\n journal: string;\n visibility: DocumentCategoryVisibility;\n transactionType: TransactionType;\n validators?: string[];\n bankAccounts?: string[];\n};\n\nexport type DocumentCategory = AdministrativeDocumentCategory | FinanceDocumentCategory;\n\nexport type NewDocumentCategory = (\n | Omit<FinanceDocumentCategory, 'id' | 'createdAt'>\n | Omit<AdministrativeDocumentCategory, 'id' | 'createdAt'>\n) & {\n createdAt?: undefined;\n id?: undefined;\n};\n\nexport type FinanceDocumentLineCategory = {\n createdAt: string;\n branchId: string;\n categoryId: string;\n costCenterId?: string;\n id: string;\n title: string;\n description: string;\n associationMandatory: boolean;\n glAccount: string;\n externalId?: string;\n defaultVatCodeId?: string;\n\n isVehicleCategory?: boolean;\n validationRulesConfigs?: ValidationRulesConfigs;\n};\n\nexport type NewFinanceDocumentLineCategory = Omit<FinanceDocumentLineCategory, 'id' | 'createdAt'>;\n\ntype BaseCostCenter = {\n branchId: string;\n name: string;\n accountingCode?: string;\n};\n\nexport type CostCenter = BaseCostCenter & {\n createdAt: string;\n createdBy: string;\n id: string;\n};\n\nexport type NewCostCenter = BaseCostCenter & {\n createdAt?: undefined;\n createdBy?: string;\n id?: undefined;\n};\n"]}
@@ -68,6 +68,7 @@ export type SearchDocumentDraft = {
68
68
  validators?: string[];
69
69
  restrictedDraftUsers?: string[];
70
70
  validationRulesStatus?: ('passed' | 'failed' | 'skipped')[];
71
+ businessValidationAt?: string;
71
72
  };
72
73
  };
73
74
  export type CheckDraftDuplicatesRequest = {
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"/","sources":["types/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,GAAG;IAC/D,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG,4BAA4B,CAAC;AAE7E,MAAM,MAAM,qBAAqB,GAAG;IAClC,gBAAgB,EAAE,sBAAsB,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG;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AAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,8CAAqB,CAAA;IACrB,gDAAuB,CAAA;AACzB,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC;AAED,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,0CAAqB,CAAA;IACrB,8CAAyB,CAAA;IACzB,kCAAa,CAAA;IACb,gCAAW,CAAA;AACb,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport { SearchRequest } from '@bisondesk/commons-sdk/search';\nimport { PaginatedRequest, SearchPermissions } from '@bisondesk/commons-sdk/types';\nimport { Organization } from '@bisondesk/core-sdk/types/crm';\nimport { PublicSearchDefinition } from '@bisondesk/core-sdk/types/definitions';\nimport { FinanceBooking } from './booking.js';\nimport {\n AdministrativeDocument,\n DocumentDraft,\n DocumentType,\n DraftProcessStage,\n FinanceDocType,\n FinanceDocument,\n} from './documents.js';\n\nexport type SearchDocumentVehicleRef = {\n id: string;\n stockNumber: string;\n administrativeNumber?: string;\n};\n\nexport type InputSearchFinanceDocument = SearchFinanceDocument & {\n permissions: SearchPermissions;\n};\n\nexport type InputSearchAdministrativeDocument = SearchAdministrativeDocument;\n\nexport type DocsSearchDefinitions = {\n searchFinanceDoc: PublicSearchDefinition;\n};\n\nexport type AdministrativeDocsSearchDefinitions = {\n searchAdministrativeDoc: PublicSearchDefinition;\n};\n\nexport enum FinanceDocumentSource {\n HyperDMS = 'HyperDMS',\n Bisondesk = 'Bisondesk',\n}\n\nexport enum AutoValidatedInfo {\n Business = 'business',\n Accounting = 'accounting',\n None = 'none',\n All = 'all',\n}\n\nexport type SearchFinanceDocument = {\n permissions: SearchPermissions;\n org?: Organization;\n doc: FinanceDocument;\n booking?: FinanceBooking;\n vehicle?: SearchDocumentVehicleRef[];\n custom: {\n autoValidated?: AutoValidatedInfo[];\n isBooked: boolean;\n inStorecove?: boolean;\n source: FinanceDocumentSource;\n };\n};\n\nexport type SearchAdministrativeDocument = {\n doc: AdministrativeDocument;\n custom: {\n categorySubtype: 'generic' | 'deal';\n };\n};\n\nexport type RelatedDocumentsRequest = {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n docTypes?: DocumentType[];\n financeDocType?: FinanceDocType;\n subtype?: 'generic' | 'deal';\n} & PaginatedRequest;\n\nexport type SearchDocumentDraftDefinitions = {\n document: PublicSearchDefinition;\n};\n\nexport type SearchDocumentDraft = {\n doc: DocumentDraft;\n permissions: SearchPermissions;\n custom: {\n stage: DraftProcessStage;\n rejected?: boolean;\n validators?: string[];\n restrictedDraftUsers?: string[];\n validationRulesStatus?: ('passed' | 'failed' | 'skipped')[];\n };\n};\n\nexport type CheckDraftDuplicatesRequest = {\n draftId: string;\n reference: string;\n};\n\nexport type ReindexDraftEvent = {\n id: string;\n tenantId: string;\n};\n\nexport type NextAvailableDraftsRequest = {\n draftId: string;\n createdAt: string;\n searchRequest: SearchRequest;\n};\n\nexport type NextAvailableDraftsResponse = {\n prev: string | undefined;\n next: string | undefined;\n};\n"]}
1
+ {"version":3,"file":"search.js","sourceRoot":"/","sources":["types/search.ts"],"names":[],"mappings":"AAmCA,MAAM,CAAN,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,8CAAqB,CAAA;IACrB,gDAAuB,CAAA;AACzB,CAAC,EAHW,qBAAqB,KAArB,qBAAqB,QAGhC;AAED,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,0CAAqB,CAAA;IACrB,8CAAyB,CAAA;IACzB,kCAAa,CAAA;IACb,gCAAW,CAAA;AACb,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport { SearchRequest } from '@bisondesk/commons-sdk/search';\nimport { PaginatedRequest, SearchPermissions } from '@bisondesk/commons-sdk/types';\nimport { Organization } from '@bisondesk/core-sdk/types/crm';\nimport { PublicSearchDefinition } from '@bisondesk/core-sdk/types/definitions';\nimport { FinanceBooking } from './booking.js';\nimport {\n AdministrativeDocument,\n DocumentDraft,\n DocumentType,\n DraftProcessStage,\n FinanceDocType,\n FinanceDocument,\n} from './documents.js';\n\nexport type SearchDocumentVehicleRef = {\n id: string;\n stockNumber: string;\n administrativeNumber?: string;\n};\n\nexport type InputSearchFinanceDocument = SearchFinanceDocument & {\n permissions: SearchPermissions;\n};\n\nexport type InputSearchAdministrativeDocument = SearchAdministrativeDocument;\n\nexport type DocsSearchDefinitions = {\n searchFinanceDoc: PublicSearchDefinition;\n};\n\nexport type AdministrativeDocsSearchDefinitions = {\n searchAdministrativeDoc: PublicSearchDefinition;\n};\n\nexport enum FinanceDocumentSource {\n HyperDMS = 'HyperDMS',\n Bisondesk = 'Bisondesk',\n}\n\nexport enum AutoValidatedInfo {\n Business = 'business',\n Accounting = 'accounting',\n None = 'none',\n All = 'all',\n}\n\nexport type SearchFinanceDocument = {\n permissions: SearchPermissions;\n org?: Organization;\n doc: FinanceDocument;\n booking?: FinanceBooking;\n vehicle?: SearchDocumentVehicleRef[];\n custom: {\n autoValidated?: AutoValidatedInfo[];\n isBooked: boolean;\n inStorecove?: boolean;\n source: FinanceDocumentSource;\n };\n};\n\nexport type SearchAdministrativeDocument = {\n doc: AdministrativeDocument;\n custom: {\n categorySubtype: 'generic' | 'deal';\n };\n};\n\nexport type RelatedDocumentsRequest = {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n docTypes?: DocumentType[];\n financeDocType?: FinanceDocType;\n subtype?: 'generic' | 'deal';\n} & PaginatedRequest;\n\nexport type SearchDocumentDraftDefinitions = {\n document: PublicSearchDefinition;\n};\n\nexport type SearchDocumentDraft = {\n doc: DocumentDraft;\n permissions: SearchPermissions;\n custom: {\n stage: DraftProcessStage;\n rejected?: boolean;\n validators?: string[];\n restrictedDraftUsers?: string[];\n validationRulesStatus?: ('passed' | 'failed' | 'skipped')[];\n businessValidationAt?: string;\n };\n};\n\nexport type CheckDraftDuplicatesRequest = {\n draftId: string;\n reference: string;\n};\n\nexport type ReindexDraftEvent = {\n id: string;\n tenantId: string;\n};\n\nexport type NextAvailableDraftsRequest = {\n draftId: string;\n createdAt: string;\n searchRequest: SearchRequest;\n};\n\nexport type NextAvailableDraftsResponse = {\n prev: string | undefined;\n next: string | undefined;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"finance.d.ts","sourceRoot":"/","sources":["utils/finance.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,OAAO,EAEL,aAAa,EACb,eAAe,EACf,8BAA8B,EAG9B,iBAAiB,EAIjB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAiB,MAAM,oBAAoB,CAAC;AAEtE,eAAO,MAAM,wBAAwB,GACnC,KACI,iBAAiB,GACjB,aAAa,CAAC,iBAAiB,CAAC,GAChC,8BAA8B,GAC9B,iBAAiB,KACpB,OAOF,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,KACI,iBAAiB,GACjB,aAAa,CAAC,iBAAiB,CAAC,GAChC,8BAA8B,GAC9B,iBAAiB,KACpB,OAQF,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,KAAK,iBAAiB,KAAG,MAoCjE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,eAAe,CAAC,OAAO,CAAC,EAC7D,OAAO,CAAC,EACR,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,YAK9C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EACtE,UAAU,MAAM,EAChB,OAAO,CAAC,EACR,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,MA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E,SAAS,MAAM;;;;;CAYtF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,KAAK,eAAe,YACC,CAAC;AAK7D,eAAO,MAAM,4BAA4B,GACvC,KAAK,eAAe,EACpB,UAAU,MAAM,KACf,eAwCF,CAAC"}
@@ -137,7 +137,7 @@ export const isGeneratingAttachment = (doc) => doc.attachment.id === GENERATING_
137
137
  export const filterDocumentLinesForRecord = (doc, recordId) => {
138
138
  const filteredLines = isFinanceDocumentV2(doc)
139
139
  ? doc.lines
140
- .filter((line) => line.associations?.some((assoc) => assoc.recordId === recordId))
140
+ .filter((line) => line.associations?.some((assoc) => assoc.recordId === recordId || assoc.linkTo?.recordId === recordId))
141
141
  .map((line) => ({
142
142
  ...line,
143
143
  amount: calculateDistributedPrice(line.amount, line.associations?.length || 1),
@@ -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,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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C,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC/D,CAAC,CAAC;AAEF,MAAM,oBAAoB,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) => line.associations?.some((assoc) => assoc.recordId === recordId))\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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AC3C,IAAI,CAAC,kBAAkB,EACvB,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,IAAI,CAAC,CACpD;SACF,CAAC,CAAC,CAAC;IAEV,OAAO;QACL,GAAG,GAAG;QACN,KAAK,EAAE,aAAa;KACF,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAAC,KAAa,EAAE,KAAa,EAAU,EAAE;IACzE,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC/D,CAAC,CAAC;AAEF,MAAM,oBAAoB,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bisondesk/documents-sdk",
3
- "version": "1.0.548",
3
+ "version": "1.0.550",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -49,6 +49,9 @@ const BASE_DOC_DRAFT_MAPPING_FIELDS: {
49
49
  'custom.validationRulesStatus': {
50
50
  esMapping: { type: 'keyword' },
51
51
  },
52
+ 'custom.businessValidationAt': {
53
+ esMapping: { type: 'date' },
54
+ },
52
55
  };
53
56
 
54
57
  const FINANCE_DOC_DRAFT_MAPPING_FIELDS: {
@@ -55,6 +55,7 @@ export type FinanceDocumentLineCategory = {
55
55
  associationMandatory: boolean;
56
56
  glAccount: string;
57
57
  externalId?: string;
58
+ defaultVatCodeId?: string;
58
59
 
59
60
  isVehicleCategory?: boolean;
60
61
  validationRulesConfigs?: ValidationRulesConfigs;
@@ -87,6 +87,7 @@ export type SearchDocumentDraft = {
87
87
  validators?: string[];
88
88
  restrictedDraftUsers?: string[];
89
89
  validationRulesStatus?: ('passed' | 'failed' | 'skipped')[];
90
+ businessValidationAt?: string;
90
91
  };
91
92
  };
92
93
 
@@ -241,7 +241,11 @@ export const filterDocumentLinesForRecord = (
241
241
  ): FinanceDocument => {
242
242
  const filteredLines = isFinanceDocumentV2(doc)
243
243
  ? doc.lines
244
- .filter((line) => line.associations?.some((assoc) => assoc.recordId === recordId))
244
+ .filter((line) =>
245
+ line.associations?.some(
246
+ (assoc) => assoc.recordId === recordId || assoc.linkTo?.recordId === recordId
247
+ )
248
+ )
245
249
  .map((line) => ({
246
250
  ...line,
247
251
  amount: calculateDistributedPrice(line.amount, line.associations?.length || 1),