@bisondesk/documents-sdk 1.0.318 → 1.0.320
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/apis/document-drafts.d.ts +4 -0
- package/lib/apis/document-drafts.d.ts.map +1 -0
- package/lib/apis/document-drafts.js +45 -0
- package/lib/apis/document-drafts.js.map +1 -0
- package/lib/apis/documents.d.ts +3 -0
- package/lib/apis/documents.d.ts.map +1 -1
- package/lib/apis/documents.js +41 -3
- package/lib/apis/documents.js.map +1 -1
- package/lib/schemas.d.ts +6 -0
- package/lib/schemas.d.ts.map +1 -0
- package/lib/schemas.js +105 -0
- package/lib/schemas.js.map +1 -0
- package/lib/types/booking.d.ts +9 -3
- package/lib/types/booking.d.ts.map +1 -1
- package/lib/types/booking.js.map +1 -1
- package/lib/types/document-categories.d.ts +23 -5
- package/lib/types/document-categories.d.ts.map +1 -1
- package/lib/types/document-categories.js.map +1 -1
- package/lib/types/documents.d.ts +23 -3
- package/lib/types/documents.d.ts.map +1 -1
- package/lib/types/documents.js +7 -0
- package/lib/types/documents.js.map +1 -1
- package/lib/types/events.d.ts +2 -2
- package/lib/types/events.d.ts.map +1 -1
- package/lib/types/events.js.map +1 -1
- package/lib/types/legacy.d.ts +1 -0
- package/lib/types/legacy.d.ts.map +1 -1
- package/lib/types/legacy.js.map +1 -1
- package/lib/types/search.d.ts +9 -8
- package/lib/types/search.d.ts.map +1 -1
- package/lib/types/search.js.map +1 -1
- package/lib/types/vat.d.ts +1 -1
- package/lib/types/vat.d.ts.map +1 -1
- package/lib/types/vat.js.map +1 -1
- package/lib/utils/associations.d.ts +6 -0
- package/lib/utils/associations.d.ts.map +1 -0
- package/lib/utils/associations.js +9 -0
- package/lib/utils/associations.js.map +1 -0
- package/lib/{utils.d.ts → utils/previews.d.ts} +1 -1
- package/lib/utils/previews.d.ts.map +1 -0
- package/lib/{utils.js → utils/previews.js} +1 -1
- package/lib/utils/previews.js.map +1 -0
- package/package.json +1 -1
- package/src/apis/document-drafts.ts +68 -0
- package/src/apis/documents.ts +60 -3
- package/src/schemas.ts +112 -0
- package/src/types/booking.ts +4 -3
- package/src/types/document-categories.ts +28 -6
- package/src/types/documents.ts +33 -3
- package/src/types/events.ts +2 -2
- package/src/types/legacy.ts +1 -0
- package/src/types/search.ts +10 -8
- package/src/types/vat.ts +1 -1
- package/src/utils/associations.ts +21 -0
- package/tsconfig.deploy.tsbuildinfo +1 -1
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js.map +0 -1
- /package/src/{utils.ts → utils/previews.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"/","sources":["types/events.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"/","sources":["types/events.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,cAAc,GAAG,kBAAkB,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
package/lib/types/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"/","sources":["types/events.ts"],"names":[],"mappings":"","sourcesContent":["export type FinanceDocumentEvent = {\n id: string;\n actionAt: string;\n action: '
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"/","sources":["types/events.ts"],"names":[],"mappings":"","sourcesContent":["export type FinanceDocumentEvent = {\n id: string;\n actionAt: string;\n action: 'create' | 'update' | 'delete';\n userId: string;\n tenantId: string;\n type: 'Sale Finance' | 'Purchase Finance';\n};\n\nexport type AdminDocumentEvent = {\n id: string;\n actionAt: string;\n action: 'upsert' | 'delete';\n userId: string;\n tenantId: string;\n category: string;\n};\n"]}
|
package/lib/types/legacy.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.d.ts","sourceRoot":"/","sources":["types/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY,EAAE;QACZ,MAAM,EAAE;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC/C,KAAK,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1D,SAAS,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAC/D,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,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,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mBAAmB,CAAC,EAAE;QACpB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACH,CAAC"}
|
package/lib/types/legacy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.js","sourceRoot":"/","sources":["types/legacy.ts"],"names":[],"mappings":"","sourcesContent":["import { AttachmentValue } from '@bisondesk/commons-sdk/types';\n\nexport type FinanceLineV1 = {\n associations: {\n others: { vehicleId: string; label: string }[];\n sales: { id: string; vehicleId: string; label: string }[];\n purchases: { id: string; vehicleId: string; label: string }[];\n };\n description: string;\n id: string;\n lineCode: string;\n quantity: string;\n unitPriceExclusive: string;\n vatCode: string;\n vatCoefficient: string;\n};\n\nexport type FinanceDocumentV1 = {\n id: string;\n branchId: string;\n version?: 1.0;\n\n type: 'Sale Finance' | 'Purchase Finance';\n subtype: 'Invoice' | 'Credit Note' | 'Proforma' | 'Purchase Order';\n reference: string;\n\n attachment: AttachmentValue;\n lines: FinanceLineV1[];\n notes?: string;\n\n createdAt: string;\n createdBy: string;\n issueDate: string;\n paidAt?: string;\n paymentNotes?: string;\n amount?: string;\n dueDate?: string;\n\n organizationSummary?: {\n id: string;\n code: string;\n name: string;\n country: string;\n vatNumber?: string;\n\n addressLine1?: string;\n addressLine2?: string;\n addressLine3?: string;\n postcode?: string;\n city?: string;\n\n email?: string;\n phone?: string;\n fax?: string;\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"legacy.js","sourceRoot":"/","sources":["types/legacy.ts"],"names":[],"mappings":"","sourcesContent":["import { AttachmentValue } from '@bisondesk/commons-sdk/types';\n\nexport type FinanceLineV1 = {\n associations: {\n others: { vehicleId: string; label: string }[];\n sales: { id: string; vehicleId: string; label: string }[];\n purchases: { id: string; vehicleId: string; label: string }[];\n };\n description: string;\n id: string;\n lineCode: string;\n quantity: string;\n unitPriceExclusive: string;\n vatCode: string;\n vatCoefficient: string;\n};\n\nexport type FinanceDocumentV1 = {\n id: string;\n branchId: string;\n version?: 1.0;\n\n type: 'Sale Finance' | 'Purchase Finance';\n subtype: 'Invoice' | 'Credit Note' | 'Proforma' | 'Purchase Order';\n reference: string;\n\n attachment: AttachmentValue;\n lines: FinanceLineV1[];\n accountingOnlyLines?: FinanceLineV1[];\n notes?: string;\n\n createdAt: string;\n createdBy: string;\n issueDate: string;\n paidAt?: string;\n paymentNotes?: string;\n amount?: string;\n dueDate?: string;\n\n organizationSummary?: {\n id: string;\n code: string;\n name: string;\n country: string;\n vatNumber?: string;\n\n addressLine1?: string;\n addressLine2?: string;\n addressLine3?: string;\n postcode?: string;\n city?: string;\n\n email?: string;\n phone?: string;\n fax?: string;\n };\n};\n"]}
|
package/lib/types/search.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';
|
|
2
|
+
import { PaginatedRequest, SearchPermissions } from '@bisondesk/commons-sdk/types';
|
|
2
3
|
import { Organization } from '@bisondesk/core-sdk/types/crm';
|
|
3
4
|
import { PublicSearchDefinition } from '@bisondesk/core-sdk/types/definitions';
|
|
4
5
|
import { FinanceBooking } from './booking.js';
|
|
5
|
-
import { AdministrativeDocument, FinanceDocument } from './documents.js';
|
|
6
|
+
import { AdministrativeDocument, DocumentType, FinanceDocument } from './documents.js';
|
|
6
7
|
export type SearchDocumentVehicleRef = {
|
|
7
8
|
id: string;
|
|
8
9
|
stockNumber: string;
|
|
@@ -11,9 +12,7 @@ export type SearchDocumentVehicleRef = {
|
|
|
11
12
|
export type InputSearchFinanceDocument = SearchFinanceDocument & {
|
|
12
13
|
permissions: SearchPermissions;
|
|
13
14
|
};
|
|
14
|
-
export type InputSearchAdministrativeDocument = SearchAdministrativeDocument
|
|
15
|
-
permissions: SearchPermissions;
|
|
16
|
-
};
|
|
15
|
+
export type InputSearchAdministrativeDocument = SearchAdministrativeDocument;
|
|
17
16
|
export type DocsSearchDefinitions = {
|
|
18
17
|
searchFinanceDoc: PublicSearchDefinition;
|
|
19
18
|
};
|
|
@@ -25,12 +24,14 @@ export type SearchFinanceDocument = {
|
|
|
25
24
|
org?: Organization;
|
|
26
25
|
doc: FinanceDocument;
|
|
27
26
|
booking?: FinanceBooking;
|
|
28
|
-
vehicle?: SearchDocumentVehicleRef[];
|
|
29
27
|
};
|
|
30
28
|
export type SearchAdministrativeDocument = {
|
|
31
29
|
doc: AdministrativeDocument;
|
|
32
30
|
permissions: SearchPermissions;
|
|
33
|
-
org?: Organization;
|
|
34
|
-
vehicle?: SearchDocumentVehicleRef[];
|
|
35
31
|
};
|
|
32
|
+
export type RelatedDocumentsRequest = {
|
|
33
|
+
businessEntityId: BusinessEntityIds;
|
|
34
|
+
recordId: string;
|
|
35
|
+
docTypes?: DocumentType[];
|
|
36
|
+
} & PaginatedRequest;
|
|
36
37
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"/","sources":["types/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"/","sources":["types/search.ts"],"names":[],"mappings":"AAA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3B,GAAG,gBAAgB,CAAC"}
|
package/lib/types/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"/","sources":["types/search.ts"],"names":[],"mappings":"","sourcesContent":["import { 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 { AdministrativeDocument, FinanceDocument } 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
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"/","sources":["types/search.ts"],"names":[],"mappings":"","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\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 { AdministrativeDocument, DocumentType, FinanceDocument } 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 type SearchFinanceDocument = {\n permissions: SearchPermissions;\n org?: Organization;\n doc: FinanceDocument;\n booking?: FinanceBooking;\n};\n\nexport type SearchAdministrativeDocument = {\n doc: AdministrativeDocument;\n permissions: SearchPermissions;\n};\n\nexport type RelatedDocumentsRequest = {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n docTypes?: DocumentType[];\n} & PaginatedRequest;\n"]}
|
package/lib/types/vat.d.ts
CHANGED
package/lib/types/vat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vat.d.ts","sourceRoot":"/","sources":["types/vat.ts"],"names":[],"mappings":"AACA,oBAAY,qBAAqB;IAC/B,iBAAiB,MAAM;IACvB,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,YAAY,MAAM;IAClB,aAAa,OAAO;IACpB,QAAQ,MAAM;IACd,SAAS,MAAM;CAChB;AAGD,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"vat.d.ts","sourceRoot":"/","sources":["types/vat.ts"],"names":[],"mappings":"AACA,oBAAY,qBAAqB;IAC/B,iBAAiB,MAAM;IACvB,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,YAAY,MAAM;IAClB,aAAa,OAAO;IACpB,QAAQ,MAAM;IACd,SAAS,MAAM;CAChB;AAGD,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,qBAAqB,CAAC;IAErC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAE7C,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC"}
|
package/lib/types/vat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vat.js","sourceRoot":"/","sources":["types/vat.ts"],"names":[],"mappings":"AACA,MAAM,CAAN,IAAY,qBASX;AATD,WAAY,qBAAqB;IAC/B,gDAAuB,CAAA;IACvB,qCAAY,CAAA;IACZ,qCAAY,CAAA;IACZ,qCAAY,CAAA;IACZ,2CAAkB,CAAA;IAClB,6CAAoB,CAAA;IACpB,uCAAc,CAAA;IACd,wCAAe,CAAA;AACjB,CAAC,EATW,qBAAqB,KAArB,qBAAqB,QAShC","sourcesContent":["// subset of codes from UN 5305 used in Peppol\nexport enum InternationalTaxCodes {\n EeaIntraCommunity = 'K',\n Exempt = 'E',\n Export = 'G',\n Margin = 'F',\n OutsideScope = 'O',\n ReverseCharge = 'AE',\n Standard = 'S',\n ZeroRated = 'Z',\n}\n\n// TODO: Add display order? Or sort by createdAt?\nexport type VatCode = {\n id: string;\n branchId: string;\n\n code: string; // accountingCode: string;\n default: boolean;\n description: string;\n rate: string;\n
|
|
1
|
+
{"version":3,"file":"vat.js","sourceRoot":"/","sources":["types/vat.ts"],"names":[],"mappings":"AACA,MAAM,CAAN,IAAY,qBASX;AATD,WAAY,qBAAqB;IAC/B,gDAAuB,CAAA;IACvB,qCAAY,CAAA;IACZ,qCAAY,CAAA;IACZ,qCAAY,CAAA;IACZ,2CAAkB,CAAA;IAClB,6CAAoB,CAAA;IACpB,uCAAc,CAAA;IACd,wCAAe,CAAA;AACjB,CAAC,EATW,qBAAqB,KAArB,qBAAqB,QAShC","sourcesContent":["// subset of codes from UN 5305 used in Peppol\nexport enum InternationalTaxCodes {\n EeaIntraCommunity = 'K',\n Exempt = 'E',\n Export = 'G',\n Margin = 'F',\n OutsideScope = 'O',\n ReverseCharge = 'AE',\n Standard = 'S',\n ZeroRated = 'Z',\n}\n\n// TODO: Add display order? Or sort by createdAt?\nexport type VatCode = {\n id: string;\n branchId: string;\n\n code: string; // accountingCode: string;\n default: boolean;\n description: string;\n rate: string;\n eInvoiceCode?: InternationalTaxCodes;\n\n reason?: string; // legal text added when this code is used\n};\n\nexport type NewVatCode = Omit<VatCode, 'id'>;\n\nexport type VatCodeDefaultUpdate = {\n id: string;\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';
|
|
2
|
+
import { GlobalBusinessEntity } from '@bisondesk/core-sdk/utils/search';
|
|
3
|
+
import { Association } from '../types/documents.js';
|
|
4
|
+
export type SupportedAssociationEntity = GlobalBusinessEntity;
|
|
5
|
+
export declare const getAssociationForBusinessEntity: (businessEntityId: BusinessEntityIds, record: SupportedAssociationEntity) => Association;
|
|
6
|
+
//# sourceMappingURL=associations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"associations.d.ts","sourceRoot":"/","sources":["utils/associations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,oBAAoB,EAIrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAE9D,eAAO,MAAM,+BAA+B,qBACxB,iBAAiB,UAC3B,0BAA0B,KACjC,WAMD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getDescriptionForBusinessEntity, getTagsForBusinessEntity, getTitleForBusinessEntity, } from '@bisondesk/core-sdk/utils/search';
|
|
2
|
+
export const getAssociationForBusinessEntity = (businessEntityId, record) => ({
|
|
3
|
+
businessEntityId,
|
|
4
|
+
recordId: record.id,
|
|
5
|
+
title: getTitleForBusinessEntity(businessEntityId, record),
|
|
6
|
+
description: getDescriptionForBusinessEntity(businessEntityId, record),
|
|
7
|
+
tags: getTagsForBusinessEntity(businessEntityId, record),
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=associations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"associations.js","sourceRoot":"/","sources":["utils/associations.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,kCAAkC,CAAC;AAK1C,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,gBAAmC,EACnC,MAAkC,EACrB,EAAE,CAAC,CAAC;IACjB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC,EAAE;IACnB,KAAK,EAAE,yBAAyB,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAC1D,WAAW,EAAE,+BAA+B,CAAC,gBAAgB,EAAE,MAAM,CAAC;IACtE,IAAI,EAAE,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACzD,CAAC,CAAC","sourcesContent":["import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';\nimport {\n GlobalBusinessEntity,\n getDescriptionForBusinessEntity,\n getTagsForBusinessEntity,\n getTitleForBusinessEntity,\n} from '@bisondesk/core-sdk/utils/search';\nimport { Association } from '../types/documents.js';\n\nexport type SupportedAssociationEntity = GlobalBusinessEntity;\n\nexport const getAssociationForBusinessEntity = (\n businessEntityId: BusinessEntityIds,\n record: SupportedAssociationEntity\n): Association => ({\n businessEntityId,\n recordId: record.id,\n title: getTitleForBusinessEntity(businessEntityId, record),\n description: getDescriptionForBusinessEntity(businessEntityId, record),\n tags: getTagsForBusinessEntity(businessEntityId, record),\n});\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const getPdfPreviewSrc: (fileUrl: string) => string;
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=previews.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"previews.d.ts","sourceRoot":"/","sources":["utils/previews.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,YAAa,MAAM,WAAsC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const getPdfPreviewSrc = (fileUrl) => fileUrl.replace('.pdf', '/1.jpg');
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=previews.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"previews.js","sourceRoot":"/","sources":["utils/previews.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["export const getPdfPreviewSrc = (fileUrl: string) => fileUrl.replace('.pdf', '/1.jpg');\n"]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FinanceDocumentCategory,
|
|
3
|
+
FinanceDocumentLineCategory,
|
|
4
|
+
} from '../types/document-categories.js';
|
|
5
|
+
import { getAdminAuth } from '@bisondesk/commons-sdk/fetch';
|
|
6
|
+
import fetch, { Response } from 'node-fetch';
|
|
7
|
+
import { TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/constants';
|
|
8
|
+
import { XError } from '@bisondesk/commons-sdk/errors';
|
|
9
|
+
|
|
10
|
+
export const getFinanceDocumentCategory = async (
|
|
11
|
+
tenantId: string,
|
|
12
|
+
branchId: string,
|
|
13
|
+
docCategoryId: string
|
|
14
|
+
): Promise<FinanceDocumentCategory | undefined> => {
|
|
15
|
+
const auth = await getAdminAuth();
|
|
16
|
+
const response: Response = await fetch(
|
|
17
|
+
`${process.env.DOCUMENT_DRAFTS_API_ORIGIN}/api/documents/settings/${branchId}/document-categories/${docCategoryId}`,
|
|
18
|
+
{
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: auth,
|
|
21
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (response.status === 200) {
|
|
27
|
+
return response.json() as any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const body = await response.text();
|
|
31
|
+
throw new XError('documents-sdk.drafts.get-doc-category-fail', {
|
|
32
|
+
tenantId,
|
|
33
|
+
branchId,
|
|
34
|
+
docCategoryId,
|
|
35
|
+
response: body,
|
|
36
|
+
status: response.status,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const listFinanceLineCategories = async (
|
|
41
|
+
tenantId: string,
|
|
42
|
+
branchId: string,
|
|
43
|
+
docCategoryId: string
|
|
44
|
+
): Promise<FinanceDocumentLineCategory[]> => {
|
|
45
|
+
const auth = await getAdminAuth();
|
|
46
|
+
const response: Response = await fetch(
|
|
47
|
+
`${process.env.DOCUMENT_DRAFTS_API_ORIGIN}/api/documents/settings/${branchId}/document-categories/${docCategoryId}/line-categories`,
|
|
48
|
+
{
|
|
49
|
+
headers: {
|
|
50
|
+
Authorization: auth,
|
|
51
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
if (response.status === 200) {
|
|
57
|
+
return response.json() as any;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const body = await response.text();
|
|
61
|
+
throw new XError('documents-sdk.drafts.get-doc-lines-categories-fail', {
|
|
62
|
+
tenantId,
|
|
63
|
+
branchId,
|
|
64
|
+
docCategoryId,
|
|
65
|
+
response: body,
|
|
66
|
+
status: response.status,
|
|
67
|
+
});
|
|
68
|
+
};
|
package/src/apis/documents.ts
CHANGED
|
@@ -1,10 +1,67 @@
|
|
|
1
1
|
import { TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/constants';
|
|
2
2
|
import { XError } from '@bisondesk/commons-sdk/errors';
|
|
3
3
|
import { getAdminAuth } from '@bisondesk/commons-sdk/fetch';
|
|
4
|
+
import { DataRecord, ReferenceData } from '@bisondesk/core-sdk/types/utils';
|
|
4
5
|
import fetch, { Response } from 'node-fetch';
|
|
5
6
|
import { FinanceBooking } from '../types/booking.js';
|
|
6
7
|
import { AdministrativeDocument, FinanceDocument } from '../types/documents.js';
|
|
7
8
|
|
|
9
|
+
export const getFinanceDocument = async (
|
|
10
|
+
tenantId: string,
|
|
11
|
+
documentId: string
|
|
12
|
+
): Promise<DataRecord<FinanceDocument, ReferenceData> | undefined> => {
|
|
13
|
+
const auth = await getAdminAuth();
|
|
14
|
+
const response: Response = await fetch(
|
|
15
|
+
`${process.env.CORE_API_ORIGIN}/api/documents/finance/${documentId}`,
|
|
16
|
+
{
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: auth,
|
|
19
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (response.status === 200) {
|
|
25
|
+
return response.json() as any;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const body = await response.text();
|
|
29
|
+
throw new XError('documents-sdk.get-finance-doc-fail', {
|
|
30
|
+
tenantId,
|
|
31
|
+
documentId,
|
|
32
|
+
response: body,
|
|
33
|
+
status: response.status,
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const getFinanceBookingByDocId = async (
|
|
38
|
+
tenantId: string,
|
|
39
|
+
documentId: string
|
|
40
|
+
): Promise<FinanceBooking | undefined> => {
|
|
41
|
+
const auth = await getAdminAuth();
|
|
42
|
+
const response: Response = await fetch(
|
|
43
|
+
`${process.env.CORE_API_ORIGIN}/api/documents/finance/${documentId}/booking`,
|
|
44
|
+
{
|
|
45
|
+
headers: {
|
|
46
|
+
Authorization: auth,
|
|
47
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
if (response.status === 200) {
|
|
53
|
+
return response.json() as any;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const body = await response.text();
|
|
57
|
+
throw new XError('documents-sdk.get-finance-booking-fail', {
|
|
58
|
+
tenantId,
|
|
59
|
+
documentId,
|
|
60
|
+
response: body,
|
|
61
|
+
status: response.status,
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
8
65
|
export const upsertFinanceDoc = async (
|
|
9
66
|
tenantId: string,
|
|
10
67
|
doc: FinanceDocument
|
|
@@ -25,7 +82,7 @@ export const upsertFinanceDoc = async (
|
|
|
25
82
|
}
|
|
26
83
|
|
|
27
84
|
const body = await response.text();
|
|
28
|
-
throw new XError('
|
|
85
|
+
throw new XError('documents-sdk.upsert-finance-doc-fail', {
|
|
29
86
|
tenantId,
|
|
30
87
|
doc,
|
|
31
88
|
response: body,
|
|
@@ -56,7 +113,7 @@ export const upsertAdminDoc = async (
|
|
|
56
113
|
}
|
|
57
114
|
|
|
58
115
|
const body = await response.text();
|
|
59
|
-
throw new XError('
|
|
116
|
+
throw new XError('documents-sdk.upsert-admin-doc-fail', {
|
|
60
117
|
tenantId,
|
|
61
118
|
doc,
|
|
62
119
|
response: body,
|
|
@@ -87,7 +144,7 @@ export const upsertFinanceBooking = async (
|
|
|
87
144
|
}
|
|
88
145
|
|
|
89
146
|
const body = await response.text();
|
|
90
|
-
throw new XError('
|
|
147
|
+
throw new XError('documents-sdk.upsert-finance-booking-fail', {
|
|
91
148
|
tenantId,
|
|
92
149
|
booking,
|
|
93
150
|
response: body,
|
package/src/schemas.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { BusinessEntityIds } from '@bisondesk/commons-sdk/constants';
|
|
2
|
+
import { attachmentValueSchema, getPhoneSchema } from '@bisondesk/commons/joi-schemas';
|
|
3
|
+
import { FinanceDocType } from '@bisondesk/documents-sdk/types/documents';
|
|
4
|
+
import Joi from 'joi';
|
|
5
|
+
|
|
6
|
+
const orgSummarySchema = Joi.object({
|
|
7
|
+
id: Joi.string().required(),
|
|
8
|
+
code: Joi.number().required(),
|
|
9
|
+
name: Joi.string().required(),
|
|
10
|
+
language: Joi.string().required(),
|
|
11
|
+
vatNumber: Joi.string(),
|
|
12
|
+
addressLine1: Joi.string(),
|
|
13
|
+
addressLine2: Joi.string(),
|
|
14
|
+
postcode: Joi.string(),
|
|
15
|
+
city: Joi.string(),
|
|
16
|
+
country: Joi.string().required(),
|
|
17
|
+
emails: Joi.array().items(Joi.string().email()),
|
|
18
|
+
phone: getPhoneSchema(),
|
|
19
|
+
contact: Joi.object({
|
|
20
|
+
name: Joi.string().required(),
|
|
21
|
+
username: Joi.string().required(),
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const associationsSchema = Joi.array().items(
|
|
26
|
+
Joi.object({
|
|
27
|
+
businessEntityId: Joi.string()
|
|
28
|
+
.valid(...Object.values(BusinessEntityIds))
|
|
29
|
+
.required(),
|
|
30
|
+
recordId: Joi.string().required(),
|
|
31
|
+
title: Joi.string().required(),
|
|
32
|
+
description: Joi.string().required(),
|
|
33
|
+
tags: Joi.array().items(Joi.string()),
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export const lineSchema = Joi.object({
|
|
38
|
+
category: Joi.string().required(),
|
|
39
|
+
amount: Joi.string().required(),
|
|
40
|
+
amountExcl: Joi.string().required(),
|
|
41
|
+
description: Joi.string().required(),
|
|
42
|
+
foreign: Joi.object({
|
|
43
|
+
amount: Joi.string().required(),
|
|
44
|
+
amountExcl: Joi.string().required(),
|
|
45
|
+
unitPriceExcl: Joi.string().required(),
|
|
46
|
+
vatAmount: Joi.string().required(),
|
|
47
|
+
}),
|
|
48
|
+
invoiceLineId: Joi.string(),
|
|
49
|
+
quantity: Joi.string().required(),
|
|
50
|
+
associations: associationsSchema,
|
|
51
|
+
unitPriceExcl: Joi.string().required(),
|
|
52
|
+
vatAmount: Joi.string().required(),
|
|
53
|
+
vatCode: Joi.string().required(),
|
|
54
|
+
vatPercentage: Joi.string().required(),
|
|
55
|
+
vatReason: Joi.string(),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const newFinanceDocV2Schema = Joi.object({
|
|
59
|
+
id: Joi.string(),
|
|
60
|
+
version: Joi.number().valid(2.0).required(),
|
|
61
|
+
reference: Joi.string().required(),
|
|
62
|
+
type: Joi.string()
|
|
63
|
+
.valid(...Object.values(FinanceDocType))
|
|
64
|
+
.required(),
|
|
65
|
+
subtype: Joi.string().required(),
|
|
66
|
+
attachment: attachmentValueSchema.required(),
|
|
67
|
+
branchId: Joi.string().required(),
|
|
68
|
+
category: Joi.string().required(),
|
|
69
|
+
organizationSummary: orgSummarySchema.required(),
|
|
70
|
+
dueDate: Joi.string(),
|
|
71
|
+
transferDescription: Joi.string(),
|
|
72
|
+
invoiceId: Joi.string(),
|
|
73
|
+
notes: Joi.string(),
|
|
74
|
+
salesperson: Joi.object({
|
|
75
|
+
name: Joi.string().required(),
|
|
76
|
+
username: Joi.string().required(),
|
|
77
|
+
}),
|
|
78
|
+
paidAt: Joi.string(),
|
|
79
|
+
tags: Joi.array().items(Joi.string()),
|
|
80
|
+
total: Joi.object({
|
|
81
|
+
amountExcl: Joi.string().required(),
|
|
82
|
+
amount: Joi.string().required(),
|
|
83
|
+
currencyCode: Joi.string().required(),
|
|
84
|
+
foreign: Joi.object({
|
|
85
|
+
amount: Joi.string().required(),
|
|
86
|
+
amountExcl: Joi.string().required(),
|
|
87
|
+
vatAmount: Joi.string().required(),
|
|
88
|
+
currencyCode: Joi.string().required(),
|
|
89
|
+
exchangeRate: Joi.string().required(),
|
|
90
|
+
}),
|
|
91
|
+
vatAmount: Joi.string().required(),
|
|
92
|
+
}),
|
|
93
|
+
issueDate: Joi.string().isoDate().required(),
|
|
94
|
+
lines: Joi.array().items(lineSchema).required(),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export const newAdministativedDocumentSchema = Joi.object({
|
|
98
|
+
id: Joi.string(),
|
|
99
|
+
displayName: Joi.string(),
|
|
100
|
+
branchId: Joi.string().required(),
|
|
101
|
+
attachment: attachmentValueSchema.required(),
|
|
102
|
+
category: Joi.string().empty(''),
|
|
103
|
+
tags: Joi.array().items(Joi.string()),
|
|
104
|
+
associations: associationsSchema,
|
|
105
|
+
organizationSummary: orgSummarySchema,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export const administativeDocumentSchema = newAdministativedDocumentSchema.keys({
|
|
109
|
+
id: Joi.string().required(),
|
|
110
|
+
createdAt: Joi.string().required(),
|
|
111
|
+
createdBy: Joi.string().required(),
|
|
112
|
+
});
|
package/src/types/booking.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { FinanceDocument } from './documents.js';
|
|
2
2
|
|
|
3
3
|
export type FinanceBookingEvent = {
|
|
4
|
-
id: string;
|
|
5
|
-
branchId: string;
|
|
6
4
|
actionAt: string;
|
|
7
5
|
userId: string;
|
|
8
6
|
tenantId: string;
|
|
9
7
|
type: 'Sale Finance' | 'Purchase Finance';
|
|
10
8
|
version: FinanceDocument['version'];
|
|
11
|
-
}
|
|
9
|
+
} & (
|
|
10
|
+
| { action: 'create'; booking: FinanceBooking; previousBooking?: undefined }
|
|
11
|
+
| { action: 'update'; booking: FinanceBooking; previousBooking: FinanceBooking }
|
|
12
|
+
);
|
|
12
13
|
|
|
13
14
|
export type FinanceBooking = {
|
|
14
15
|
branchId: string; // same tenantId can have different companies
|
|
@@ -14,7 +14,6 @@ type BaseDocumentCategory = {
|
|
|
14
14
|
createdAt: string;
|
|
15
15
|
branchId: string;
|
|
16
16
|
id: string;
|
|
17
|
-
code: string;
|
|
18
17
|
type: DocumentCategoryType;
|
|
19
18
|
title: string;
|
|
20
19
|
};
|
|
@@ -25,27 +24,50 @@ export type AdministrativeDocumentCategory = BaseDocumentCategory & {
|
|
|
25
24
|
|
|
26
25
|
export type FinanceDocumentCategory = BaseDocumentCategory & {
|
|
27
26
|
type: DocumentCategoryType.Finance;
|
|
28
|
-
journal
|
|
27
|
+
journal?: string;
|
|
28
|
+
costCenter: string;
|
|
29
29
|
visibility: DocumentCategoryVisibility;
|
|
30
|
-
|
|
30
|
+
transactionType: TransactionType;
|
|
31
31
|
validators?: string[];
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export type DocumentCategory = AdministrativeDocumentCategory | FinanceDocumentCategory;
|
|
35
35
|
|
|
36
|
-
export type NewDocumentCategory =
|
|
36
|
+
export type NewDocumentCategory = (
|
|
37
37
|
| Omit<FinanceDocumentCategory, 'id' | 'createdAt'>
|
|
38
|
-
| Omit<AdministrativeDocumentCategory, 'id' | 'createdAt'
|
|
38
|
+
| Omit<AdministrativeDocumentCategory, 'id' | 'createdAt'>
|
|
39
|
+
) & {
|
|
40
|
+
createdAt?: undefined;
|
|
41
|
+
id?: undefined;
|
|
42
|
+
};
|
|
39
43
|
|
|
40
44
|
export type FinanceDocumentLineCategory = {
|
|
41
45
|
createdAt: string;
|
|
42
46
|
branchId: string;
|
|
43
47
|
categoryId: string;
|
|
44
48
|
id: string;
|
|
45
|
-
code: string;
|
|
46
49
|
title: string;
|
|
47
50
|
description: string;
|
|
51
|
+
associationMandatory: boolean;
|
|
48
52
|
glAccount: string;
|
|
49
53
|
};
|
|
50
54
|
|
|
51
55
|
export type NewFinanceDocumentLineCategory = Omit<FinanceDocumentLineCategory, 'id' | 'createdAt'>;
|
|
56
|
+
|
|
57
|
+
type BaseCostCenter = {
|
|
58
|
+
branchId: string;
|
|
59
|
+
name: string;
|
|
60
|
+
externalId?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type CostCenter = BaseCostCenter & {
|
|
64
|
+
createdAt: string;
|
|
65
|
+
createdBy: string;
|
|
66
|
+
id: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type NewCostCenter = BaseCostCenter & {
|
|
70
|
+
createdAt?: undefined;
|
|
71
|
+
createdBy?: string;
|
|
72
|
+
id?: undefined;
|
|
73
|
+
};
|
package/src/types/documents.ts
CHANGED
|
@@ -6,7 +6,8 @@ export type FinanceDocument = FinanceDocumentV1 | FinanceDocumentV2;
|
|
|
6
6
|
|
|
7
7
|
export type Association = {
|
|
8
8
|
businessEntityId: BusinessEntityIds;
|
|
9
|
-
|
|
9
|
+
recordId: string;
|
|
10
|
+
title: string;
|
|
10
11
|
description: string;
|
|
11
12
|
tags?: string[];
|
|
12
13
|
};
|
|
@@ -82,8 +83,9 @@ export type FinanceDocumentV2 = BaseDocument & {
|
|
|
82
83
|
transferDescription?: string; // we ask clients to put this as description of the transfer
|
|
83
84
|
invoiceId?: string; // mandatory in credit notes but forbidden in invoices
|
|
84
85
|
issueDate: string;
|
|
85
|
-
lines: FinanceDocumentLine[];
|
|
86
86
|
paymentNotes?: string;
|
|
87
|
+
lines: FinanceDocumentLine[];
|
|
88
|
+
accountingLines?: FinanceDocumentLine[];
|
|
87
89
|
notes?: string;
|
|
88
90
|
salesperson: {
|
|
89
91
|
name: string;
|
|
@@ -118,7 +120,7 @@ export type AdministrativeDocument = BaseDocument & {
|
|
|
118
120
|
tags?: string[];
|
|
119
121
|
category: string;
|
|
120
122
|
associations?: Association[];
|
|
121
|
-
|
|
123
|
+
displayName?: string;
|
|
122
124
|
};
|
|
123
125
|
|
|
124
126
|
export type NewAdministrativeDocument = Omit<
|
|
@@ -207,6 +209,12 @@ export const isFinanceDocumentV1 = (
|
|
|
207
209
|
return (arg as FinanceDocumentV2).version == null;
|
|
208
210
|
};
|
|
209
211
|
|
|
212
|
+
export const isFinanceDocument = (
|
|
213
|
+
arg: FinanceDocument | AdministrativeDocument | NewAdministrativeDocument | NewFinanceDocumentV2
|
|
214
|
+
): arg is FinanceDocument => {
|
|
215
|
+
return (arg as FinanceDocument).reference != null;
|
|
216
|
+
};
|
|
217
|
+
|
|
210
218
|
export const isAdministrativeDocumentDraft = (
|
|
211
219
|
draft: DocumentDraft | NewDocumentDraft
|
|
212
220
|
): draft is DocumentDraft<AdministrativeDocument> | NewDocumentDraft<AdministrativeDocument> =>
|
|
@@ -265,3 +273,25 @@ export enum FinanceDocumentActions {
|
|
|
265
273
|
PAY_FINANCE_DOCUMENT = 'pay_finance_document',
|
|
266
274
|
DELETE_FINANCE_DOCUMENT = 'delete_finance_document',
|
|
267
275
|
}
|
|
276
|
+
|
|
277
|
+
export enum AdministrativeDocumentActions {
|
|
278
|
+
DELETE_ADMINISTRATIVE_DOCUMENT = 'delete_finance_document',
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export type AdministrativeUpdateOperation =
|
|
282
|
+
| {
|
|
283
|
+
doc: AdministrativeDocument;
|
|
284
|
+
op: 'replace';
|
|
285
|
+
}
|
|
286
|
+
| {
|
|
287
|
+
doc: NewAdministrativeDocument;
|
|
288
|
+
op: 'add';
|
|
289
|
+
}
|
|
290
|
+
| {
|
|
291
|
+
association: {
|
|
292
|
+
businessEntityId: BusinessEntityIds;
|
|
293
|
+
recordId: string;
|
|
294
|
+
documentId: string;
|
|
295
|
+
};
|
|
296
|
+
op: 'remove-association';
|
|
297
|
+
};
|
package/src/types/events.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export type FinanceDocumentEvent = {
|
|
2
2
|
id: string;
|
|
3
3
|
actionAt: string;
|
|
4
|
-
action: '
|
|
4
|
+
action: 'create' | 'update' | 'delete';
|
|
5
5
|
userId: string;
|
|
6
6
|
tenantId: string;
|
|
7
7
|
type: 'Sale Finance' | 'Purchase Finance';
|
|
8
|
-
subtype: string; // Invoice, Credit Note, etc.
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
export type AdminDocumentEvent = {
|
|
@@ -14,4 +13,5 @@ export type AdminDocumentEvent = {
|
|
|
14
13
|
action: 'upsert' | 'delete';
|
|
15
14
|
userId: string;
|
|
16
15
|
tenantId: string;
|
|
16
|
+
category: string;
|
|
17
17
|
};
|