@accounter/server 0.0.8-alpha-20251021150615-800574fc6d416cd319de216c97b431643d8958a2 → 0.0.8-alpha-20251021225827-178e480c997a9811913e16f85cb94329041b096e

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +53 -4
  2. package/dist/green-invoice-graphql/src/mesh-artifacts/index.d.ts +1 -1
  3. package/dist/server/src/__generated__/types.d.ts +152 -4
  4. package/dist/server/src/__generated__/types.js.map +1 -1
  5. package/dist/server/src/modules/app-providers/green-invoice-client.d.ts +1 -1
  6. package/dist/server/src/modules/contracts/__generated__/contracts.types.d.ts +145 -0
  7. package/dist/server/src/modules/contracts/__generated__/types.d.ts +20 -3
  8. package/dist/server/src/modules/contracts/__generated__/types.js +1 -0
  9. package/dist/server/src/modules/contracts/__generated__/types.js.map +1 -1
  10. package/dist/server/src/modules/contracts/providers/contracts.provider.d.ts +10 -1
  11. package/dist/server/src/modules/contracts/providers/contracts.provider.js +141 -0
  12. package/dist/server/src/modules/contracts/providers/contracts.provider.js.map +1 -1
  13. package/dist/server/src/modules/contracts/resolvers/contracts.resolver.js +70 -1
  14. package/dist/server/src/modules/contracts/resolvers/contracts.resolver.js.map +1 -1
  15. package/dist/server/src/modules/contracts/typeDefs/contracts.graphql.js +40 -1
  16. package/dist/server/src/modules/contracts/typeDefs/contracts.graphql.js.map +1 -1
  17. package/dist/server/src/modules/documents/__generated__/documents.types.d.ts +32 -0
  18. package/dist/server/src/modules/documents/__generated__/types.d.ts +2 -1
  19. package/dist/server/src/modules/documents/__generated__/types.js.map +1 -1
  20. package/dist/server/src/modules/documents/providers/documents.provider.d.ts +2 -0
  21. package/dist/server/src/modules/documents/providers/documents.provider.js +27 -1
  22. package/dist/server/src/modules/documents/providers/documents.provider.js.map +1 -1
  23. package/dist/server/src/modules/documents/resolvers/documents.resolver.js +10 -0
  24. package/dist/server/src/modules/documents/resolvers/documents.resolver.js.map +1 -1
  25. package/dist/server/src/modules/documents/typeDefs/documents.graphql.js +1 -0
  26. package/dist/server/src/modules/documents/typeDefs/documents.graphql.js.map +1 -1
  27. package/dist/server/src/modules/financial-entities/__generated__/clients.types.d.ts +2 -0
  28. package/dist/server/src/modules/financial-entities/__generated__/types.d.ts +25 -7
  29. package/dist/server/src/modules/financial-entities/__generated__/types.js.map +1 -1
  30. package/dist/server/src/modules/financial-entities/providers/clients.provider.js +2 -2
  31. package/dist/server/src/modules/financial-entities/resolvers/businesses.resolver.js +0 -1
  32. package/dist/server/src/modules/financial-entities/resolvers/businesses.resolver.js.map +1 -1
  33. package/dist/server/src/modules/financial-entities/resolvers/clients.resolvers.js +60 -0
  34. package/dist/server/src/modules/financial-entities/resolvers/clients.resolvers.js.map +1 -1
  35. package/dist/server/src/modules/financial-entities/resolvers/common.js +3 -0
  36. package/dist/server/src/modules/financial-entities/resolvers/common.js.map +1 -1
  37. package/dist/server/src/modules/financial-entities/typeDefs/businesses.graphql.js +8 -0
  38. package/dist/server/src/modules/financial-entities/typeDefs/businesses.graphql.js.map +1 -1
  39. package/dist/server/src/modules/financial-entities/typeDefs/clients.graphql.js +32 -0
  40. package/dist/server/src/modules/financial-entities/typeDefs/clients.graphql.js.map +1 -1
  41. package/dist/server/src/modules/financial-entities/typeDefs/financial-entities.graphql.js +3 -0
  42. package/dist/server/src/modules/financial-entities/typeDefs/financial-entities.graphql.js.map +1 -1
  43. package/dist/server/src/modules/financial-entities/typeDefs/tax-categories.graphql.js +3 -0
  44. package/dist/server/src/modules/financial-entities/typeDefs/tax-categories.graphql.js.map +1 -1
  45. package/dist/server/src/modules/green-invoice/__generated__/types.d.ts +3 -2
  46. package/dist/server/src/modules/green-invoice/__generated__/types.js.map +1 -1
  47. package/dist/server/src/modules/green-invoice/resolvers/green-invoice.resolvers.js +18 -0
  48. package/dist/server/src/modules/green-invoice/resolvers/green-invoice.resolvers.js.map +1 -1
  49. package/dist/server/src/modules/green-invoice/typeDefs/green-invoice.graphql.js +1 -0
  50. package/dist/server/src/modules/green-invoice/typeDefs/green-invoice.graphql.js.map +1 -1
  51. package/package.json +4 -4
  52. package/src/__generated__/types.ts +170 -4
  53. package/src/modules/contracts/__generated__/contracts.types.ts +161 -0
  54. package/src/modules/contracts/__generated__/types.ts +21 -3
  55. package/src/modules/contracts/providers/contracts.provider.ts +171 -1
  56. package/src/modules/contracts/resolvers/contracts.resolver.ts +67 -2
  57. package/src/modules/contracts/typeDefs/contracts.graphql.ts +40 -1
  58. package/src/modules/documents/__generated__/documents.types.ts +35 -0
  59. package/src/modules/documents/__generated__/types.ts +2 -1
  60. package/src/modules/documents/providers/documents.provider.ts +36 -1
  61. package/src/modules/documents/resolvers/documents.resolver.ts +12 -0
  62. package/src/modules/documents/typeDefs/documents.graphql.ts +1 -0
  63. package/src/modules/financial-entities/__generated__/clients.types.ts +2 -0
  64. package/src/modules/financial-entities/__generated__/types.ts +25 -7
  65. package/src/modules/financial-entities/providers/clients.provider.ts +2 -2
  66. package/src/modules/financial-entities/resolvers/businesses.resolver.ts +0 -1
  67. package/src/modules/financial-entities/resolvers/clients.resolvers.ts +66 -1
  68. package/src/modules/financial-entities/resolvers/common.ts +3 -0
  69. package/src/modules/financial-entities/typeDefs/businesses.graphql.ts +8 -0
  70. package/src/modules/financial-entities/typeDefs/clients.graphql.ts +32 -0
  71. package/src/modules/financial-entities/typeDefs/financial-entities.graphql.ts +3 -0
  72. package/src/modules/financial-entities/typeDefs/tax-categories.graphql.ts +3 -0
  73. package/src/modules/green-invoice/__generated__/types.ts +3 -2
  74. package/src/modules/green-invoice/resolvers/green-invoice.resolvers.ts +19 -0
  75. package/src/modules/green-invoice/typeDefs/green-invoice.graphql.ts +1 -0
