@bisondesk/documents-sdk 1.0.546 → 1.0.547

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":"schemas.d.ts","sourceRoot":"/","sources":["schemas.ts"],"names":[],"mappings":"AAOA,OAAO,GAAG,MAAM,KAAK,CAAC;AAqCtB,eAAO,MAAM,UAAU,uBAmBrB,CAAC;AAEH,eAAO,MAAM,qBAAqB,uBAwChC,CAAC;AAEH,eAAO,MAAM,gCAAgC,uBAS3C,CAAC;AAEH,eAAO,MAAM,4BAA4B,uBAIvC,CAAC"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"/","sources":["schemas.ts"],"names":[],"mappings":"AAOA,OAAO,GAAG,MAAM,KAAK,CAAC;AAqCtB,eAAO,MAAM,UAAU,uBAmBrB,CAAC;AAEH,eAAO,MAAM,qBAAqB,uBAiDhC,CAAC;AAEH,eAAO,MAAM,gCAAgC,uBAS3C,CAAC;AAEH,eAAO,MAAM,4BAA4B,uBAIvC,CAAC"}
package/lib/schemas.js CHANGED
@@ -93,6 +93,13 @@ export const newFinanceDocV2Schema = Joi.object({
93
93
  reportingYear: Joi.number().min(0).cast('string'),
94
94
  reportingPeriod: Joi.number().min(0).cast('string'),
95
95
  accountingDescription: Joi.string().empty(''),
96
+ peppol: Joi.object({
97
+ extraAttachments: Joi.array()
98
+ .items(attachmentValueSchema.keys({
99
+ contentType: Joi.string().valid('application/pdf').required(),
100
+ }))
101
+ .max(9),
102
+ }),
96
103
  });
