@accounter/server 0.0.8-alpha-20251030162201-d2f279aafe537912ec3546af855cbd3a38ac0f5c → 0.0.8-alpha-20251030164843-d2f490daba879840366288d1f62974ab25081876
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/CHANGELOG.md +33 -20
- package/dist/server/src/__generated__/types.d.ts +37 -70
- package/dist/server/src/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/contracts/__generated__/contracts.types.d.ts +29 -0
- package/dist/server/src/modules/contracts/__generated__/types.d.ts +3 -1
- package/dist/server/src/modules/contracts/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/contracts/providers/contracts.provider.d.ts +5 -1
- package/dist/server/src/modules/contracts/providers/contracts.provider.js +37 -7
- package/dist/server/src/modules/contracts/providers/contracts.provider.js.map +1 -1
- package/dist/server/src/modules/contracts/resolvers/contracts.resolver.js +27 -0
- package/dist/server/src/modules/contracts/resolvers/contracts.resolver.js.map +1 -1
- package/dist/server/src/modules/contracts/typeDefs/contracts.graphql.js +2 -0
- package/dist/server/src/modules/contracts/typeDefs/contracts.graphql.js.map +1 -1
- package/dist/server/src/modules/financial-entities/__generated__/admin-businesses.types.d.ts +0 -57
- package/dist/server/src/modules/financial-entities/__generated__/admin-businesses.types.js +1 -0
- package/dist/server/src/modules/financial-entities/__generated__/admin-businesses.types.js.map +1 -1
- package/dist/server/src/modules/financial-entities/__generated__/types.d.ts +10 -33
- package/dist/server/src/modules/financial-entities/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/financial-entities/providers/admin-businesses.provider.d.ts +1 -2
- package/dist/server/src/modules/financial-entities/providers/admin-businesses.provider.js +0 -37
- package/dist/server/src/modules/financial-entities/providers/admin-businesses.provider.js.map +1 -1
- package/dist/server/src/modules/financial-entities/resolvers/admin-businesses.resolver.js +11 -46
- package/dist/server/src/modules/financial-entities/resolvers/admin-businesses.resolver.js.map +1 -1
- package/dist/server/src/modules/financial-entities/typeDefs/admin-businesses.graphql.js +16 -49
- package/dist/server/src/modules/financial-entities/typeDefs/admin-businesses.graphql.js.map +1 -1
- package/dist/server/src/modules/financial-entities/types.d.ts +1 -1
- package/dist/server/src/modules/green-invoice/__generated__/types.d.ts +2 -1
- package/dist/server/src/modules/green-invoice/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.d.ts +5 -0
- package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.js +60 -0
- package/dist/server/src/modules/green-invoice/helpers/contract-to-draft.helper.js.map +1 -0
- package/dist/server/src/modules/green-invoice/resolvers/green-invoice.resolvers.js +10 -54
- package/dist/server/src/modules/green-invoice/resolvers/green-invoice.resolvers.js.map +1 -1
- package/dist/server/src/modules/green-invoice/typeDefs/green-invoice.graphql.js +4 -0
- package/dist/server/src/modules/green-invoice/typeDefs/green-invoice.graphql.js.map +1 -1
- package/package.json +1 -1
- package/src/__generated__/types.ts +43 -76
- package/src/modules/contracts/__generated__/contracts.types.ts +32 -0
- package/src/modules/contracts/__generated__/types.ts +3 -1
- package/src/modules/contracts/providers/contracts.provider.ts +51 -6
- package/src/modules/contracts/resolvers/contracts.resolver.ts +24 -0
- package/src/modules/contracts/typeDefs/contracts.graphql.ts +2 -0
- package/src/modules/financial-entities/__generated__/admin-businesses.types.ts +0 -60
- package/src/modules/financial-entities/__generated__/types.ts +10 -33
- package/src/modules/financial-entities/providers/admin-businesses.provider.ts +0 -44
- package/src/modules/financial-entities/resolvers/admin-businesses.resolver.ts +11 -53
- package/src/modules/financial-entities/typeDefs/admin-businesses.graphql.ts +16 -49
- package/src/modules/financial-entities/types.ts +1 -1
- package/src/modules/green-invoice/__generated__/types.ts +2 -1
- package/src/modules/green-invoice/helpers/contract-to-draft.helper.ts +75 -0
- package/src/modules/green-invoice/resolvers/green-invoice.resolvers.ts +15 -63
- package/src/modules/green-invoice/typeDefs/green-invoice.graphql.ts +4 -0
- package/dist/server/src/modules/financial-entities/helpers/admin-businesses.helper.d.ts +0 -31
- package/dist/server/src/modules/financial-entities/helpers/admin-businesses.helper.js +0 -27
- package/dist/server/src/modules/financial-entities/helpers/admin-businesses.helper.js.map +0 -1
- package/src/modules/financial-entities/helpers/admin-businesses.helper.ts +0 -33
package/dist/server/src/modules/financial-entities/__generated__/admin-businesses.types.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
/** Types generated for queries found in "src/modules/financial-entities/providers/admin-businesses.provider.ts" */
|
|
2
|
-
export type DateOrString = Date | string;
|
|
3
|
-
export type Json = null | boolean | number | string | Json[] | {
|
|
4
|
-
[key: string]: Json;
|
|
5
|
-
};
|
|
6
|
-
export type JsonArray = (Json)[];
|
|
7
2
|
/** 'GetAdminBusinessesByIds' parameters type */
|
|
8
3
|
export interface IGetAdminBusinessesByIdsParams {
|
|
9
4
|
ids: readonly (string | null | void)[];
|
|
@@ -11,9 +6,6 @@ export interface IGetAdminBusinessesByIdsParams {
|
|
|
11
6
|
/** 'GetAdminBusinessesByIds' return type */
|
|
12
7
|
export interface IGetAdminBusinessesByIdsResult {
|
|
13
8
|
advance_tax_rate: number | null;
|
|
14
|
-
advance_tax_rates: JsonArray;
|
|
15
|
-
business_registration_start_date: Date | null;
|
|
16
|
-
company_tax_id: string | null;
|
|
17
9
|
id: string;
|
|
18
10
|
name: string;
|
|
19
11
|
nikuim: string | null;
|
|
@@ -21,8 +13,6 @@ export interface IGetAdminBusinessesByIdsResult {
|
|
|
21
13
|
pinkas_social_security_2021: string | null;
|
|
22
14
|
pinkas_social_security_2022: string | null;
|
|
23
15
|
registration_date: Date | null;
|
|
24
|
-
social_security_employer_ids: JsonArray;
|
|
25
|
-
tax_advances_ids: JsonArray;
|
|
26
16
|
tax_nikuim_pinkas_number: string | null;
|
|
27
17
|
tax_pinkas_number_2020: string | null;
|
|
28
18
|
tax_siduri_number_2021: string | null;
|
|
@@ -31,7 +21,6 @@ export interface IGetAdminBusinessesByIdsResult {
|
|
|
31
21
|
vat_number: string | null;
|
|
32
22
|
vat_report_cadence: number | null;
|
|
33
23
|
website_login_screenshot: string | null;
|
|
34
|
-
withholding_tax_annual_ids: JsonArray;
|
|
35
24
|
wizcloud_company_id: string | null;
|
|
36
25
|
wizcloud_token: string | null;
|
|
37
26
|
}
|
|
@@ -45,9 +34,6 @@ export type IGetAllAdminBusinessesParams = void;
|
|
|
45
34
|
/** 'GetAllAdminBusinesses' return type */
|
|
46
35
|
export interface IGetAllAdminBusinessesResult {
|
|
47
36
|
advance_tax_rate: number | null;
|
|
48
|
-
advance_tax_rates: JsonArray;
|
|
49
|
-
business_registration_start_date: Date | null;
|
|
50
|
-
company_tax_id: string | null;
|
|
51
37
|
id: string;
|
|
52
38
|
name: string;
|
|
53
39
|
nikuim: string | null;
|
|
@@ -55,8 +41,6 @@ export interface IGetAllAdminBusinessesResult {
|
|
|
55
41
|
pinkas_social_security_2021: string | null;
|
|
56
42
|
pinkas_social_security_2022: string | null;
|
|
57
43
|
registration_date: Date | null;
|
|
58
|
-
social_security_employer_ids: JsonArray;
|
|
59
|
-
tax_advances_ids: JsonArray;
|
|
60
44
|
tax_nikuim_pinkas_number: string | null;
|
|
61
45
|
tax_pinkas_number_2020: string | null;
|
|
62
46
|
tax_siduri_number_2021: string | null;
|
|
@@ -65,7 +49,6 @@ export interface IGetAllAdminBusinessesResult {
|
|
|
65
49
|
vat_number: string | null;
|
|
66
50
|
vat_report_cadence: number | null;
|
|
67
51
|
website_login_screenshot: string | null;
|
|
68
|
-
withholding_tax_annual_ids: JsonArray;
|
|
69
52
|
wizcloud_company_id: string | null;
|
|
70
53
|
wizcloud_token: string | null;
|
|
71
54
|
}
|
|
@@ -74,43 +57,3 @@ export interface IGetAllAdminBusinessesQuery {
|
|
|
74
57
|
params: IGetAllAdminBusinessesParams;
|
|
75
58
|
result: IGetAllAdminBusinessesResult;
|
|
76
59
|
}
|
|
77
|
-
/** 'UpdateAdminBusinesses' parameters type */
|
|
78
|
-
export interface IUpdateAdminBusinessesParams {
|
|
79
|
-
advanceTaxRates?: JsonArray | null | void;
|
|
80
|
-
businessRegistrationStartDate?: DateOrString | null | void;
|
|
81
|
-
companyTaxId?: string | null | void;
|
|
82
|
-
id?: string | null | void;
|
|
83
|
-
socialSecurityEmployerIds?: JsonArray | null | void;
|
|
84
|
-
taxAdvancesIds?: JsonArray | null | void;
|
|
85
|
-
withholdingTaxAnnualIds?: JsonArray | null | void;
|
|
86
|
-
}
|
|
87
|
-
/** 'UpdateAdminBusinesses' return type */
|
|
88
|
-
export interface IUpdateAdminBusinessesResult {
|
|
89
|
-
advance_tax_rate: number | null;
|
|
90
|
-
advance_tax_rates: JsonArray;
|
|
91
|
-
business_registration_start_date: Date | null;
|
|
92
|
-
company_tax_id: string | null;
|
|
93
|
-
id: string;
|
|
94
|
-
nikuim: string | null;
|
|
95
|
-
password: string | null;
|
|
96
|
-
pinkas_social_security_2021: string | null;
|
|
97
|
-
pinkas_social_security_2022: string | null;
|
|
98
|
-
registration_date: Date | null;
|
|
99
|
-
social_security_employer_ids: JsonArray;
|
|
100
|
-
tax_advances_ids: JsonArray;
|
|
101
|
-
tax_nikuim_pinkas_number: string | null;
|
|
102
|
-
tax_pinkas_number_2020: string | null;
|
|
103
|
-
tax_siduri_number_2021: string | null;
|
|
104
|
-
tax_siduri_number_2022: string | null;
|
|
105
|
-
username_vat_website: string | null;
|
|
106
|
-
vat_report_cadence: number | null;
|
|
107
|
-
website_login_screenshot: string | null;
|
|
108
|
-
withholding_tax_annual_ids: JsonArray;
|
|
109
|
-
wizcloud_company_id: string | null;
|
|
110
|
-
wizcloud_token: string | null;
|
|
111
|
-
}
|
|
112
|
-
/** 'UpdateAdminBusinesses' query type */
|
|
113
|
-
export interface IUpdateAdminBusinessesQuery {
|
|
114
|
-
params: IUpdateAdminBusinessesParams;
|
|
115
|
-
result: IUpdateAdminBusinessesResult;
|
|
116
|
-
}
|
package/dist/server/src/modules/financial-entities/__generated__/admin-businesses.types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-businesses.types.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/__generated__/admin-businesses.types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"admin-businesses.types.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/__generated__/admin-businesses.types.ts"],"names":[],"mappings":"AAAA,mHAAmH"}
|
|
@@ -4,9 +4,7 @@ export declare namespace FinancialEntitiesModule {
|
|
|
4
4
|
interface DefinedFields {
|
|
5
5
|
Query: 'adminBusiness' | 'allAdminBusinesses' | 'businessTransactionsSumFromLedgerRecords' | 'businessTransactionsFromLedgerRecords' | 'business' | 'businesses' | 'allBusinesses' | 'client' | 'allClients' | 'financialEntity' | 'allFinancialEntities' | 'taxCategories' | 'taxCategory' | 'taxCategoryByBusinessId';
|
|
6
6
|
Mutation: 'createAdminBusiness' | 'updateAdminBusiness' | 'deleteAdminBusiness' | 'updateBusiness' | 'insertNewBusiness' | 'mergeBusinesses' | 'batchGenerateBusinessesOutOfTransactions' | 'updateClient' | 'insertClient' | 'updateTaxCategory' | 'insertTaxCategory';
|
|
7
|
-
AdminBusiness: 'id' | 'name' | 'governmentId' | '
|
|
8
|
-
AnnualId: 'year' | 'id';
|
|
9
|
-
TaxAdvancesRate: 'date' | 'rate';
|
|
7
|
+
AdminBusiness: 'id' | 'name' | 'governmentId' | 'business' | 'withholdingTaxBookNumber' | 'withholdingTaxFileNumber' | 'socialSecurityEmployerId' | 'taxAdvancesRate' | 'taxAdvancesId' | 'registrationDate';
|
|
10
8
|
BusinessTransactionsSumFromLedgerRecordsSuccessfulResult: 'businessTransactionsSum';
|
|
11
9
|
BusinessTransactionSum: 'business' | 'credit' | 'debit' | 'total' | 'foreignCurrenciesSum';
|
|
12
10
|
ForeignCurrencySum: 'credit' | 'debit' | 'total' | 'currency';
|
|
@@ -50,10 +48,8 @@ export declare namespace FinancialEntitiesModule {
|
|
|
50
48
|
EmailAttachmentType: 'PDF' | 'PNG' | 'JPEG';
|
|
51
49
|
}
|
|
52
50
|
interface DefinedInputFields {
|
|
53
|
-
CreateAdminBusinessInput: 'businessId' | '
|
|
54
|
-
UpdateAdminBusinessInput: '
|
|
55
|
-
AnnualIdInput: 'year' | 'id';
|
|
56
|
-
TaxAdvancesRateInput: 'date' | 'rate';
|
|
51
|
+
CreateAdminBusinessInput: 'businessId' | 'withholdingTaxBookNumber' | 'withholdingTaxFileNumber' | 'socialSecurityEmployerId' | 'taxAdvancesRate' | 'taxAdvancesId' | 'registrationDate';
|
|
52
|
+
UpdateAdminBusinessInput: 'withholdingTaxBookNumber' | 'withholdingTaxFileNumber' | 'socialSecurityEmployerId' | 'taxAdvancesRate' | 'taxAdvancesId' | 'registrationDate';
|
|
57
53
|
BusinessTransactionsFilter: 'businessIDs' | 'ownerIds' | 'type' | 'fromDate' | 'toDate' | 'includeRevaluation';
|
|
58
54
|
UpdateBusinessInput: 'name' | 'sortCode' | 'country' | 'hebrewName' | 'address' | 'email' | 'website' | 'phoneNumber' | 'governmentId' | 'taxCategory' | 'exemptDealer' | 'suggestions' | 'optionalVAT' | 'isReceiptEnough' | 'isDocumentsOptional' | 'pcn874RecordType' | 'irsCode' | 'isActive';
|
|
59
55
|
InsertNewBusinessInput: 'name' | 'sortCode' | 'country' | 'hebrewName' | 'address' | 'email' | 'website' | 'phoneNumber' | 'governmentId' | 'taxCategory' | 'exemptDealer' | 'suggestions' | 'optionalVAT' | 'isReceiptEnough' | 'isDocumentsOptional' | 'pcn874RecordType' | 'irsCode' | 'isActive';
|
|
@@ -71,12 +67,8 @@ export declare namespace FinancialEntitiesModule {
|
|
|
71
67
|
export type Mutation = Pick<Types.Mutation, DefinedFields['Mutation']>;
|
|
72
68
|
export type CreateAdminBusinessInput = Pick<Types.CreateAdminBusinessInput, DefinedInputFields['CreateAdminBusinessInput']>;
|
|
73
69
|
export type UpdateAdminBusinessInput = Pick<Types.UpdateAdminBusinessInput, DefinedInputFields['UpdateAdminBusinessInput']>;
|
|
74
|
-
export type TimelessDate = Types.TimelessDate;
|
|
75
70
|
export type LtdFinancialEntity = Pick<Types.LtdFinancialEntity, DefinedFields['LtdFinancialEntity']>;
|
|
76
|
-
export type
|
|
77
|
-
export type TaxAdvancesRate = Pick<Types.TaxAdvancesRate, DefinedFields['TaxAdvancesRate']>;
|
|
78
|
-
export type AnnualIdInput = Pick<Types.AnnualIdInput, DefinedInputFields['AnnualIdInput']>;
|
|
79
|
-
export type TaxAdvancesRateInput = Pick<Types.TaxAdvancesRateInput, DefinedInputFields['TaxAdvancesRateInput']>;
|
|
71
|
+
export type TimelessDate = Types.TimelessDate;
|
|
80
72
|
export type BusinessTransactionsSumFromLedgerRecordsResult = Types.BusinessTransactionsSumFromLedgerRecordsResult;
|
|
81
73
|
export type BusinessTransactionsFilter = Pick<Types.BusinessTransactionsFilter, DefinedInputFields['BusinessTransactionsFilter']>;
|
|
82
74
|
export type BusinessTransactionsFromLedgerRecordsResult = Types.BusinessTransactionsFromLedgerRecordsResult;
|
|
@@ -143,8 +135,6 @@ export declare namespace FinancialEntitiesModule {
|
|
|
143
135
|
export type QueryResolvers = Pick<Types.QueryResolvers, DefinedFields['Query']>;
|
|
144
136
|
export type MutationResolvers = Pick<Types.MutationResolvers, DefinedFields['Mutation']>;
|
|
145
137
|
export type AdminBusinessResolvers = Pick<Types.AdminBusinessResolvers, DefinedFields['AdminBusiness']>;
|
|
146
|
-
export type AnnualIdResolvers = Pick<Types.AnnualIdResolvers, DefinedFields['AnnualId']>;
|
|
147
|
-
export type TaxAdvancesRateResolvers = Pick<Types.TaxAdvancesRateResolvers, DefinedFields['TaxAdvancesRate']>;
|
|
148
138
|
export type BusinessTransactionsSumFromLedgerRecordsSuccessfulResultResolvers = Pick<Types.BusinessTransactionsSumFromLedgerRecordsSuccessfulResultResolvers, DefinedFields['BusinessTransactionsSumFromLedgerRecordsSuccessfulResult'] | '__isTypeOf'>;
|
|
149
139
|
export type BusinessTransactionSumResolvers = Pick<Types.BusinessTransactionSumResolvers, DefinedFields['BusinessTransactionSum']>;
|
|
150
140
|
export type ForeignCurrencySumResolvers = Pick<Types.ForeignCurrencySumResolvers, DefinedFields['ForeignCurrencySum']>;
|
|
@@ -186,8 +176,6 @@ export declare namespace FinancialEntitiesModule {
|
|
|
186
176
|
Query?: QueryResolvers;
|
|
187
177
|
Mutation?: MutationResolvers;
|
|
188
178
|
AdminBusiness?: AdminBusinessResolvers;
|
|
189
|
-
AnnualId?: AnnualIdResolvers;
|
|
190
|
-
TaxAdvancesRate?: TaxAdvancesRateResolvers;
|
|
191
179
|
BusinessTransactionsSumFromLedgerRecordsSuccessfulResult?: BusinessTransactionsSumFromLedgerRecordsSuccessfulResultResolvers;
|
|
192
180
|
BusinessTransactionSum?: BusinessTransactionSumResolvers;
|
|
193
181
|
ForeignCurrencySum?: ForeignCurrencySumResolvers;
|
|
@@ -261,24 +249,13 @@ export declare namespace FinancialEntitiesModule {
|
|
|
261
249
|
id?: gm.Middleware[];
|
|
262
250
|
name?: gm.Middleware[];
|
|
263
251
|
governmentId?: gm.Middleware[];
|
|
264
|
-
registrationDate?: gm.Middleware[];
|
|
265
252
|
business?: gm.Middleware[];
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
};
|
|
273
|
-
AnnualId?: {
|
|
274
|
-
'*'?: gm.Middleware[];
|
|
275
|
-
year?: gm.Middleware[];
|
|
276
|
-
id?: gm.Middleware[];
|
|
277
|
-
};
|
|
278
|
-
TaxAdvancesRate?: {
|
|
279
|
-
'*'?: gm.Middleware[];
|
|
280
|
-
date?: gm.Middleware[];
|
|
281
|
-
rate?: gm.Middleware[];
|
|
253
|
+
withholdingTaxBookNumber?: gm.Middleware[];
|
|
254
|
+
withholdingTaxFileNumber?: gm.Middleware[];
|
|
255
|
+
socialSecurityEmployerId?: gm.Middleware[];
|
|
256
|
+
taxAdvancesRate?: gm.Middleware[];
|
|
257
|
+
taxAdvancesId?: gm.Middleware[];
|
|
258
|
+
registrationDate?: gm.Middleware[];
|
|
282
259
|
};
|
|
283
260
|
LtdFinancialEntity?: {
|
|
284
261
|
'*'?: gm.Middleware[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/__generated__/types.ts"],"names":[],"mappings":"AAEA,MAAM,KAAW,uBAAuB,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/__generated__/types.ts"],"names":[],"mappings":"AAEA,MAAM,KAAW,uBAAuB,CAoevC;AApeD,WAAiB,uBAAuB;IA0CrC,CAAC;IAKD,CAAC;IAeD,CAAC;IAuJD,CAAC;IA8QD,CAAC;AACJ,CAAC,EApegB,uBAAuB,KAAvB,uBAAuB,QAoevC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import DataLoader from 'dataloader';
|
|
2
2
|
import { DBProvider } from '../../app-providers/db.provider.js';
|
|
3
|
-
import type { IGetAllAdminBusinessesResult
|
|
3
|
+
import type { IGetAllAdminBusinessesResult } from '../types.js';
|
|
4
4
|
export declare class AdminBusinessesProvider {
|
|
5
5
|
private dbProvider;
|
|
6
6
|
cache: {
|
|
@@ -16,6 +16,5 @@ export declare class AdminBusinessesProvider {
|
|
|
16
16
|
private batchAdminBusinessesByIds;
|
|
17
17
|
getAdminBusinessByIdLoader: DataLoader<string, import("../types.js").IGetAdminBusinessesByIdsResult | undefined, import("node-cache").Key | import("node-cache").Key[]>;
|
|
18
18
|
getAllAdminBusinesses(): Promise<IGetAllAdminBusinessesResult[]>;
|
|
19
|
-
updateAdminBusiness(params: IUpdateAdminBusinessesParams): Promise<IUpdateAdminBusinessesResult>;
|
|
20
19
|
clearCache(): void;
|
|
21
20
|
}
|
|
@@ -4,7 +4,6 @@ import { Injectable, Scope } from 'graphql-modules';
|
|
|
4
4
|
import { DBProvider } from '../../app-providers/db.provider.js';
|
|
5
5
|
import { sql } from '@pgtyped/runtime';
|
|
6
6
|
import { getCacheInstance } from '../../../shared/helpers/index.js';
|
|
7
|
-
import { adminBusinessUpdateSchema } from '../helpers/admin-businesses.helper.js';
|
|
8
7
|
const getAdminBusinessesByIds = sql `
|
|
9
8
|
SELECT ab.*, f.name, b.vat_number
|
|
10
9
|
FROM accounter_schema.businesses_admin ab
|
|
@@ -22,36 +21,6 @@ const getAllAdminBusinesses = sql `
|
|
|
22
21
|
USING (id)
|
|
23
22
|
INNER JOIN accounter_schema.financial_entities fe
|
|
24
23
|
USING (id);`;
|
|
25
|
-
const updateAdminBusinesses = sql `
|
|
26
|
-
UPDATE accounter_schema.businesses_admin
|
|
27
|
-
SET
|
|
28
|
-
business_registration_start_date = COALESCE(
|
|
29
|
-
$businessRegistrationStartDate,
|
|
30
|
-
business_registration_start_date
|
|
31
|
-
),
|
|
32
|
-
company_tax_id = COALESCE(
|
|
33
|
-
$companyTaxId,
|
|
34
|
-
company_tax_id
|
|
35
|
-
),
|
|
36
|
-
advance_tax_rates = COALESCE(
|
|
37
|
-
$advanceTaxRates,
|
|
38
|
-
advance_tax_rates
|
|
39
|
-
),
|
|
40
|
-
tax_advances_ids = COALESCE(
|
|
41
|
-
$taxAdvancesIds,
|
|
42
|
-
tax_advances_ids
|
|
43
|
-
),
|
|
44
|
-
social_security_employer_ids = COALESCE(
|
|
45
|
-
$socialSecurityEmployerIds,
|
|
46
|
-
social_security_employer_ids
|
|
47
|
-
),
|
|
48
|
-
withholding_tax_annual_ids = COALESCE(
|
|
49
|
-
$withholdingTaxAnnualIds,
|
|
50
|
-
withholding_tax_annual_ids
|
|
51
|
-
)
|
|
52
|
-
WHERE
|
|
53
|
-
id = $id
|
|
54
|
-
RETURNING *;`;
|
|
55
24
|
let AdminBusinessesProvider = class AdminBusinessesProvider {
|
|
56
25
|
dbProvider;
|
|
57
26
|
cache = getCacheInstance({
|
|
@@ -81,12 +50,6 @@ let AdminBusinessesProvider = class AdminBusinessesProvider {
|
|
|
81
50
|
return result;
|
|
82
51
|
});
|
|
83
52
|
}
|
|
84
|
-
async updateAdminBusiness(params) {
|
|
85
|
-
const inputParams = adminBusinessUpdateSchema.parse(params);
|
|
86
|
-
const [result] = await updateAdminBusinesses.run(inputParams, this.dbProvider);
|
|
87
|
-
this.clearCache();
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
53
|
clearCache() {
|
|
91
54
|
this.cache.clear();
|
|
92
55
|
}
|
package/dist/server/src/modules/financial-entities/providers/admin-businesses.provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-businesses.provider.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/providers/admin-businesses.provider.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,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;
|
|
1
|
+
{"version":3,"file":"admin-businesses.provider.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/providers/admin-businesses.provider.ts"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,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;AAOnD,MAAM,uBAAuB,GAAG,GAAG,CAA+B;;;;;;;0BAOxC,CAAC;AAE3B,MAAM,qBAAqB,GAAG,GAAG,CAA6B;;;;;;;;kBAQ5C,CAAC;AAMZ,IAAM,uBAAuB,GAA7B,MAAM,uBA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AAC;IAEM,UAAU;QACf,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF,CAAA;AAxCY,uBAAuB;IAJnC,UAAU,CAAC;QACV,KAAK,EAAE,KAAK,CAAC,SAAS;QACtB,MAAM,EAAE,IAAI;KACb,CAAC;qCAMgC,UAAU;GAL/B,uBAAuB,CAwCnC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GraphQLError } from 'graphql';
|
|
2
2
|
import { dateToTimelessDateString } from '../../../shared/helpers/index.js';
|
|
3
|
-
import { taxAdvancesRatesSchema, yearlyIdsSchema } from '../helpers/admin-businesses.helper.js';
|
|
4
3
|
import { AdminBusinessesProvider } from '../providers/admin-businesses.provider.js';
|
|
5
4
|
import { BusinessesProvider } from '../providers/businesses.provider.js';
|
|
6
5
|
export const adminBusinessesResolvers = {
|
|
@@ -19,39 +18,6 @@ export const adminBusinessesResolvers = {
|
|
|
19
18
|
return adminBusinesses;
|
|
20
19
|
},
|
|
21
20
|
},
|
|
22
|
-
Mutation: {
|
|
23
|
-
updateAdminBusiness: async (_, { businessId, fields }, { injector }) => {
|
|
24
|
-
try {
|
|
25
|
-
await injector.get(AdminBusinessesProvider).updateAdminBusiness({
|
|
26
|
-
id: businessId,
|
|
27
|
-
businessRegistrationStartDate: fields.registrationDate,
|
|
28
|
-
companyTaxId: fields.withholdingTaxCompanyId,
|
|
29
|
-
taxAdvancesIds: fields.taxAdvancesAnnualIds
|
|
30
|
-
? [...fields.taxAdvancesAnnualIds]
|
|
31
|
-
: undefined,
|
|
32
|
-
advanceTaxRates: fields.taxAdvancesRates ? [...fields.taxAdvancesRates] : undefined,
|
|
33
|
-
withholdingTaxAnnualIds: fields.withholdingTaxAnnualIds
|
|
34
|
-
? [...fields.withholdingTaxAnnualIds]
|
|
35
|
-
: undefined,
|
|
36
|
-
socialSecurityEmployerIds: fields.socialSecurityEmployerIds
|
|
37
|
-
? [...fields.socialSecurityEmployerIds]
|
|
38
|
-
: undefined,
|
|
39
|
-
});
|
|
40
|
-
const updatedAdminBusiness = await injector
|
|
41
|
-
.get(AdminBusinessesProvider)
|
|
42
|
-
.getAdminBusinessByIdLoader.load(businessId);
|
|
43
|
-
if (!updatedAdminBusiness) {
|
|
44
|
-
throw new GraphQLError(`Error updating Admin business ID="${businessId}"`);
|
|
45
|
-
}
|
|
46
|
-
return updatedAdminBusiness;
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
const message = `Error updating Admin business ID="${businessId}"`;
|
|
50
|
-
console.error(message, error);
|
|
51
|
-
throw new GraphQLError(message);
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
21
|
AdminBusiness: {
|
|
56
22
|
id: admin => admin.id,
|
|
57
23
|
name: admin => admin.name,
|
|
@@ -61,12 +27,6 @@ export const adminBusinessesResolvers = {
|
|
|
61
27
|
}
|
|
62
28
|
return admin.vat_number;
|
|
63
29
|
},
|
|
64
|
-
registrationDate: admin => {
|
|
65
|
-
if (!admin.registration_date) {
|
|
66
|
-
throw new GraphQLError(`Admin business ID="${admin.id}" has no registration date`);
|
|
67
|
-
}
|
|
68
|
-
return dateToTimelessDateString(admin.registration_date);
|
|
69
|
-
},
|
|
70
30
|
business: async (admin, _, { injector }) => {
|
|
71
31
|
const business = await injector.get(BusinessesProvider).getBusinessByIdLoader.load(admin.id);
|
|
72
32
|
if (!business) {
|
|
@@ -74,12 +34,17 @@ export const adminBusinessesResolvers = {
|
|
|
74
34
|
}
|
|
75
35
|
return business;
|
|
76
36
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
37
|
+
withholdingTaxBookNumber: admin => admin.tax_nikuim_pinkas_number,
|
|
38
|
+
withholdingTaxFileNumber: admin => admin.nikuim,
|
|
39
|
+
socialSecurityEmployerId: admin => admin.pinkas_social_security_2022,
|
|
40
|
+
taxAdvancesRate: admin => admin.advance_tax_rate,
|
|
41
|
+
taxAdvancesId: admin => admin.tax_siduri_number_2022,
|
|
42
|
+
registrationDate: admin => {
|
|
43
|
+
if (!admin.registration_date) {
|
|
44
|
+
throw new GraphQLError(`Admin business ID="${admin.id}" has no registration date`);
|
|
45
|
+
}
|
|
46
|
+
return dateToTimelessDateString(admin.registration_date);
|
|
47
|
+
},
|
|
83
48
|
},
|
|
84
49
|
LtdFinancialEntity: {
|
|
85
50
|
adminInfo: async (parentBusiness, _, { injector }) => {
|
package/dist/server/src/modules/financial-entities/resolvers/admin-businesses.resolver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-businesses.resolver.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/resolvers/admin-businesses.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"admin-businesses.resolver.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/resolvers/admin-businesses.resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGzE,MAAM,CAAC,MAAM,wBAAwB,GAAsC;IACzE,KAAK,EAAE;QACL,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC/C,MAAM,aAAa,GAAG,MAAM,QAAQ;iBACjC,GAAG,CAAC,uBAAuB,CAAC;iBAC5B,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACvC,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,MAA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AAC,KAAK,CAAC,2BAA2B;QACpE,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB;QAChD,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,sBAAsB;QACpD,gBAAgB,EAAE,KAAK,CAAC,EAAE;YACxB,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;gBAC7B,MAAM,IAAI,YAAY,CAAC,sBAAsB,KAAK,CAAC,EAAE,4BAA4B,CAAC,CAAC;YACrF,CAAC;YACD,OAAO,wBAAwB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC3D,CAAC;KACF;IACD,kBAAkB,EAAE;QAClB,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YACnD,MAAM,aAAa,GAAG,MAAM,QAAQ;iBACjC,GAAG,CAAC,uBAAuB,CAAC;iBAC5B,0BAA0B,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;YAEtD,OAAO,aAAa,IAAI,IAAI,CAAC;QAC/B,CAAC;KACF;CACF,CAAC"}
|
|
@@ -18,67 +18,34 @@ export default gql `
|
|
|
18
18
|
id: UUID!
|
|
19
19
|
name: String!
|
|
20
20
|
governmentId: String!
|
|
21
|
-
registrationDate: TimelessDate!
|
|
22
21
|
business: LtdFinancialEntity!
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
" Social Security Info "
|
|
30
|
-
socialSecurityDeductionsId: String
|
|
31
|
-
socialSecurityEmployerIds: [AnnualId!]!
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
" Represents an annual identifier for tax purposes. "
|
|
35
|
-
type AnnualId {
|
|
36
|
-
year: Int!
|
|
37
|
-
id: String!
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
" Represents the tax advance rate for a specific date. "
|
|
41
|
-
type TaxAdvancesRate {
|
|
42
|
-
date: TimelessDate!
|
|
43
|
-
rate: Float!
|
|
22
|
+
withholdingTaxBookNumber: String
|
|
23
|
+
withholdingTaxFileNumber: String
|
|
24
|
+
socialSecurityEmployerId: String
|
|
25
|
+
taxAdvancesRate: Float
|
|
26
|
+
taxAdvancesId: String
|
|
27
|
+
registrationDate: TimelessDate!
|
|
44
28
|
}
|
|
45
29
|
|
|
46
30
|
" Input type for creating a new admin business. "
|
|
47
31
|
input CreateAdminBusinessInput {
|
|
48
32
|
businessId: UUID!
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
taxAdvancesAnnualId: String
|
|
52
|
-
taxAdvancesRate: Float
|
|
53
|
-
withholdingTaxAnnualId: String
|
|
33
|
+
withholdingTaxBookNumber: String
|
|
34
|
+
withholdingTaxFileNumber: String
|
|
54
35
|
socialSecurityEmployerId: String
|
|
36
|
+
taxAdvancesRate: Float
|
|
37
|
+
taxAdvancesId: String
|
|
38
|
+
registrationDate: TimelessDate!
|
|
55
39
|
}
|
|
56
40
|
|
|
57
41
|
" Input type for updating admin business details. "
|
|
58
42
|
input UpdateAdminBusinessInput {
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
withholdingTaxBookNumber: String
|
|
44
|
+
withholdingTaxFileNumber: String
|
|
45
|
+
socialSecurityEmployerId: String
|
|
46
|
+
taxAdvancesRate: Float
|
|
47
|
+
taxAdvancesId: String
|
|
61
48
|
registrationDate: TimelessDate
|
|
62
|
-
" Tax Advances Info "
|
|
63
|
-
taxAdvancesAnnualIds: [AnnualIdInput!]
|
|
64
|
-
taxAdvancesRates: [TaxAdvancesRateInput!]
|
|
65
|
-
" Withholding Tax Info "
|
|
66
|
-
withholdingTaxCompanyId: String
|
|
67
|
-
withholdingTaxAnnualIds: [AnnualIdInput!]
|
|
68
|
-
" Social Security Info "
|
|
69
|
-
socialSecurityEmployerIds: [AnnualIdInput!]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
" Input type representing an annual identifier for tax purposes. "
|
|
73
|
-
input AnnualIdInput {
|
|
74
|
-
year: Int!
|
|
75
|
-
id: String!
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
" Input type representing the tax advance rate for a specific date. "
|
|
79
|
-
input TaxAdvancesRateInput {
|
|
80
|
-
date: TimelessDate!
|
|
81
|
-
rate: Float!
|
|
82
49
|
}
|
|
83
50
|
|
|
84
51
|
extend type LtdFinancialEntity {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-businesses.graphql.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/typeDefs/admin-businesses.graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,eAAe,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"admin-businesses.graphql.js","sourceRoot":"","sources":["../../../../../../src/modules/financial-entities/typeDefs/admin-businesses.graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDjB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './__generated__/types.js';
|
|
2
|
-
export type { Json, pcn874_record_type
|
|
2
|
+
export type { Json, pcn874_record_type } from './__generated__/businesses.types.js';
|
|
3
3
|
export * from './__generated__/businesses.types.js';
|
|
4
4
|
export * from './__generated__/businesses-operation.types.js';
|
|
5
5
|
export * from './__generated__/admin-businesses.types.js';
|
|
@@ -2,7 +2,7 @@ import * as Types from "../../../__generated__/types.js";
|
|
|
2
2
|
import * as gm from "graphql-modules";
|
|
3
3
|
export declare namespace GreenInvoiceModule {
|
|
4
4
|
interface DefinedFields {
|
|
5
|
-
Query: 'newDocumentInfoDraftByCharge' | 'newDocumentInfoDraftByDocument' | 'clientMonthlyChargesDrafts' | 'clientMonthlyChargeDraft' | 'greenInvoiceClient';
|
|
5
|
+
Query: 'newDocumentInfoDraftByCharge' | 'newDocumentInfoDraftByDocument' | 'clientMonthlyChargesDrafts' | 'clientChargesDraftsByContracts' | 'clientMonthlyChargeDraft' | 'greenInvoiceClient';
|
|
6
6
|
Mutation: 'fetchIncomeDocuments' | 'issueGreenInvoiceDocuments' | 'previewGreenInvoiceDocument' | 'issueGreenInvoiceDocument';
|
|
7
7
|
GenerateMonthlyClientDocumentsResult: 'success' | 'errors';
|
|
8
8
|
NewDocumentInfo: 'description' | 'remarks' | 'footer' | 'type' | 'date' | 'dueDate' | 'lang' | 'currency' | 'vatType' | 'discount' | 'rounding' | 'signed' | 'maxPayments' | 'client' | 'income' | 'payment' | 'linkedDocumentIds' | 'linkedPaymentId' | 'linkType';
|
|
@@ -91,6 +91,7 @@ export declare namespace GreenInvoiceModule {
|
|
|
91
91
|
newDocumentInfoDraftByCharge?: gm.Middleware[];
|
|
92
92
|
newDocumentInfoDraftByDocument?: gm.Middleware[];
|
|
93
93
|
clientMonthlyChargesDrafts?: gm.Middleware[];
|
|
94
|
+
clientChargesDraftsByContracts?: gm.Middleware[];
|
|
94
95
|
clientMonthlyChargeDraft?: gm.Middleware[];
|
|
95
96
|
greenInvoiceClient?: gm.Middleware[];
|
|
96
97
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/green-invoice/__generated__/types.ts"],"names":[],"mappings":"AAEA,MAAM,KAAW,kBAAkB,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/green-invoice/__generated__/types.ts"],"names":[],"mappings":"AAEA,MAAM,KAAW,kBAAkB,CAiMlC;AAjMD,WAAiB,kBAAkB;IAWhC,CAAC;IAaD,CAAC;IAQD,CAAC;IAsDD,CAAC;IA0GD,CAAC;AACJ,CAAC,EAjMgB,kBAAkB,KAAlB,kBAAkB,QAiMlC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Injector } from 'graphql-modules';
|
|
2
|
+
import type { IGetContractsByIdsResult } from '../../contracts/types.js';
|
|
3
|
+
import { NewDocumentInfo } from '../../../__generated__/types.js';
|
|
4
|
+
import { TimelessDateString } from '../../../shared/types/index.js';
|
|
5
|
+
export declare const convertContractToDraft: (contract: IGetContractsByIdsResult, injector: Injector, issueMonth: TimelessDateString) => Promise<NewDocumentInfo>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { addMonths, endOfMonth, format, startOfMonth, subMonths } from 'date-fns';
|
|
2
|
+
import { GraphQLError } from 'graphql';
|
|
3
|
+
import { normalizeDocumentType } from '../../documents/resolvers/common.js';
|
|
4
|
+
import { BusinessesProvider } from '../../financial-entities/providers/businesses.provider.js';
|
|
5
|
+
import { ClientsProvider } from '../../financial-entities/providers/clients.provider.js';
|
|
6
|
+
import { dateToTimelessDateString } from '../../../shared/helpers/index.js';
|
|
7
|
+
import { getClientFromGreenInvoiceClient } from './issue-document.helper.js';
|
|
8
|
+
export const convertContractToDraft = async (contract, injector, issueMonth) => {
|
|
9
|
+
const businessPromise = injector
|
|
10
|
+
.get(BusinessesProvider)
|
|
11
|
+
.getBusinessByIdLoader.load(contract.client_id);
|
|
12
|
+
const clientPromise = injector.get(ClientsProvider).getClientByIdLoader.load(contract.client_id);
|
|
13
|
+
const greenInvoiceClientPromise = getClientFromGreenInvoiceClient(injector, contract.client_id);
|
|
14
|
+
const [business, client, greenInvoiceClient] = await Promise.all([
|
|
15
|
+
businessPromise,
|
|
16
|
+
clientPromise,
|
|
17
|
+
greenInvoiceClientPromise,
|
|
18
|
+
]);
|
|
19
|
+
if (!business) {
|
|
20
|
+
throw new GraphQLError(`Business ID="${contract.client_id}" not found`);
|
|
21
|
+
}
|
|
22
|
+
if (!client) {
|
|
23
|
+
throw new GraphQLError(`Client not found for business ID="${contract.client_id}"`);
|
|
24
|
+
}
|
|
25
|
+
if (!greenInvoiceClient) {
|
|
26
|
+
throw new GraphQLError(`Green invoice match not found for business ID="${contract.client_id}"`);
|
|
27
|
+
}
|
|
28
|
+
const today = issueMonth ? addMonths(new Date(issueMonth), 1) : new Date();
|
|
29
|
+
const monthStart = dateToTimelessDateString(startOfMonth(today));
|
|
30
|
+
const monthEnd = dateToTimelessDateString(endOfMonth(today));
|
|
31
|
+
const year = today.getFullYear() + (today.getMonth() === 0 ? -1 : 0);
|
|
32
|
+
const month = format(subMonths(today, 1), 'MMMM');
|
|
33
|
+
const documentInput = {
|
|
34
|
+
remarks: `${contract.purchase_orders[0] ? `PO: ${contract.purchase_orders[0]}${contract.remarks ? ', ' : ''}` : ''}${contract.remarks ?? ''}`,
|
|
35
|
+
description: `GraphQL Hive Enterprise License - ${month} ${year}`,
|
|
36
|
+
type: normalizeDocumentType(contract.document_type),
|
|
37
|
+
date: monthStart,
|
|
38
|
+
dueDate: monthEnd,
|
|
39
|
+
lang: 'ENGLISH',
|
|
40
|
+
currency: contract.currency,
|
|
41
|
+
vatType: 'EXEMPT',
|
|
42
|
+
rounding: false,
|
|
43
|
+
signed: true,
|
|
44
|
+
client: {
|
|
45
|
+
...greenInvoiceClient,
|
|
46
|
+
emails: [...(client.emails?.filter(Boolean) ?? [])],
|
|
47
|
+
},
|
|
48
|
+
income: [
|
|
49
|
+
{
|
|
50
|
+
description: `GraphQL Hive Enterprise License - ${month} ${year}`,
|
|
51
|
+
quantity: 1,
|
|
52
|
+
price: contract.amount,
|
|
53
|
+
currency: contract.currency,
|
|
54
|
+
vatType: 'EXEMPT',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
return documentInput;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=contract-to-draft.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-to-draft.helper.js","sourceRoot":"","sources":["../../../../../../src/modules/green-invoice/helpers/contract-to-draft.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,E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