@@ -47,7 +47,7 @@ export declare class GreenInvoiceClientProvider {
47
47
  getLinkedDocuments(documentId: string): Promise<Pick<import("../../../../green-invoice-graphql/src/index.js").GetLinkedDocuments, "number" | "type" | "id" | "currency" | "amount" | "documentDate" | "status" | "currencyRate"> | null | undefined>;
48
48
  private _batchLoadByIds;
49
49
  private batchDocumentsByIds;
50
- documentLoader: DataLoader<string, (Pick<import("../../../../green-invoice-graphql/src/index.js").Document, "number" | "type" | "id" | "currency" | "amount" | "description" | "vat" | "documentDate" | "remarks" | "status" | "currencyRate" | "creationDate" | "lang" | "signed" | "amountDueVat" | "amountDueVatLocal" | "amountExcludeVat" | "amountExemptVat" | "amountLocal" | "amountOpened" | "calculatedAmountLocal" | "calculatedAmountOpenedLocal" | "calculatedIncomeAmountExcludeLocal" | "calculatedIncomeAmountLocal" | "calculatedPaymentAmountLocal" | "cancellable" | "cancelType" | "downloaded" | "footer" | "ref" | "reverseCharge" | "rounding" | "skinId" | "taxConfirmationEligible" | "templateId" | "userName" | "vatLocal" | "vatRate" | "vatType"> & {
50
+ documentLoader: DataLoader<string, (Pick<import("../../../../green-invoice-graphql/src/index.js").Document, "number" | "type" | "id" | "currency" | "amount" | "description" | "vat" | "documentDate" | "remarks" | "status" | "currencyRate" | "footer" | "lang" | "rounding" | "signed" | "vatType" | "creationDate" | "amountDueVat" | "amountDueVatLocal" | "amountExcludeVat" | "amountExemptVat" | "amountLocal" | "amountOpened" | "calculatedAmountLocal" | "calculatedAmountOpenedLocal" | "calculatedIncomeAmountExcludeLocal" | "calculatedIncomeAmountLocal" | "calculatedPaymentAmountLocal" | "cancellable" | "cancelType" | "downloaded" | "ref" | "reverseCharge" | "skinId" | "taxConfirmationEligible" | "templateId" | "userName" | "vatLocal" | "vatRate"> & {
51
51
  business: Pick<import("../../../../green-invoice-graphql/src/index.js").Business, "accountantDocsEmailSettings" | "accountantEmails" | "accountantReportEmailSettings" | "accountingType" | "active" | "advanceNationalInsuranceRate" | "advanceTaxRate" | "bankDisplay" | "bankDisplayEn" | "deductionRate" | "documentsEmailSettings" | "emailSubjectType" | "exemption" | "incomeReportEmailSettings" | "incomeReportFormatType" | "reportSendingDay" | "senderEmailSettings" | "type">;
52
52
  client: Pick<import("../../../../green-invoice-graphql/src/index.js").Client, "country" | "emails" | "id" | "name" | "phone" | "taxId" | "self">;
53
53
  data: Pick<import("../../../../green-invoice-graphql/src/index.js").DocumentData, "tags">;
@@ -1,6 +1,7 @@
1
1
  /** Types generated for queries found in "src/modules/contracts/providers/contracts.provider.ts" */
2
2
  export type currency = 'AUD' | 'CAD' | 'ETH' | 'EUR' | 'GBP' | 'GRT' | 'ILS' | 'JPY' | 'SEK' | 'USD' | 'USDC';
3
3
  export type document_type = 'CREDIT_INVOICE' | 'INVOICE' | 'INVOICE_RECEIPT' | 'OTHER' | 'PROFORMA' | 'RECEIPT' | 'UNPROCESSED';
4
+ export type DateOrString = Date | string;
4
5
  /** 'GetAllOpenContracts' parameters type */
5
6
  export type IGetAllOpenContractsParams = void;
6
7
  /** 'GetAllOpenContracts' return type */
@@ -26,3 +27,147 @@ export interface IGetAllOpenContractsQuery {
26
27
  params: IGetAllOpenContractsParams;
27
28
  result: IGetAllOpenContractsResult;
28
29
  }
30
+ /** 'GetContractsByIds' parameters type */
31
+ export interface IGetContractsByIdsParams {
32
+ ids: readonly (string | null | void)[];
33
+ }
34
+ /** 'GetContractsByIds' return type */
35
+ export interface IGetContractsByIdsResult {
36
+ amount: number;
37
+ billing_cycle: string;
38
+ client_id: string;
39
+ currency: currency;
40
+ document_type: document_type;
41
+ end_date: Date;
42
+ id: string;
43
+ is_active: boolean | null;
44
+ ms_cloud: string | null;
45
+ plan: string | null;
46
+ product: string | null;
47
+ purchase_order: string | null;
48
+ remarks: string | null;
49
+ signed_agreement: string | null;
50
+ start_date: Date;
51
+ }
52
+ /** 'GetContractsByIds' query type */
53
+ export interface IGetContractsByIdsQuery {
54
+ params: IGetContractsByIdsParams;
55
+ result: IGetContractsByIdsResult;
56
+ }
57
+ /** 'GetContractsByClientIds' parameters type */
58
+ export interface IGetContractsByClientIdsParams {
59
+ clientIds: readonly (string | null | void)[];
60
+ }
61
+ /** 'GetContractsByClientIds' return type */
62
+ export interface IGetContractsByClientIdsResult {
63
+ amount: number;
64
+ billing_cycle: string;
65
+ client_id: string;
66
+ currency: currency;
67
+ document_type: document_type;
68
+ end_date: Date;
69
+ id: string;
70
+ is_active: boolean | null;
71
+ ms_cloud: string | null;
72
+ plan: string | null;
73
+ product: string | null;
74
+ purchase_order: string | null;
75
+ remarks: string | null;
76
+ signed_agreement: string | null;
77
+ start_date: Date;
78
+ }
79
+ /** 'GetContractsByClientIds' query type */
80
+ export interface IGetContractsByClientIdsQuery {
81
+ params: IGetContractsByClientIdsParams;
82
+ result: IGetContractsByClientIdsResult;
83
+ }
84
+ /** 'DeleteContract' parameters type */
85
+ export interface IDeleteContractParams {
86
+ id?: string | null | void;
87
+ }
88
+ /** 'DeleteContract' return type */
89
+ export type IDeleteContractResult = void;
90
+ /** 'DeleteContract' query type */
91
+ export interface IDeleteContractQuery {
92
+ params: IDeleteContractParams;
93
+ result: IDeleteContractResult;
94
+ }
95
+ /** 'UpdateContract' parameters type */
96
+ export interface IUpdateContractParams {
97
+ amount?: number | null | void;
98
+ billing_cycle?: string | null | void;
99
+ client_id?: string | null | void;
100
+ contractId?: string | null | void;
101
+ currency?: currency | null | void;
102
+ document_type?: document_type | null | void;
103
+ end_date?: DateOrString | null | void;
104
+ is_active?: boolean | null | void;
105
+ ms_cloud?: string | null | void;
106
+ plan?: string | null | void;
107
+ product?: string | null | void;
108
+ purchase_order?: string | null | void;
109
+ remarks?: string | null | void;
110
+ start_date?: DateOrString | null | void;
111
+ }
112
+ /** 'UpdateContract' return type */
113
+ export interface IUpdateContractResult {
114
+ amount: number;
115
+ billing_cycle: string;
116
+ client_id: string;
117
+ currency: currency;
118
+ document_type: document_type;
119
+ end_date: Date;
120
+ id: string;
121
+ is_active: boolean | null;
122
+ ms_cloud: string | null;
123
+ plan: string | null;
124
+ product: string | null;
125
+ purchase_order: string | null;
126
+ remarks: string | null;
127
+ signed_agreement: string | null;
128
+ start_date: Date;
129
+ }
130
+ /** 'UpdateContract' query type */
131
+ export interface IUpdateContractQuery {
132
+ params: IUpdateContractParams;
133
+ result: IUpdateContractResult;
134
+ }
135
+ /** 'InsertContract' parameters type */
136
+ export interface IInsertContractParams {
137
+ amount?: number | null | void;
138
+ billingCycle?: string | null | void;
139
+ clientId?: string | null | void;
140
+ currency?: currency | null | void;
141
+ documentType?: document_type | null | void;
142
+ endDate?: DateOrString | null | void;
143
+ isActive?: boolean | null | void;
144
+ msCloud?: string | null | void;
145
+ plan?: string | null | void;
146
+ product?: string | null | void;
147
+ purchaseOrder?: string | null | void;
148
+ remarks?: string | null | void;
149
+ startDate?: DateOrString | null | void;
150
+ }
151
+ /** 'InsertContract' return type */
152
+ export interface IInsertContractResult {
153
+ amount: number;
154
+ billing_cycle: string;
155
+ client_id: string;
156
+ currency: currency;
157
+ document_type: document_type;
158
+ end_date: Date;
159
+ id: string;
160
+ is_active: boolean | null;
161
+ ms_cloud: string | null;
162
+ plan: string | null;
163
+ product: string | null;
164
+ purchase_order: string | null;
165
+ remarks: string | null;
166
+ signed_agreement: string | null;
167
+ start_date: Date;
168
+ }
169
+ /** 'InsertContract' query type */
170
+ export interface IInsertContractQuery {
171
+ params: IInsertContractParams;
172
+ result: IInsertContractResult;
173
+ }
@@ -2,17 +2,25 @@ import * as Types from "../../../__generated__/types.js";
2
2
  import * as gm from "graphql-modules";
3
3
  export declare namespace ContractsModule {
4
4
  interface DefinedFields {
5
- Query: 'allOpenContracts';
6
- Contract: 'id' | 'client' | 'purchaseOrder' | 'startDate' | 'endDate' | 'remarks' | 'amount' | 'documentType' | 'billingCycle' | 'isActive' | 'product' | 'plan' | 'signedAgreement' | 'msCloud';
5
+ Query: 'allOpenContracts' | 'contractsByClient';
6
+ Mutation: 'updateContract' | 'deleteContract' | 'createContract';
7
+ Contract: 'id' | 'client' | 'purchaseOrder' | 'startDate' | 'endDate' | 'remarks' | 'amount' | 'documentType' | 'billingCycle' | 'isActive' | 'product' | 'plan' | 'msCloud';
7
8
  }
8
9
  interface DefinedEnumValues {
9
10
  BillingCycle: 'MONTHLY' | 'ANNUAL';
10
11
  Product: 'HIVE' | 'STELLATE';
11
12
  SubscriptionPlan: 'ENTERPRISE' | 'PRO';
12
13
  }
14
+ interface DefinedInputFields {
15
+ CreateContractInput: 'clientId' | 'purchaseOrder' | 'startDate' | 'endDate' | 'remarks' | 'amount' | 'documentType' | 'billingCycle' | 'product' | 'plan' | 'msCloud' | 'isActive';
16
+ UpdateContractInput: 'clientId' | 'purchaseOrder' | 'startDate' | 'endDate' | 'remarks' | 'amount' | 'documentType' | 'billingCycle' | 'product' | 'plan' | 'msCloud' | 'isActive';
17
+ }
13
18
  export type Query = Pick<Types.Query, DefinedFields['Query']>;
14
19
  export type Contract = Pick<Types.Contract, DefinedFields['Contract']>;
15
20
  export type UUID = Types.Uuid;
21
+ export type Mutation = Pick<Types.Mutation, DefinedFields['Mutation']>;
22
+ export type UpdateContractInput = Pick<Types.UpdateContractInput, DefinedInputFields['UpdateContractInput']>;
23
+ export type CreateContractInput = Pick<Types.CreateContractInput, DefinedInputFields['CreateContractInput']>;
16
24
  export type Client = Types.Client;
17
25
  export type TimelessDate = Types.TimelessDate;
18
26
  export type FinancialAmount = Types.FinancialAmount;
@@ -21,10 +29,13 @@ export declare namespace ContractsModule {
21
29
  export type Product = DefinedEnumValues['Product'];
22
30
  export type SubscriptionPlan = DefinedEnumValues['SubscriptionPlan'];
23
31
  export type URL = Types.Url;
32
+ export type FinancialAmountInput = Types.FinancialAmountInput;
24
33
  export type QueryResolvers = Pick<Types.QueryResolvers, DefinedFields['Query']>;
34
+ export type MutationResolvers = Pick<Types.MutationResolvers, DefinedFields['Mutation']>;
25
35
  export type ContractResolvers = Pick<Types.ContractResolvers, DefinedFields['Contract'] | '__isTypeOf'>;
26
36
  export interface Resolvers {
27
37
  Query?: QueryResolvers;
38
+ Mutation?: MutationResolvers;
28
39
  Contract?: ContractResolvers;
29
40
  }
30
41
  export interface MiddlewareMap {
@@ -34,6 +45,13 @@ export declare namespace ContractsModule {
34
45
  Query?: {
35
46
  '*'?: gm.Middleware[];
36
47
  allOpenContracts?: gm.Middleware[];
48
+ contractsByClient?: gm.Middleware[];
49
+ };
50
+ Mutation?: {
51
+ '*'?: gm.Middleware[];
52
+ updateContract?: gm.Middleware[];
53
+ deleteContract?: gm.Middleware[];
54
+ createContract?: gm.Middleware[];
37
55
  };
38
56
  Contract?: {
39
57
  '*'?: gm.Middleware[];
@@ -49,7 +67,6 @@ export declare namespace ContractsModule {
49
67
  isActive?: gm.Middleware[];
50
68
  product?: gm.Middleware[];
51
69
  plan?: gm.Middleware[];
52
- signedAgreement?: gm.Middleware[];
53
70
  msCloud?: gm.Middleware[];
54
71
  };
55
72
  }
@@ -4,5 +4,6 @@ export var ContractsModule;
4
4
  ;
5
5
  ;
6
6
  ;
7
+ ;
7
8
  })(ContractsModule || (ContractsModule = {}));
8
9
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/contracts/__generated__/types.ts"],"names":[],"mappings":"AAEA,MAAM,KAAW,eAAe,CA0D/B;AA1DD,WAAiB,eAAe;IAI7B,CAAC;IAMD,CAAC;IAoBD,CAAC;IA2BD,CAAC;AACJ,CAAC,EA1DgB,eAAe,KAAf,eAAe,QA0D/B"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/contracts/__generated__/types.ts"],"names":[],"mappings":"AAEA,MAAM,KAAW,eAAe,CA4E/B;AA5ED,WAAiB,eAAe;IAK7B,CAAC;IAMD,CAAC;IAKD,CAAC;IA0BD,CAAC;IAiCD,CAAC;AACJ,CAAC,EA5EgB,eAAe,KAAf,eAAe,QA4E/B"}
@@ -1,5 +1,6 @@
1
+ import DataLoader from 'dataloader';
1
2
  import { DBProvider } from '../../app-providers/db.provider.js';
2
- import type { IGetAllOpenContractsResult } from '../types.js';
3
+ import type { IGetAllOpenContractsResult, IInsertContractParams, IUpdateContractParams } from '../types.js';
3
4
  export declare class ContractsProvider {
4
5
  private dbProvider;
5
6
  cache: {
@@ -13,5 +14,13 @@ export declare class ContractsProvider {
13
14
  };
14
15
  constructor(dbProvider: DBProvider);
15
16
  getAllOpenContracts(): Promise<IGetAllOpenContractsResult[]>;
17
+ private contractsByIds;
18
+ getContractsByIdLoader: DataLoader<string, import("../types.js").IGetContractsByIdsResult | undefined, import("node-cache").Key | import("node-cache").Key[]>;
19
+ private contractsByClients;
20
+ getContractsByClientIdLoader: DataLoader<string, import("../types.js").IGetContractsByClientIdsResult[], import("node-cache").Key | import("node-cache").Key[]>;
21
+ createContract(params: IInsertContractParams): Promise<import("../types.js").IInsertContractResult>;
22
+ updateContract(params: IUpdateContractParams): Promise<import("../types.js").IUpdateContractResult>;
23
+ deleteContract(contractId: string): Promise<boolean>;
24
+ invalidateCacheForContract(contractId: string): Promise<void>;
16
25
  clearCache(): void;
17
26
  }
@@ -1,4 +1,5 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
+ import DataLoader from 'dataloader';
2
3
  import { Injectable, Scope } from 'graphql-modules';
3
4
  import { DBProvider } from '../../app-providers/db.provider.js';
4
5
  import { sql } from '@pgtyped/runtime';
@@ -7,6 +8,106 @@ const getAllOpenContracts = sql `
7
8
  SELECT *
8
9
  FROM accounter_schema.clients_contracts
9
10
  WHERE is_active IS TRUE;`;
11
+ const getContractsByIds = sql `
12
+ SELECT *
13
+ FROM accounter_schema.clients_contracts
14
+ WHERE id In $$ids;`;
15
+ const getContractsByClientIds = sql `
16
+ SELECT *
17
+ FROM accounter_schema.clients_contracts
18
+ WHERE client_id IN $$clientIds;`;
19
+ const deleteContract = sql `
20
+ DELETE FROM accounter_schema.clients_contracts
21
+ WHERE id = $id;`;
22
+ const updateContract = sql `
23
+ UPDATE accounter_schema.clients_contracts
24
+ SET
25
+ client_id = COALESCE(
26
+ $client_id,
27
+ client_id
28
+ ),
29
+ purchase_order = COALESCE(
30
+ $purchase_order,
31
+ purchase_order
32
+ ),
33
+ start_date = COALESCE(
34
+ $start_date,
35
+ start_date
36
+ ),
37
+ end_date = COALESCE(
38
+ $end_date,
39
+ end_date
40
+ ),
41
+ remarks = COALESCE(
42
+ $remarks,
43
+ remarks
44
+ ),
45
+ document_type = COALESCE(
46
+ $document_type,
47
+ document_type
48
+ ),
49
+ amount = COALESCE(
50
+ $amount,
51
+ amount
52
+ ),
53
+ currency = COALESCE(
54
+ $currency,
55
+ currency
56
+ ),
57
+ billing_cycle = COALESCE(
58
+ $billing_cycle,
59
+ billing_cycle
60
+ ),
61
+ product = COALESCE(
62
+ $product,
63
+ product
64
+ ),
65
+ plan = COALESCE(
66
+ $plan,
67
+ plan
68
+ ),
69
+ is_active = COALESCE(
70
+ $is_active,
71
+ is_active
72
+ ),
73
+ ms_cloud = COALESCE(
74
+ $ms_cloud,
75
+ ms_cloud
76
+ )
77
+ WHERE
78
+ id = $contractId
79
+ RETURNING *;
80
+ `;
81
+ const insertContract = sql `
82
+ INSERT INTO accounter_schema.clients_contracts (
83
+ client_id,
84
+ purchase_order,
85
+ start_date,
86
+ end_date,
87
+ remarks,
88
+ document_type,
89
+ amount,
90
+ currency,
91
+ billing_cycle,
92
+ product,
93
+ plan,
94
+ is_active,
95
+ ms_cloud
96
+ )
97
+ VALUES ($clientId,
98
+ $purchaseOrder,
99
+ $startDate,
100
+ $endDate,
101
+ $remarks,
102
+ $documentType,
103
+ $amount,
104
+ $currency,
105
+ $billingCycle,
106
+ $product,
107
+ $plan,
108
+ $isActive,
109
+ $msCloud)
110
+ RETURNING *;`;
10
111
  let ContractsProvider = class ContractsProvider {
11
112
  dbProvider;
12
113
  cache = getCacheInstance({
@@ -30,6 +131,46 @@ let ContractsProvider = class ContractsProvider {
30
131
  return contracts;
31
132
  });
32
133
  }
134
+ async contractsByIds(ids) {
135
+ const contracts = await getContractsByIds.run({ ids }, this.dbProvider);
136
+ return ids.map(id => contracts.find(contract => contract.id === id));
137
+ }
138
+ getContractsByIdLoader = new DataLoader((ids) => this.contractsByIds(ids), {
139
+ cacheKeyFn: id => `contract-${id}`,
140
+ cacheMap: this.cache,
141
+ });
142
+ async contractsByClients(clientIds) {
143
+ const contracts = await getContractsByClientIds.run({ clientIds }, this.dbProvider);
144
+ return clientIds.map(clientId => contracts.filter(contract => contract.client_id === clientId));
145
+ }
146
+ getContractsByClientIdLoader = new DataLoader((ids) => this.contractsByClients(ids), {
147
+ cacheKeyFn: id => `client-contracts-${id}`,
148
+ cacheMap: this.cache,
149
+ });
150
+ async createContract(params) {
151
+ this.clearCache();
152
+ const [newContract] = await insertContract.run(params, this.dbProvider);
153
+ this.cache.set(`contract-${newContract.id}`, newContract);
154
+ return newContract;
155
+ }
156
+ async updateContract(params) {
157
+ this.clearCache();
158
+ const [updatedContract] = await updateContract.run(params, this.dbProvider);
159
+ this.cache.set(`contract-${updatedContract.id}`, updatedContract);
160
+ return updatedContract;
161
+ }
162
+ async deleteContract(contractId) {
163
+ await deleteContract.run({ id: contractId }, this.dbProvider);
164
+ this.clearCache();
165
+ return true;
166
+ }
167
+ async invalidateCacheForContract(contractId) {
168
+ const contract = await this.getContractsByIdLoader.load(contractId);
169
+ if (contract) {
170
+ this.cache.delete(`client-contracts-${contract.client_id}`);
171
+ }
172
+ this.cache.delete(`contract-${contractId}`);
173
+ }
33
174
  clearCache() {
34
175
  this.cache.clear();
35
176
  }
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.provider.js","sourceRoot":"","sources":["../../../../../../src/modules/contracts/providers/contracts.provider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,MAAM,mBAAmB,GAAG,GAAG,CAA2B;;;6BAG7B,CAAC;AAMvB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAKR;IAJpB,KAAK,GAAG,gBAAgB,CAAC;QACvB,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,UAAU;KAC5B,CAAC,CAAC;IAEH,YAAoB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvC,mBAAmB;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAA+B,eAAe,CAAC,CAAC;QAC7E,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,mBAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC1E,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;gBAC3C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;oBACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,QAAQ,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;gBACtD,CAAC,CAAC,CAAC;YACL,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,UAAU;QACf,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF,CAAA;AA1BY,iBAAiB;IAJ7B,UAAU,CAAC;QACV,KAAK,EAAE,KAAK,CAAC,SAAS;QACtB,MAAM,EAAE,IAAI;KACb,CAAC;qCAMgC,UAAU;GAL/B,iBAAiB,CA0B7B"}
1
+ {"version":3,"file":"contracts.provider.js","sourceRoot":"","sources":["../../../../../../src/modules/contracts/providers/contracts.provider.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE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C,CAAC;IAC9C,CAAC;IAEM,UAAU;QACf,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF,CAAA;AAhFY,iBAAiB;IAJ7B,UAAU,CAAC;QACV,KAAK,EAAE,KAAK,CAAC,SAAS;QACtB,MAAM,EAAE,IAAI;KACb,CAAC;qCAMgC,UAAU;GAL/B,iBAAiB,CAgF7B"}
@@ -15,6 +15,76 @@ export const contractsResolvers = {
15
15
  throw new GraphQLError('Error fetching countries');
16
16
  }
17
17
  },
18
+ contractsByClient: async (_, { clientId }, { injector }) => {
19
+ try {
20
+ return injector.get(ContractsProvider).getContractsByClientIdLoader.load(clientId);
21
+ }
22
+ catch (e) {
23
+ const message = 'Error fetching contracts by client';
24
+ console.error(message, e);
25
+ throw new GraphQLError(message);
26
+ }
27
+ },
28
+ },
29
+ Mutation: {
30
+ createContract: async (_, { input }, { injector }) => {
31
+ try {
32
+ const params = {
33
+ amount: input.amount.raw,
34
+ billingCycle: input.billingCycle,
35
+ clientId: input.clientId,
36
+ currency: input.amount.currency,
37
+ documentType: input.documentType,
38
+ endDate: input.endDate,
39
+ isActive: input.isActive,
40
+ msCloud: input.msCloud?.toString(),
41
+ plan: input.plan,
42
+ product: input.product,
43
+ purchaseOrder: input.purchaseOrder,
44
+ remarks: input.remarks,
45
+ startDate: input.startDate,
46
+ };
47
+ return injector.get(ContractsProvider).createContract(params);
48
+ }
49
+ catch (e) {
50
+ console.error('Error creating contract', e);
51
+ throw new GraphQLError('Error creating contract');
52
+ }
53
+ },
54
+ updateContract: async (_, { contractId, input }, { injector }) => {
55
+ try {
56
+ const params = {
57
+ contractId,
58
+ amount: input.amount?.raw,
59
+ billing_cycle: input.billingCycle,
60
+ client_id: input.clientId,
61
+ currency: input.amount?.currency,
62
+ document_type: input.documentType,
63
+ end_date: input.endDate,
64
+ is_active: input.isActive,
65
+ ms_cloud: input.msCloud?.toString(),
66
+ plan: input.plan,
67
+ product: input.product,
68
+ purchase_order: input.purchaseOrder,
69
+ remarks: input.remarks,
70
+ start_date: input.startDate,
71
+ };
72
+ return injector.get(ContractsProvider).updateContract(params);
73
+ }
74
+ catch (e) {
75
+ console.error('Error updating contract', e);
76
+ throw new GraphQLError('Error updating contract');
77
+ }
78
+ },
79
+ deleteContract: async (_, { id }, { injector }) => {
80
+ try {
81
+ return injector.get(ContractsProvider).deleteContract(id);
82
+ }
83
+ catch (e) {
84
+ console.error('Error deleting contract', e);
85
+ throw new GraphQLError('Error deleting contract');
86
+ }
87
+ },
18
88
  },
19
89
  Contract: {
20
90
  id: dbContract => dbContract.id,
@@ -42,7 +112,6 @@ export const contractsResolvers = {
42
112
  isActive: dbContract => dbContract.is_active ?? false, //Boolean!
43
113
  product: dbContract => normalizeProduct(dbContract.product), //Product!
44
114
  plan: dbContract => normalizeSubscriptionPlan(dbContract.plan), //SubscriptionPlan!
45
- signedAgreement: dbContract => dbContract.signed_agreement, //URL
46
115
  msCloud: dbContract => dbContract.ms_cloud, //URL
47
116
  },
48
117
  };
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.resolver.js","sourceRoot":"","sources":["../../../../../../src/modules/contracts/resolvers/contracts.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,2DAA2D,CAAC;AAC5F,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGvE,MAAM,CAAC,MAAM,kBAAkB,GAA8B;IAC3D,KAAK,EAAE;QACL,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,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AAE,QAAQ;QACnD,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,qBAAqB,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,kBAAkB;QACvG,YAAY,EAAE,UAAU,CAAC,EAAE,CAAC,qBAAqB,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,eAAe;QAC5F,YAAY,EAAE,UAAU,CAAC,EAAE,CAAC,qBAAqB,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,eAAe;QAC5F,QAAQ,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,IAAI,KAAK,EAAE,UAAU;QACjE,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,UAAU;QACvE,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,yBAAyB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,mBAAmB;QACnF,eAAe,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,KAAK;QACjE,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK;KAClD;CACF,CAAC"}
1
+ {"version":3,"file":"contracts.resolver.js","sourceRoot":"","sources":["../../../../../../src/modules/contracts/resolvers/contracts.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,2DAA2D,CAAC;AAC5F,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGvE,MAAM,CAAC,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
5
+ contractsByClient(clientId: UUID!): [Contract!]! @auth(role: ACCOUNTANT)
6
+ }
7
+
8
+ extend type Mutation {
9
+ updateContract(contractId: UUID!, input: UpdateContractInput!): Contract!
10
+ @auth(role: ACCOUNTANT)
11
+ deleteContract(id: UUID!): Boolean! @auth(role: ACCOUNTANT)
12
+ createContract(input: CreateContractInput!): Contract! @auth(role: ACCOUNTANT)
5
13
  }
6
14
 
7
15
  " a client contract "
@@ -18,7 +26,6 @@ export default gql `
18
26
  isActive: Boolean!
19
27
  product: Product
20
28
  plan: SubscriptionPlan
21
- signedAgreement: URL
22
29
  msCloud: URL
23
30
  }
24
31
 
@@ -39,5 +46,37 @@ export default gql `
39
46
  ENTERPRISE
40
47
  PRO
41
48
  }
49
+
50
+ " input for creating a new contract "
51
+ input CreateContractInput {
52
+ clientId: UUID!
53
+ purchaseOrder: String
54
+ startDate: TimelessDate!
55
+ endDate: TimelessDate!
56
+ remarks: String
57
+ amount: FinancialAmountInput!
58
+ documentType: DocumentType!
59
+ billingCycle: BillingCycle!
60
+ product: Product
61
+ plan: SubscriptionPlan
62
+ msCloud: URL
63
+ isActive: Boolean!
64
+ }
65
+
66
+ " input for updating a contract "
67
+ input UpdateContractInput {
68
+ clientId: UUID
69
+ purchaseOrder: String
70
+ startDate: TimelessDate
71
+ endDate: TimelessDate
72
+ remarks: String
73
+ amount: FinancialAmountInput
74
+ documentType: DocumentType
75
+ billingCycle: BillingCycle
76
+ product: Product
77
+ plan: SubscriptionPlan
78
+ msCloud: URL
79
+ isActive: Boolean
80
+ }
42
81
  `;
43
82
  //# sourceMappingURL=contracts.graphql.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.graphql.js","sourceRoot":"","sources":["../../../../../../src/modules/contracts/typeDefs/contracts.graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCjB,CAAC"}
1
+ {"version":3,"file":"contracts.graphql.js","sourceRoot":"","sources":["../../../../../../src/modules/contracts/typeDefs/contracts.graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+EjB,CAAC"}
@@ -97,6 +97,38 @@ export interface IGetDocumentsByIdsQuery {
97
97
  params: IGetDocumentsByIdsParams;
98
98
  result: IGetDocumentsByIdsResult;
99
99
  }
100
+ /** 'GetDocumentsByBusinessIds' parameters type */
101
+ export interface IGetDocumentsByBusinessIdsParams {
102
+ Ids: readonly (string | null | void)[];
103
+ }
104
+ /** 'GetDocumentsByBusinessIds' return type */
105
+ export interface IGetDocumentsByBusinessIdsResult {
106
+ allocation_number: string | null;
107
+ charge_id: string | null;
108
+ created_at: Date;
109
+ creditor_id: string | null;
110
+ currency_code: currency | null;
111
+ date: Date | null;
112
+ debtor_id: string | null;
113
+ exchange_rate_override: string | null;
114
+ file_hash: string | null;
115
+ file_url: string | null;
116
+ id: string;
117
+ image_url: string | null;
118
+ is_reviewed: boolean;
119
+ modified_at: Date;
120
+ no_vat_amount: string | null;
121
+ serial_number: string | null;
122
+ total_amount: number | null;
123
+ type: document_type;
124
+ vat_amount: number | null;
125
+ vat_report_date_override: Date | null;
126
+ }
127
+ /** 'GetDocumentsByBusinessIds' query type */
128
+ export interface IGetDocumentsByBusinessIdsQuery {
129
+ params: IGetDocumentsByBusinessIdsParams;
130
+ result: IGetDocumentsByBusinessIdsResult;
131
+ }
100
132
  /** 'GetDocumentsByHashes' parameters type */
101
133
  export interface IGetDocumentsByHashesParams {
102
134
  hashes: readonly (string | null | void)[];
@@ -3,7 +3,7 @@ import * as gm from "graphql-modules";
3
3
  export declare namespace DocumentsModule {
4
4
  interface DefinedFields {
5
5
  DocumentSuggestions: 'owner' | 'counterparty' | 'amount' | 'isIncome';
6
- Query: 'documents' | 'documentsByFilters' | 'documentById' | 'recentDocumentsByClient' | 'recentIssuedDocumentsByType';
6
+ Query: 'documents' | 'documentsByFilters' | 'documentById' | 'recentDocumentsByBusiness' | 'recentDocumentsByClient' | 'recentIssuedDocumentsByType';
7
7
  Mutation: 'insertDocument' | 'updateDocument' | 'deleteDocument' | 'uploadDocument' | 'batchUploadDocuments' | 'batchUploadDocumentsFromGoogleDrive' | 'closeDocument';
8
8
  Unprocessed: 'id' | 'image' | 'file' | 'documentType' | 'isReviewed';
9
9
  OtherDocument: 'id' | 'image' | 'file' | 'documentType' | 'isReviewed';
@@ -248,6 +248,7 @@ export declare namespace DocumentsModule {
248
248
  documents?: gm.Middleware[];
249
249
  documentsByFilters?: gm.Middleware[];
250
250
  documentById?: gm.Middleware[];
251
+ recentDocumentsByBusiness?: gm.Middleware[];
251
252
  recentDocumentsByClient?: gm.Middleware[];
252
253
  recentIssuedDocumentsByType?: gm.Middleware[];
253
254
  };