97
104
  export const newAdministrativedDocumentSchema = Joi.object({
98
105
  id: Joi.string(),
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.js","sourceRoot":"/","sources":["schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,aAAa,GACd,MAAM,gCAAgC,CAAC;AACxC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,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACjD,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACnD,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;CAC9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC,MAAM,CAAC;IACzD,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;IACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,UAAU,EAAE,qBAAqB,CAAC,QAAQ,EAAE;IAC5C,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;IAChC,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC/C,YAAY,EAAE,kBAAkB;IAChC,mBAAmB,EAAE,gBAAgB;CACtC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,gCAAgC,CAAC,IAAI,CAAC;IAChF,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport {\n attachmentValueSchema,\n getPhoneSchema,\n isoDateSchema,\n} from '@bisondesk/commons/joi-schemas';\nimport { FinanceDocType } from '@bisondesk/documents-sdk/types/documents';\nimport Joi from 'joi';\n\nconst orgSummarySchema = Joi.object({\n id: Joi.string().required(),\n code: Joi.number().required(),\n name: Joi.string().empty('').required(),\n language: Joi.string().empty(''),\n vatNumber: Joi.string().empty(''),\n addressLine1: Joi.string().empty(''),\n addressLine2: Joi.string().empty(''),\n postcode: Joi.string().empty(''),\n city: Joi.string().empty(''),\n country: Joi.string().required(),\n emails: Joi.array().items(Joi.string().empty('').email()),\n phone: getPhoneSchema(),\n contact: Joi.object({\n name: Joi.string().empty('').required(),\n username: Joi.string().empty('').required(),\n }),\n});\n\nconst associationsSchema = Joi.array().items(\n Joi.object({\n businessEntityId: Joi.string()\n .valid(...Object.values(BusinessEntityIds))\n .required(),\n recordId: Joi.string().required(),\n title: Joi.string().required(),\n description: Joi.string().required(),\n tags: Joi.array().items(Joi.string().empty('')),\n linkTo: Joi.object({\n businessEntityId: Joi.string().required(),\n recordId: Joi.string().required(),\n }),\n })\n);\n\nexport const lineSchema = Joi.object({\n category: Joi.string().required(),\n amount: Joi.number().cast('string').required(),\n amountExcl: Joi.number().cast('string').required(),\n description: Joi.string().required(),\n foreign: Joi.object({\n amount: Joi.number().cast('string').required(),\n amountExcl: Joi.number().cast('string').required(),\n unitPriceExcl: Joi.number().cast('string').required(),\n vatAmount: Joi.number().cast('string').required(),\n }),\n invoiceLineId: Joi.string().empty('').uuid(),\n quantity: Joi.number().min(0).cast('string').required(),\n associations: associationsSchema,\n unitPriceExcl: Joi.number().cast('string').required(),\n vatAmount: Joi.number().cast('string').required(),\n vatCode: Joi.string().required(),\n vatPercentage: Joi.number().min(0).cast('string').required(),\n vatReason: Joi.string().empty(''),\n});\n\nexport const newFinanceDocV2Schema = Joi.object({\n id: Joi.string().uuid(),\n version: Joi.number().valid(2.0).default(2.0),\n reference: Joi.string().required(),\n type: Joi.string()\n .valid(...Object.values(FinanceDocType))\n .required(),\n subtype: Joi.string().required(),\n attachment: attachmentValueSchema.required(),\n branchId: Joi.string().required(),\n category: Joi.string().required(),\n organizationSummary: orgSummarySchema.required(),\n transferDescription: Joi.string().empty(''),\n invoiceId: Joi.string().uuid().empty(''),\n notes: Joi.string().empty(''),\n salesperson: Joi.object({\n name: Joi.string().required(),\n username: Joi.string().required(),\n }),\n paidAt: Joi.string().empty(''),\n tags: Joi.array().items(Joi.string().empty('')),\n total: Joi.object({\n amountExcl: Joi.number().min(0).cast('string').required(),\n amount: Joi.number().min(0).cast('string').required(),\n currencyCode: Joi.string().required(),\n foreign: Joi.object({\n amount: Joi.number().min(0).cast('string').required(),\n amountExcl: Joi.number().min(0).cast('string').required(),\n vatAmount: Joi.number().min(0).cast('string').required(),\n currencyCode: Joi.string().required(),\n exchangeRate: Joi.number().min(0).cast('string').required(),\n }),\n vatAmount: Joi.number().min(0).cast('string').required(),\n }),\n issueDate: isoDateSchema.required(),\n dueDate: isoDateSchema.empty(''),\n lines: Joi.array().items(lineSchema).required().default([]),\n reportingYear: Joi.number().min(0).cast('string'),\n reportingPeriod: Joi.number().min(0).cast('string'),\n accountingDescription: Joi.string().empty(''),\n});\n\nexport const newAdministrativedDocumentSchema = Joi.object({\n id: Joi.string(),\n displayName: Joi.string().empty(''),\n branchId: Joi.string().required(),\n attachment: attachmentValueSchema.required(),\n category: Joi.string().empty(''),\n tags: Joi.array().items(Joi.string().empty('')),\n associations: associationsSchema,\n organizationSummary: orgSummarySchema,\n});\n\nexport const AdministrativeDocumentSchema = newAdministrativedDocumentSchema.keys({\n id: Joi.string().required(),\n createdAt: Joi.string().required(),\n createdBy: Joi.string().required(),\n});\n"]}
1
+ {"version":3,"file":"schemas.js","sourceRoot":"/","sources":["schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,aAAa,GACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,GAAG,MAAM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S,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport {\n attachmentValueSchema,\n getPhoneSchema,\n isoDateSchema,\n} from '@bisondesk/commons/joi-schemas';\nimport { FinanceDocType } from '@bisondesk/documents-sdk/types/documents';\nimport Joi from 'joi';\n\nconst orgSummarySchema = Joi.object({\n id: Joi.string().required(),\n code: Joi.number().required(),\n name: Joi.string().empty('').required(),\n language: Joi.string().empty(''),\n vatNumber: Joi.string().empty(''),\n addressLine1: Joi.string().empty(''),\n addressLine2: Joi.string().empty(''),\n postcode: Joi.string().empty(''),\n city: Joi.string().empty(''),\n country: Joi.string().required(),\n emails: Joi.array().items(Joi.string().empty('').email()),\n phone: getPhoneSchema(),\n contact: Joi.object({\n name: Joi.string().empty('').required(),\n username: Joi.string().empty('').required(),\n }),\n});\n\nconst associationsSchema = Joi.array().items(\n Joi.object({\n businessEntityId: Joi.string()\n .valid(...Object.values(BusinessEntityIds))\n .required(),\n recordId: Joi.string().required(),\n title: Joi.string().required(),\n description: Joi.string().required(),\n tags: Joi.array().items(Joi.string().empty('')),\n linkTo: Joi.object({\n businessEntityId: Joi.string().required(),\n recordId: Joi.string().required(),\n }),\n })\n);\n\nexport const lineSchema = Joi.object({\n category: Joi.string().required(),\n amount: Joi.number().cast('string').required(),\n amountExcl: Joi.number().cast('string').required(),\n description: Joi.string().required(),\n foreign: Joi.object({\n amount: Joi.number().cast('string').required(),\n amountExcl: Joi.number().cast('string').required(),\n unitPriceExcl: Joi.number().cast('string').required(),\n vatAmount: Joi.number().cast('string').required(),\n }),\n invoiceLineId: Joi.string().empty('').uuid(),\n quantity: Joi.number().min(0).cast('string').required(),\n associations: associationsSchema,\n unitPriceExcl: Joi.number().cast('string').required(),\n vatAmount: Joi.number().cast('string').required(),\n vatCode: Joi.string().required(),\n vatPercentage: Joi.number().min(0).cast('string').required(),\n vatReason: Joi.string().empty(''),\n});\n\nexport const newFinanceDocV2Schema = Joi.object({\n id: Joi.string().uuid(),\n version: Joi.number().valid(2.0).default(2.0),\n reference: Joi.string().required(),\n type: Joi.string()\n .valid(...Object.values(FinanceDocType))\n .required(),\n subtype: Joi.string().required(),\n attachment: attachmentValueSchema.required(),\n branchId: Joi.string().required(),\n category: Joi.string().required(),\n organizationSummary: orgSummarySchema.required(),\n transferDescription: Joi.string().empty(''),\n invoiceId: Joi.string().uuid().empty(''),\n notes: Joi.string().empty(''),\n salesperson: Joi.object({\n name: Joi.string().required(),\n username: Joi.string().required(),\n }),\n paidAt: Joi.string().empty(''),\n tags: Joi.array().items(Joi.string().empty('')),\n total: Joi.object({\n amountExcl: Joi.number().min(0).cast('string').required(),\n amount: Joi.number().min(0).cast('string').required(),\n currencyCode: Joi.string().required(),\n foreign: Joi.object({\n amount: Joi.number().min(0).cast('string').required(),\n amountExcl: Joi.number().min(0).cast('string').required(),\n vatAmount: Joi.number().min(0).cast('string').required(),\n currencyCode: Joi.string().required(),\n exchangeRate: Joi.number().min(0).cast('string').required(),\n }),\n vatAmount: Joi.number().min(0).cast('string').required(),\n }),\n issueDate: isoDateSchema.required(),\n dueDate: isoDateSchema.empty(''),\n lines: Joi.array().items(lineSchema).required().default([]),\n reportingYear: Joi.number().min(0).cast('string'),\n reportingPeriod: Joi.number().min(0).cast('string'),\n accountingDescription: Joi.string().empty(''),\n peppol: Joi.object({\n extraAttachments: Joi.array()\n .items(\n attachmentValueSchema.keys({\n contentType: Joi.string().valid('application/pdf').required(),\n })\n )\n .max(9),\n }),\n});\n\nexport const newAdministrativedDocumentSchema = Joi.object({\n id: Joi.string(),\n displayName: Joi.string().empty(''),\n branchId: Joi.string().required(),\n attachment: attachmentValueSchema.required(),\n category: Joi.string().empty(''),\n tags: Joi.array().items(Joi.string().empty('')),\n associations: associationsSchema,\n organizationSummary: orgSummarySchema,\n});\n\nexport const AdministrativeDocumentSchema = newAdministrativedDocumentSchema.keys({\n id: Joi.string().required(),\n createdAt: Joi.string().required(),\n createdBy: Joi.string().required(),\n});\n"]}
@@ -107,6 +107,9 @@ export type FinanceDocumentV2 = BaseDocument & {
107
107
  bankAccounts?: BankAccountData[];
108
108
  externalQrCodeUrl?: string;
109
109
  externalId?: string;
110
+ peppol?: {
111
+ extraAttachments?: AttachmentValue[];
112
+ };
110
113
  };
111
114
  export type NewFinanceDocumentV2 = Omit<FinanceDocumentV2, 'id' | 'createdAt' | 'createdBy' | 'lines'> & {
112
115
  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,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AC1B,OAAO,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAE,GAAuB,CAAC,IAAI,CAAC,CAAC;AACtF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,KAAuC,EACoD,EAAE,CAC7F,KAAK,CAAC,YAAY,KAAK,YAAY,CAAC,cAAc,CAAC;AAErD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,GAAqC,EAC0C,EAAE;IACjF,OAAO,GAAG,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO,CAAC;AACnD,CAAC,CAAC;AAwEF,MAAM,CAAN,IAAY,sBAKX;AALD,WAAY,sBAAsB;IAChC,6CAAmB,CAAA;IACnB,oDAA0B,CAAA;IAC1B,+CAAqB,CAAA;IACrB,0DAAgC,CAAA;AAClC,CAAC,EALW,sBAAsB,KAAtB,sBAAsB,QAKjC;AAED,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,uEAA6C,CAAA;IAC7C,6EAAmD,CAAA;AACrD,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAED,MAAM,CAAN,IAAY,6BAEX;AAFD,WAAY,6BAA6B;IACvC,2FAA0D,CAAA;AAC5D,CAAC,EAFW,6BAA6B,KAA7B,6BAA6B,QAExC","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport { AttachmentValue, PhoneNumberValue } from '@bisondesk/commons-sdk/types';\nimport { BankAccountData } from './bank-accounts.js';\nimport { DocumentCategoryVisibility } from './document-categories.js';\nimport { FinanceDocumentV1 } from './legacy.js';\n\nexport type FinanceDocument = FinanceDocumentV1 | FinanceDocumentV2;\n\nexport type Association = {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n title: string;\n description: string;\n tags?: string[];\n linkTo?: {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n };\n};\n\nexport type FinanceDocumentLine = {\n id: string;\n category: string; // abstraction used to map lines to GL accounts (e.g., deposit, insurance)\n amount: string;\n amountExcl: string; // quantity * unit price\n description: string;\n foreign?: {\n amount: string;\n amountExcl: string;\n unitPriceExcl: string;\n vatAmount: string;\n };\n invoiceLineId?: string; // used by credit notes\n quantity: string;\n associations?: Association[];\n unitPriceExcl: string;\n vatAmount: string;\n vatCode: string;\n vatPercentage: string;\n vatReason?: string;\n\n externalId?: string; // id used by external systems (e.g., accounting integration)\n};\n\ntype OrgSummary = {\n id: string;\n code: number;\n name: string;\n vatNumber?: string;\n\n addressLine1?: string;\n addressLine2?: string;\n postcode?: string;\n city?: string;\n country: string;\n\n emails?: string[];\n phone?: PhoneNumberValue;\n\n // TODO person name?\n contact?: {\n name: string;\n username: string;\n };\n};\n\nexport enum FinanceDocType {\n Sale = 'Sale Finance',\n Purchase = 'Purchase Finance',\n}\n\ntype BaseDocument = {\n id: string;\n branchId: string;\n attachment: AttachmentValue;\n createdAt: string;\n createdBy: string;\n};\n\nexport type FinanceDocumentV2 = BaseDocument & {\n version: 2.0;\n language?: string;\n autoGenerated?: boolean;\n reference: string;\n subtype: FinanceDocumentSubtype;\n type: FinanceDocType;\n category: string;\n visibility?: DocumentCategoryVisibility;\n organizationSummary: OrgSummary;\n\n dueDate?: string;\n transferDescription?: string; // we ask clients to put this as description of the transfer\n invoiceId?: string; // mandatory in credit notes but optional in invoices on invoices represents a reissued invoice\n issueDate: string;\n lines: FinanceDocumentLine[];\n accountingLines?: FinanceDocumentLine[];\n notes?: string;\n salesperson?: {\n name: string;\n username: string;\n };\n tags: string[]; // optional values used to improve document search\n total: {\n amountExcl: string;\n amount: string;\n currencyCode: string; // from the branch\n foreign?: {\n amount: string;\n amountExcl: string;\n vatAmount: string;\n currencyCode: string;\n exchangeRate: string;\n };\n vatAmount: string;\n };\n\n paidAt?: string; // ONLY for when accounting integration is not used. Otherwise ALWAYS look at the Finance Booking paidAt\n\n reportingPeriod?: string;\n reportingYear?: string;\n accountingDescription?: string;\n\n // mostly for the case we want to regenerate the document pdf again\n bankAccounts?: BankAccountData[];\n\n externalQrCodeUrl?: string; // QR code data to be rendered on the document\n externalId?: string; // id used by external systems (e.g., accounting integration, storecove)\n};\n\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 // whether the provider enforces credit notes to be linked to an invoice\n // lines. Eg can't change description of line values\n strictCreditNotes?: boolean;\n // whether the companies from the same country of the branch must provide\n // a vat number to generate sale finance documents\n mandatoryLocalOrganizationVatNumber?: boolean;\n meta: M;\n};\n\nexport type BisondeskMetaFinanceDocumentSettings = {\n [key in FinanceDocumentSubtype]: {\n templateId: string;\n };\n};\n\nexport type FinanceDocumentBisondeskSettings = {\n [FinanceDocumentSubtype.Invoice]: {\n prefix: string;\n templateId: string;\n };\n [FinanceDocumentSubtype.CreditNote]: {\n prefix: string;\n templateId: string;\n };\n};\n\nexport type FinanceDocumentPayment = {\n documentId: string;\n reference: string;\n attachment: AttachmentValue;\n} & ({ paid: true; paidAt: string } | { paid: false; paidAt?: undefined });\n\nexport enum FinanceDocumentSubtype {\n Invoice = 'Invoice',\n CreditNote = 'Credit Note',\n Proforma = 'Proforma',\n PurchaseOrder = 'Purchase Order',\n}\n\nexport enum FinanceDocumentActions {\n PAY_FINANCE_DOCUMENT = 'pay_finance_document',\n DELETE_FINANCE_DOCUMENT = 'delete_finance_document',\n}\n\nexport enum AdministrativeDocumentActions {\n DELETE_ADMINISTRATIVE_DOCUMENT = 'delete_finance_document',\n}\n\nexport type AdministrativeUpdateOperation =\n | {\n association?: undefined;\n doc: AdministrativeDocument;\n op: 'replace';\n }\n | {\n association?: undefined;\n doc: NewAdministrativeDocument;\n op: 'add';\n }\n | {\n association: {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n documentId: string;\n };\n doc?: undefined;\n op: 'remove-association';\n };\n"]}
1
+ {"version":3,"file":"documents.js","sourceRoot":"/","sources":["types/documents.ts"],"names":[],"mappings":"AAkEA,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,+CAA6B,CAAA;AAC/B,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAmFD,MAAM,CAAN,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,iDAA2B,CAAA;IAC3B,6CAAuB,CAAA;IACvB,qDAA+B,CAAA;IAC/B,yDAAmC,CAAA;IACnC,6CAAuB,CAAA;AACzB,CAAC,EAPW,kBAAkB,KAAlB,kBAAkB,QAO7B;AAED,MAAM,CAAN,IAAY,iBAOX;AAPD,WAAY,iBAAiB;IAC3B,kDAA6B,CAAA;IAC7B,8CAAyB,CAAA;IACzB,8DAAyC,CAAA;IACzC,kEAA6C,CAAA;IAC7C,0DAAqC,CAAA;IACrC,kCAAa,CAAA;AACf,CAAC,EAPW,iBAAiB,KAAjB,iBAAiB,QAO5B;AAqCD,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,4CAA4B,CAAA;IAC5B,0DAA0C,CAAA;AAC5C,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AA6BD,MAAM,CAAN,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,4CAA4B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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 externalId?: string; // id used by external systems (e.g., accounting integration)\n};\n\ntype OrgSummary = {\n id: string;\n code: number;\n name: string;\n vatNumber?: string;\n\n addressLine1?: string;\n addressLine2?: string;\n postcode?: string;\n city?: string;\n country: string;\n\n emails?: string[];\n phone?: PhoneNumberValue;\n\n // TODO person name?\n contact?: {\n name: string;\n username: string;\n };\n};\n\nexport enum FinanceDocType {\n Sale = 'Sale Finance',\n Purchase = 'Purchase Finance',\n}\n\ntype BaseDocument = {\n id: string;\n branchId: string;\n attachment: AttachmentValue;\n createdAt: string;\n createdBy: string;\n};\n\nexport type FinanceDocumentV2 = BaseDocument & {\n version: 2.0;\n language?: string;\n autoGenerated?: boolean;\n reference: string;\n subtype: FinanceDocumentSubtype;\n type: FinanceDocType;\n category: string;\n visibility?: DocumentCategoryVisibility;\n organizationSummary: OrgSummary;\n\n dueDate?: string;\n transferDescription?: string; // we ask clients to put this as description of the transfer\n invoiceId?: string; // mandatory in credit notes but optional in invoices on invoices represents a reissued invoice\n issueDate: string;\n lines: FinanceDocumentLine[];\n accountingLines?: FinanceDocumentLine[];\n notes?: string;\n salesperson?: {\n name: string;\n username: string;\n };\n tags: string[]; // optional values used to improve document search\n total: {\n amountExcl: string;\n amount: string;\n currencyCode: string; // from the branch\n foreign?: {\n amount: string;\n amountExcl: string;\n vatAmount: string;\n currencyCode: string;\n exchangeRate: string;\n };\n vatAmount: string;\n };\n\n paidAt?: string; // ONLY for when accounting integration is not used. Otherwise ALWAYS look at the Finance Booking paidAt\n\n reportingPeriod?: string;\n reportingYear?: string;\n accountingDescription?: string;\n\n // mostly for the case we want to regenerate the document pdf again\n bankAccounts?: BankAccountData[];\n\n externalQrCodeUrl?: string; // QR code data to be rendered on the document\n externalId?: string; // id used by external systems (e.g., accounting integration, storecove)\n\n peppol?: {\n extraAttachments?: AttachmentValue[];\n };\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 // whether the provider enforces credit notes to be linked to an invoice\n // lines. Eg can't change description of line values\n strictCreditNotes?: boolean;\n // whether the companies from the same country of the branch must provide\n // a vat number to generate sale finance documents\n mandatoryLocalOrganizationVatNumber?: boolean;\n meta: M;\n};\n\nexport type BisondeskMetaFinanceDocumentSettings = {\n [key in FinanceDocumentSubtype]: {\n templateId: string;\n };\n};\n\nexport type FinanceDocumentBisondeskSettings = {\n [FinanceDocumentSubtype.Invoice]: {\n prefix: string;\n templateId: string;\n };\n [FinanceDocumentSubtype.CreditNote]: {\n prefix: string;\n templateId: string;\n };\n};\n\nexport type FinanceDocumentPayment = {\n documentId: string;\n reference: string;\n attachment: AttachmentValue;\n} & ({ paid: true; paidAt: string } | { paid: false; paidAt?: undefined });\n\nexport enum FinanceDocumentSubtype {\n Invoice = 'Invoice',\n CreditNote = 'Credit Note',\n Proforma = 'Proforma',\n PurchaseOrder = 'Purchase Order',\n}\n\nexport enum FinanceDocumentActions {\n PAY_FINANCE_DOCUMENT = 'pay_finance_document',\n DELETE_FINANCE_DOCUMENT = 'delete_finance_document',\n}\n\nexport enum AdministrativeDocumentActions {\n DELETE_ADMINISTRATIVE_DOCUMENT = 'delete_finance_document',\n}\n\nexport type AdministrativeUpdateOperation =\n | {\n association?: undefined;\n doc: AdministrativeDocument;\n op: 'replace';\n }\n | {\n association?: undefined;\n doc: NewAdministrativeDocument;\n op: 'add';\n }\n | {\n association: {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n documentId: string;\n };\n doc?: undefined;\n op: 'remove-association';\n };\n"]}
@@ -14,7 +14,7 @@ export const documentGoesToStorecove = (doc) => {
14
14
  }
15
15
  const vatNumber = doc.organizationSummary.vatNumber;
16
16
  const isBeCountry = doc.organizationSummary.country === 'be';
17
- const isBEVAT = (isBeCountry && vatNumber?.startsWith('BE')) || false;
17
+ const isBEVAT = (isBeCountry && vatNumber?.toLowerCase().startsWith('be')) || false;
18
18
  return isBEVAT && documentGoesToAccounting(doc);
19
19
  };
20
20
  export const getAccountingDescription = (doc) => {
@@ -1 +1 @@
1
- {"version":3,"file":"finance.js","sourceRoot":"/","sources":["utils/finance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;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,KAAK,QAAQ;gBAC5B,KAAK,CAAC,aAAa,KAAK,QAAQ;gBAChC,KAAK,CAAC,EAAE,KAAK,QAAQ,CACtB,CAAC;QACJ,CAAC,CAAC,CACH;aACA,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACd,GAAG,IAAI;YACP,kBAAkB,EAAE,yBAAyB,CAC3C,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?.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,CAAC;AAG/B,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,GAIqB,EACZ,EAAE;IACX,OAAO,CACL,CAAC,CAAC,GAAG,CAAC,OAAO;QACb,CAAC,sBAAsB,CAAC,OAAO,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC,QAAQ,CAC1E,GAAG,CAAC,OAAiC,CACtC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,GAIqB,EACZ,EAAE;IACX,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,SAAS,GAAG,GAAG,CAAC,mBAAmB,CAAC,SAAS,CAAC;IACpD,MAAM,WAAW,GAAG,GAAG,CAAC,mBAAmB,CAAC,OAAO,KAAK,IAAI,CAAC;IAC7D,MAAM,OAAO,GAAG,CAAC,WAAW,IAAI,SAAS,EAAE,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,C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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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bisondesk/documents-sdk",
3
- "version": "1.0.546",
3
+ "version": "1.0.547",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/schemas.ts CHANGED
@@ -103,6 +103,15 @@ export const newFinanceDocV2Schema = Joi.object({
103
103
  reportingYear: Joi.number().min(0).cast('string'),
104
104
  reportingPeriod: Joi.number().min(0).cast('string'),
105
105
  accountingDescription: Joi.string().empty(''),
106
+ peppol: Joi.object({
107
+ extraAttachments: Joi.array()
108
+ .items(
109
+ attachmentValueSchema.keys({
110
+ contentType: Joi.string().valid('application/pdf').required(),
111
+ })
112
+ )
113
+ .max(9),
114
+ }),
106
115
  });
107
116
 
108
117
  export const newAdministrativedDocumentSchema = Joi.object({
@@ -125,6 +125,10 @@ export type FinanceDocumentV2 = BaseDocument & {
125
125
 
126
126
  externalQrCodeUrl?: string; // QR code data to be rendered on the document
127
127
  externalId?: string; // id used by external systems (e.g., accounting integration, storecove)
128
+
129
+ peppol?: {
130
+ extraAttachments?: AttachmentValue[];
131
+ };
128
132
  };
129
133
 
130
134
  export type NewFinanceDocumentV2 = Omit<
@@ -45,7 +45,7 @@ export const documentGoesToStorecove = (
45
45
  }
46
46
  const vatNumber = doc.organizationSummary.vatNumber;
47
47
  const isBeCountry = doc.organizationSummary.country === 'be';
48
- const isBEVAT = (isBeCountry && vatNumber?.startsWith('BE')) || false;
48
+ const isBEVAT = (isBeCountry && vatNumber?.toLowerCase().startsWith('be')) || false;
49
49
  return isBEVAT && documentGoesToAccounting(doc);
50
50
  };
51
51