@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
|
@@ -29,6 +29,30 @@ export const contractsResolvers: ContractsModule.Resolvers = {
|
|
|
29
29
|
throw new GraphQLError(message);
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
contractsByAdmin: async (_, { adminId }, { injector }) => {
|
|
33
|
+
try {
|
|
34
|
+
return injector.get(ContractsProvider).getContractsByAdminBusinessIdLoader.load(adminId);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
const message = 'Error fetching contracts by admin';
|
|
37
|
+
console.error(message, e);
|
|
38
|
+
throw new GraphQLError(message);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
contractsById: async (_, { id }, { injector }) => {
|
|
42
|
+
try {
|
|
43
|
+
return injector
|
|
44
|
+
.get(ContractsProvider)
|
|
45
|
+
.getContractsByIdLoader.load(id)
|
|
46
|
+
.then(res => {
|
|
47
|
+
if (!res) throw new GraphQLError('Contract not found');
|
|
48
|
+
return res;
|
|
49
|
+
});
|
|
50
|
+
} catch (e) {
|
|
51
|
+
const message = 'Error fetching contracts by id';
|
|
52
|
+
console.error(message, e);
|
|
53
|
+
throw new GraphQLError(message);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
32
56
|
},
|
|
33
57
|
Mutation: {
|
|
34
58
|
createContract: async (_, { input }, { injector }) => {
|
|
@@ -4,6 +4,8 @@ export default gql`
|
|
|
4
4
|
extend type Query {
|
|
5
5
|
allOpenContracts: [Contract!]! @auth(role: ACCOUNTANT)
|
|
6
6
|
contractsByClient(clientId: UUID!): [Contract!]! @auth(role: ACCOUNTANT)
|
|
7
|
+
contractsByAdmin(adminId: UUID!): [Contract!]! @auth(role: ACCOUNTANT)
|
|
8
|
+
contractsById(id: UUID!): Contract! @auth(role: ACCOUNTANT)
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
extend type Mutation {
|
|
@@ -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
|
-
|
|
4
|
-
export type Json = null | boolean | number | string | Json[] | { [key: string]: Json };
|
|
5
|
-
|
|
6
|
-
export type JsonArray = (Json)[];
|
|
7
2
|
|
|
8
3
|
/** 'GetAdminBusinessesByIds' parameters type */
|
|
9
4
|
export interface IGetAdminBusinessesByIdsParams {
|
|
@@ -13,9 +8,6 @@ export interface IGetAdminBusinessesByIdsParams {
|
|
|
13
8
|
/** 'GetAdminBusinessesByIds' return type */
|
|
14
9
|
export interface IGetAdminBusinessesByIdsResult {
|
|
15
10
|
advance_tax_rate: number | null;
|
|
16
|
-
advance_tax_rates: JsonArray;
|
|
17
|
-
business_registration_start_date: Date | null;
|
|
18
|
-
company_tax_id: string | null;
|
|
19
11
|
id: string;
|
|
20
12
|
name: string;
|
|
21
13
|
nikuim: string | null;
|
|
@@ -23,8 +15,6 @@ export interface IGetAdminBusinessesByIdsResult {
|
|
|
23
15
|
pinkas_social_security_2021: string | null;
|
|
24
16
|
pinkas_social_security_2022: string | null;
|
|
25
17
|
registration_date: Date | null;
|
|
26
|
-
social_security_employer_ids: JsonArray;
|
|
27
|
-
tax_advances_ids: JsonArray;
|
|
28
18
|
tax_nikuim_pinkas_number: string | null;
|
|
29
19
|
tax_pinkas_number_2020: string | null;
|
|
30
20
|
tax_siduri_number_2021: string | null;
|
|
@@ -33,7 +23,6 @@ export interface IGetAdminBusinessesByIdsResult {
|
|
|
33
23
|
vat_number: string | null;
|
|
34
24
|
vat_report_cadence: number | null;
|
|
35
25
|
website_login_screenshot: string | null;
|
|
36
|
-
withholding_tax_annual_ids: JsonArray;
|
|
37
26
|
wizcloud_company_id: string | null;
|
|
38
27
|
wizcloud_token: string | null;
|
|
39
28
|
}
|
|
@@ -50,9 +39,6 @@ export type IGetAllAdminBusinessesParams = void;
|
|
|
50
39
|
/** 'GetAllAdminBusinesses' return type */
|
|
51
40
|
export interface IGetAllAdminBusinessesResult {
|
|
52
41
|
advance_tax_rate: number | null;
|
|
53
|
-
advance_tax_rates: JsonArray;
|
|
54
|
-
business_registration_start_date: Date | null;
|
|
55
|
-
company_tax_id: string | null;
|
|
56
42
|
id: string;
|
|
57
43
|
name: string;
|
|
58
44
|
nikuim: string | null;
|
|
@@ -60,8 +46,6 @@ export interface IGetAllAdminBusinessesResult {
|
|
|
60
46
|
pinkas_social_security_2021: string | null;
|
|
61
47
|
pinkas_social_security_2022: string | null;
|
|
62
48
|
registration_date: Date | null;
|
|
63
|
-
social_security_employer_ids: JsonArray;
|
|
64
|
-
tax_advances_ids: JsonArray;
|
|
65
49
|
tax_nikuim_pinkas_number: string | null;
|
|
66
50
|
tax_pinkas_number_2020: string | null;
|
|
67
51
|
tax_siduri_number_2021: string | null;
|
|
@@ -70,7 +54,6 @@ export interface IGetAllAdminBusinessesResult {
|
|
|
70
54
|
vat_number: string | null;
|
|
71
55
|
vat_report_cadence: number | null;
|
|
72
56
|
website_login_screenshot: string | null;
|
|
73
|
-
withholding_tax_annual_ids: JsonArray;
|
|
74
57
|
wizcloud_company_id: string | null;
|
|
75
58
|
wizcloud_token: string | null;
|
|
76
59
|
}
|
|
@@ -81,46 +64,3 @@ export interface IGetAllAdminBusinessesQuery {
|
|
|
81
64
|
result: IGetAllAdminBusinessesResult;
|
|
82
65
|
}
|
|
83
66
|
|
|
84
|
-
/** 'UpdateAdminBusinesses' parameters type */
|
|
85
|
-
export interface IUpdateAdminBusinessesParams {
|
|
86
|
-
advanceTaxRates?: JsonArray | null | void;
|
|
87
|
-
businessRegistrationStartDate?: DateOrString | null | void;
|
|
88
|
-
companyTaxId?: string | null | void;
|
|
89
|
-
id?: string | null | void;
|
|
90
|
-
socialSecurityEmployerIds?: JsonArray | null | void;
|
|
91
|
-
taxAdvancesIds?: JsonArray | null | void;
|
|
92
|
-
withholdingTaxAnnualIds?: JsonArray | null | void;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** 'UpdateAdminBusinesses' return type */
|
|
96
|
-
export interface IUpdateAdminBusinessesResult {
|
|
97
|
-
advance_tax_rate: number | null;
|
|
98
|
-
advance_tax_rates: JsonArray;
|
|
99
|
-
business_registration_start_date: Date | null;
|
|
100
|
-
company_tax_id: string | null;
|
|
101
|
-
id: string;
|
|
102
|
-
nikuim: string | null;
|
|
103
|
-
password: string | null;
|
|
104
|
-
pinkas_social_security_2021: string | null;
|
|
105
|
-
pinkas_social_security_2022: string | null;
|
|
106
|
-
registration_date: Date | null;
|
|
107
|
-
social_security_employer_ids: JsonArray;
|
|
108
|
-
tax_advances_ids: JsonArray;
|
|
109
|
-
tax_nikuim_pinkas_number: string | null;
|
|
110
|
-
tax_pinkas_number_2020: string | null;
|
|
111
|
-
tax_siduri_number_2021: string | null;
|
|
112
|
-
tax_siduri_number_2022: string | null;
|
|
113
|
-
username_vat_website: string | null;
|
|
114
|
-
vat_report_cadence: number | null;
|
|
115
|
-
website_login_screenshot: string | null;
|
|
116
|
-
withholding_tax_annual_ids: JsonArray;
|
|
117
|
-
wizcloud_company_id: string | null;
|
|
118
|
-
wizcloud_token: string | null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** 'UpdateAdminBusinesses' query type */
|
|
122
|
-
export interface IUpdateAdminBusinessesQuery {
|
|
123
|
-
params: IUpdateAdminBusinessesParams;
|
|
124
|
-
result: IUpdateAdminBusinessesResult;
|
|
125
|
-
}
|
|
126
|
-
|
|
@@ -4,9 +4,7 @@ export 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';
|
|
@@ -52,10 +50,8 @@ export namespace FinancialEntitiesModule {
|
|
|
52
50
|
};
|
|
53
51
|
|
|
54
52
|
interface DefinedInputFields {
|
|
55
|
-
CreateAdminBusinessInput: 'businessId' | '
|
|
56
|
-
UpdateAdminBusinessInput: '
|
|
57
|
-
AnnualIdInput: 'year' | 'id';
|
|
58
|
-
TaxAdvancesRateInput: 'date' | 'rate';
|
|
53
|
+
CreateAdminBusinessInput: 'businessId' | 'withholdingTaxBookNumber' | 'withholdingTaxFileNumber' | 'socialSecurityEmployerId' | 'taxAdvancesRate' | 'taxAdvancesId' | 'registrationDate';
|
|
54
|
+
UpdateAdminBusinessInput: 'withholdingTaxBookNumber' | 'withholdingTaxFileNumber' | 'socialSecurityEmployerId' | 'taxAdvancesRate' | 'taxAdvancesId' | 'registrationDate';
|
|
59
55
|
BusinessTransactionsFilter: 'businessIDs' | 'ownerIds' | 'type' | 'fromDate' | 'toDate' | 'includeRevaluation';
|
|
60
56
|
UpdateBusinessInput: 'name' | 'sortCode' | 'country' | 'hebrewName' | 'address' | 'email' | 'website' | 'phoneNumber' | 'governmentId' | 'taxCategory' | 'exemptDealer' | 'suggestions' | 'optionalVAT' | 'isReceiptEnough' | 'isDocumentsOptional' | 'pcn874RecordType' | 'irsCode' | 'isActive';
|
|
61
57
|
InsertNewBusinessInput: 'name' | 'sortCode' | 'country' | 'hebrewName' | 'address' | 'email' | 'website' | 'phoneNumber' | 'governmentId' | 'taxCategory' | 'exemptDealer' | 'suggestions' | 'optionalVAT' | 'isReceiptEnough' | 'isDocumentsOptional' | 'pcn874RecordType' | 'irsCode' | 'isActive';
|
|
@@ -74,12 +70,8 @@ export namespace FinancialEntitiesModule {
|
|
|
74
70
|
export type Mutation = Pick<Types.Mutation, DefinedFields['Mutation']>;
|
|
75
71
|
export type CreateAdminBusinessInput = Pick<Types.CreateAdminBusinessInput, DefinedInputFields['CreateAdminBusinessInput']>;
|
|
76
72
|
export type UpdateAdminBusinessInput = Pick<Types.UpdateAdminBusinessInput, DefinedInputFields['UpdateAdminBusinessInput']>;
|
|
77
|
-
export type TimelessDate = Types.TimelessDate;
|
|
78
73
|
export type LtdFinancialEntity = Pick<Types.LtdFinancialEntity, DefinedFields['LtdFinancialEntity']>;
|
|
79
|
-
export type
|
|
80
|
-
export type TaxAdvancesRate = Pick<Types.TaxAdvancesRate, DefinedFields['TaxAdvancesRate']>;
|
|
81
|
-
export type AnnualIdInput = Pick<Types.AnnualIdInput, DefinedInputFields['AnnualIdInput']>;
|
|
82
|
-
export type TaxAdvancesRateInput = Pick<Types.TaxAdvancesRateInput, DefinedInputFields['TaxAdvancesRateInput']>;
|
|
74
|
+
export type TimelessDate = Types.TimelessDate;
|
|
83
75
|
export type BusinessTransactionsSumFromLedgerRecordsResult = Types.BusinessTransactionsSumFromLedgerRecordsResult;
|
|
84
76
|
export type BusinessTransactionsFilter = Pick<Types.BusinessTransactionsFilter, DefinedInputFields['BusinessTransactionsFilter']>;
|
|
85
77
|
export type BusinessTransactionsFromLedgerRecordsResult = Types.BusinessTransactionsFromLedgerRecordsResult;
|
|
@@ -147,8 +139,6 @@ export namespace FinancialEntitiesModule {
|
|
|
147
139
|
export type QueryResolvers = Pick<Types.QueryResolvers, DefinedFields['Query']>;
|
|
148
140
|
export type MutationResolvers = Pick<Types.MutationResolvers, DefinedFields['Mutation']>;
|
|
149
141
|
export type AdminBusinessResolvers = Pick<Types.AdminBusinessResolvers, DefinedFields['AdminBusiness']>;
|
|
150
|
-
export type AnnualIdResolvers = Pick<Types.AnnualIdResolvers, DefinedFields['AnnualId']>;
|
|
151
|
-
export type TaxAdvancesRateResolvers = Pick<Types.TaxAdvancesRateResolvers, DefinedFields['TaxAdvancesRate']>;
|
|
152
142
|
export type BusinessTransactionsSumFromLedgerRecordsSuccessfulResultResolvers = Pick<Types.BusinessTransactionsSumFromLedgerRecordsSuccessfulResultResolvers, DefinedFields['BusinessTransactionsSumFromLedgerRecordsSuccessfulResult'] | '__isTypeOf'>;
|
|
153
143
|
export type BusinessTransactionSumResolvers = Pick<Types.BusinessTransactionSumResolvers, DefinedFields['BusinessTransactionSum']>;
|
|
154
144
|
export type ForeignCurrencySumResolvers = Pick<Types.ForeignCurrencySumResolvers, DefinedFields['ForeignCurrencySum']>;
|
|
@@ -191,8 +181,6 @@ export namespace FinancialEntitiesModule {
|
|
|
191
181
|
Query?: QueryResolvers;
|
|
192
182
|
Mutation?: MutationResolvers;
|
|
193
183
|
AdminBusiness?: AdminBusinessResolvers;
|
|
194
|
-
AnnualId?: AnnualIdResolvers;
|
|
195
|
-
TaxAdvancesRate?: TaxAdvancesRateResolvers;
|
|
196
184
|
BusinessTransactionsSumFromLedgerRecordsSuccessfulResult?: BusinessTransactionsSumFromLedgerRecordsSuccessfulResultResolvers;
|
|
197
185
|
BusinessTransactionSum?: BusinessTransactionSumResolvers;
|
|
198
186
|
ForeignCurrencySum?: ForeignCurrencySumResolvers;
|
|
@@ -267,24 +255,13 @@ export namespace FinancialEntitiesModule {
|
|
|
267
255
|
id?: gm.Middleware[];
|
|
268
256
|
name?: gm.Middleware[];
|
|
269
257
|
governmentId?: gm.Middleware[];
|
|
270
|
-
registrationDate?: gm.Middleware[];
|
|
271
258
|
business?: gm.Middleware[];
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
};
|
|
279
|
-
AnnualId?: {
|
|
280
|
-
'*'?: gm.Middleware[];
|
|
281
|
-
year?: gm.Middleware[];
|
|
282
|
-
id?: gm.Middleware[];
|
|
283
|
-
};
|
|
284
|
-
TaxAdvancesRate?: {
|
|
285
|
-
'*'?: gm.Middleware[];
|
|
286
|
-
date?: gm.Middleware[];
|
|
287
|
-
rate?: gm.Middleware[];
|
|
259
|
+
withholdingTaxBookNumber?: gm.Middleware[];
|
|
260
|
+
withholdingTaxFileNumber?: gm.Middleware[];
|
|
261
|
+
socialSecurityEmployerId?: gm.Middleware[];
|
|
262
|
+
taxAdvancesRate?: gm.Middleware[];
|
|
263
|
+
taxAdvancesId?: gm.Middleware[];
|
|
264
|
+
registrationDate?: gm.Middleware[];
|
|
288
265
|
};
|
|
289
266
|
LtdFinancialEntity?: {
|
|
290
267
|
'*'?: gm.Middleware[];
|
|
@@ -3,14 +3,10 @@ import { Injectable, Scope } from 'graphql-modules';
|
|
|
3
3
|
import { DBProvider } from '@modules/app-providers/db.provider.js';
|
|
4
4
|
import { sql } from '@pgtyped/runtime';
|
|
5
5
|
import { getCacheInstance } from '@shared/helpers';
|
|
6
|
-
import { adminBusinessUpdateSchema } from '../helpers/admin-businesses.helper.js';
|
|
7
6
|
import type {
|
|
8
7
|
IGetAdminBusinessesByIdsQuery,
|
|
9
8
|
IGetAllAdminBusinessesQuery,
|
|
10
9
|
IGetAllAdminBusinessesResult,
|
|
11
|
-
IUpdateAdminBusinessesParams,
|
|
12
|
-
IUpdateAdminBusinessesQuery,
|
|
13
|
-
IUpdateAdminBusinessesResult,
|
|
14
10
|
} from '../types.js';
|
|
15
11
|
|
|
16
12
|
const getAdminBusinessesByIds = sql<IGetAdminBusinessesByIdsQuery>`
|
|
@@ -32,37 +28,6 @@ const getAllAdminBusinesses = sql<IGetAllAdminBusinessesQuery>`
|
|
|
32
28
|
INNER JOIN accounter_schema.financial_entities fe
|
|
33
29
|
USING (id);`;
|
|
34
30
|
|
|
35
|
-
const updateAdminBusinesses = sql<IUpdateAdminBusinessesQuery>`
|
|
36
|
-
UPDATE accounter_schema.businesses_admin
|
|
37
|
-
SET
|
|
38
|
-
business_registration_start_date = COALESCE(
|
|
39
|
-
$businessRegistrationStartDate,
|
|
40
|
-
business_registration_start_date
|
|
41
|
-
),
|
|
42
|
-
company_tax_id = COALESCE(
|
|
43
|
-
$companyTaxId,
|
|
44
|
-
company_tax_id
|
|
45
|
-
),
|
|
46
|
-
advance_tax_rates = COALESCE(
|
|
47
|
-
$advanceTaxRates,
|
|
48
|
-
advance_tax_rates
|
|
49
|
-
),
|
|
50
|
-
tax_advances_ids = COALESCE(
|
|
51
|
-
$taxAdvancesIds,
|
|
52
|
-
tax_advances_ids
|
|
53
|
-
),
|
|
54
|
-
social_security_employer_ids = COALESCE(
|
|
55
|
-
$socialSecurityEmployerIds,
|
|
56
|
-
social_security_employer_ids
|
|
57
|
-
),
|
|
58
|
-
withholding_tax_annual_ids = COALESCE(
|
|
59
|
-
$withholdingTaxAnnualIds,
|
|
60
|
-
withholding_tax_annual_ids
|
|
61
|
-
)
|
|
62
|
-
WHERE
|
|
63
|
-
id = $id
|
|
64
|
-
RETURNING *;`;
|
|
65
|
-
|
|
66
31
|
@Injectable({
|
|
67
32
|
scope: Scope.Operation,
|
|
68
33
|
global: true,
|
|
@@ -104,15 +69,6 @@ export class AdminBusinessesProvider {
|
|
|
104
69
|
});
|
|
105
70
|
}
|
|
106
71
|
|
|
107
|
-
public async updateAdminBusiness(
|
|
108
|
-
params: IUpdateAdminBusinessesParams,
|
|
109
|
-
): Promise<IUpdateAdminBusinessesResult> {
|
|
110
|
-
const inputParams = adminBusinessUpdateSchema.parse(params);
|
|
111
|
-
const [result] = await updateAdminBusinesses.run(inputParams, this.dbProvider);
|
|
112
|
-
this.clearCache();
|
|
113
|
-
return result;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
72
|
public clearCache() {
|
|
117
73
|
this.cache.clear();
|
|
118
74
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { GraphQLError } from 'graphql';
|
|
2
2
|
import { dateToTimelessDateString } from '@shared/helpers';
|
|
3
|
-
import { TimelessDateString } from '@shared/types';
|
|
4
|
-
import { taxAdvancesRatesSchema, yearlyIdsSchema } from '../helpers/admin-businesses.helper.js';
|
|
5
3
|
import { AdminBusinessesProvider } from '../providers/admin-businesses.provider.js';
|
|
6
4
|
import { BusinessesProvider } from '../providers/businesses.provider.js';
|
|
7
5
|
import type { FinancialEntitiesModule } from '../types.js';
|
|
@@ -24,41 +22,6 @@ export const adminBusinessesResolvers: FinancialEntitiesModule.Resolvers = {
|
|
|
24
22
|
return adminBusinesses;
|
|
25
23
|
},
|
|
26
24
|
},
|
|
27
|
-
Mutation: {
|
|
28
|
-
updateAdminBusiness: async (_, { businessId, fields }, { injector }) => {
|
|
29
|
-
try {
|
|
30
|
-
await injector.get(AdminBusinessesProvider).updateAdminBusiness({
|
|
31
|
-
id: businessId,
|
|
32
|
-
businessRegistrationStartDate: fields.registrationDate,
|
|
33
|
-
companyTaxId: fields.withholdingTaxCompanyId,
|
|
34
|
-
taxAdvancesIds: fields.taxAdvancesAnnualIds
|
|
35
|
-
? [...fields.taxAdvancesAnnualIds]
|
|
36
|
-
: undefined,
|
|
37
|
-
advanceTaxRates: fields.taxAdvancesRates ? [...fields.taxAdvancesRates] : undefined,
|
|
38
|
-
withholdingTaxAnnualIds: fields.withholdingTaxAnnualIds
|
|
39
|
-
? [...fields.withholdingTaxAnnualIds]
|
|
40
|
-
: undefined,
|
|
41
|
-
socialSecurityEmployerIds: fields.socialSecurityEmployerIds
|
|
42
|
-
? [...fields.socialSecurityEmployerIds]
|
|
43
|
-
: undefined,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const updatedAdminBusiness = await injector
|
|
47
|
-
.get(AdminBusinessesProvider)
|
|
48
|
-
.getAdminBusinessByIdLoader.load(businessId);
|
|
49
|
-
|
|
50
|
-
if (!updatedAdminBusiness) {
|
|
51
|
-
throw new GraphQLError(`Error updating Admin business ID="${businessId}"`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return updatedAdminBusiness;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
const message = `Error updating Admin business ID="${businessId}"`;
|
|
57
|
-
console.error(message, error);
|
|
58
|
-
throw new GraphQLError(message);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
25
|
AdminBusiness: {
|
|
63
26
|
id: admin => admin.id,
|
|
64
27
|
name: admin => admin.name,
|
|
@@ -68,12 +31,6 @@ export const adminBusinessesResolvers: FinancialEntitiesModule.Resolvers = {
|
|
|
68
31
|
}
|
|
69
32
|
return admin.vat_number;
|
|
70
33
|
},
|
|
71
|
-
registrationDate: admin => {
|
|
72
|
-
if (!admin.registration_date) {
|
|
73
|
-
throw new GraphQLError(`Admin business ID="${admin.id}" has no registration date`);
|
|
74
|
-
}
|
|
75
|
-
return dateToTimelessDateString(admin.registration_date);
|
|
76
|
-
},
|
|
77
34
|
business: async (admin, _, { injector }) => {
|
|
78
35
|
const business = await injector.get(BusinessesProvider).getBusinessByIdLoader.load(admin.id);
|
|
79
36
|
if (!business) {
|
|
@@ -81,16 +38,17 @@ export const adminBusinessesResolvers: FinancialEntitiesModule.Resolvers = {
|
|
|
81
38
|
}
|
|
82
39
|
return business;
|
|
83
40
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
41
|
+
withholdingTaxBookNumber: admin => admin.tax_nikuim_pinkas_number,
|
|
42
|
+
withholdingTaxFileNumber: admin => admin.nikuim,
|
|
43
|
+
socialSecurityEmployerId: admin => admin.pinkas_social_security_2022,
|
|
44
|
+
taxAdvancesRate: admin => admin.advance_tax_rate,
|
|
45
|
+
taxAdvancesId: admin => admin.tax_siduri_number_2022,
|
|
46
|
+
registrationDate: admin => {
|
|
47
|
+
if (!admin.registration_date) {
|
|
48
|
+
throw new GraphQLError(`Admin business ID="${admin.id}" has no registration date`);
|
|
49
|
+
}
|
|
50
|
+
return dateToTimelessDateString(admin.registration_date);
|
|
51
|
+
},
|
|
94
52
|
},
|
|
95
53
|
LtdFinancialEntity: {
|
|
96
54
|
adminInfo: async (parentBusiness, _, { injector }) => {
|
|
@@ -19,67 +19,34 @@ export default gql`
|
|
|
19
19
|
id: UUID!
|
|
20
20
|
name: String!
|
|
21
21
|
governmentId: String!
|
|
22
|
-
registrationDate: TimelessDate!
|
|
23
22
|
business: LtdFinancialEntity!
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
" Social Security Info "
|
|
31
|
-
socialSecurityDeductionsId: String
|
|
32
|
-
socialSecurityEmployerIds: [AnnualId!]!
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
" Represents an annual identifier for tax purposes. "
|
|
36
|
-
type AnnualId {
|
|
37
|
-
year: Int!
|
|
38
|
-
id: String!
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
" Represents the tax advance rate for a specific date. "
|
|
42
|
-
type TaxAdvancesRate {
|
|
43
|
-
date: TimelessDate!
|
|
44
|
-
rate: Float!
|
|
23
|
+
withholdingTaxBookNumber: String
|
|
24
|
+
withholdingTaxFileNumber: String
|
|
25
|
+
socialSecurityEmployerId: String
|
|
26
|
+
taxAdvancesRate: Float
|
|
27
|
+
taxAdvancesId: String
|
|
28
|
+
registrationDate: TimelessDate!
|
|
45
29
|
}
|
|
46
30
|
|
|
47
31
|
" Input type for creating a new admin business. "
|
|
48
32
|
input CreateAdminBusinessInput {
|
|
49
33
|
businessId: UUID!
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
taxAdvancesAnnualId: String
|
|
53
|
-
taxAdvancesRate: Float
|
|
54
|
-
withholdingTaxAnnualId: String
|
|
34
|
+
withholdingTaxBookNumber: String
|
|
35
|
+
withholdingTaxFileNumber: String
|
|
55
36
|
socialSecurityEmployerId: String
|
|
37
|
+
taxAdvancesRate: Float
|
|
38
|
+
taxAdvancesId: String
|
|
39
|
+
registrationDate: TimelessDate!
|
|
56
40
|
}
|
|
57
41
|
|
|
58
42
|
" Input type for updating admin business details. "
|
|
59
43
|
input UpdateAdminBusinessInput {
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
withholdingTaxBookNumber: String
|
|
45
|
+
withholdingTaxFileNumber: String
|
|
46
|
+
socialSecurityEmployerId: String
|
|
47
|
+
taxAdvancesRate: Float
|
|
48
|
+
taxAdvancesId: String
|
|
62
49
|
registrationDate: TimelessDate
|
|
63
|
-
" Tax Advances Info "
|
|
64
|
-
taxAdvancesAnnualIds: [AnnualIdInput!]
|
|
65
|
-
taxAdvancesRates: [TaxAdvancesRateInput!]
|
|
66
|
-
" Withholding Tax Info "
|
|
67
|
-
withholdingTaxCompanyId: String
|
|
68
|
-
withholdingTaxAnnualIds: [AnnualIdInput!]
|
|
69
|
-
" Social Security Info "
|
|
70
|
-
socialSecurityEmployerIds: [AnnualIdInput!]
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
" Input type representing an annual identifier for tax purposes. "
|
|
74
|
-
input AnnualIdInput {
|
|
75
|
-
year: Int!
|
|
76
|
-
id: String!
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
" Input type representing the tax advance rate for a specific date. "
|
|
80
|
-
input TaxAdvancesRateInput {
|
|
81
|
-
date: TimelessDate!
|
|
82
|
-
rate: Float!
|
|
83
50
|
}
|
|
84
51
|
|
|
85
52
|
extend type LtdFinancialEntity {
|
|
@@ -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 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';
|
|
@@ -97,6 +97,7 @@ export namespace GreenInvoiceModule {
|
|
|
97
97
|
newDocumentInfoDraftByCharge?: gm.Middleware[];
|
|
98
98
|
newDocumentInfoDraftByDocument?: gm.Middleware[];
|
|
99
99
|
clientMonthlyChargesDrafts?: gm.Middleware[];
|
|
100
|
+
clientChargesDraftsByContracts?: gm.Middleware[];
|
|
100
101
|
clientMonthlyChargeDraft?: gm.Middleware[];
|
|
101
102
|
greenInvoiceClient?: gm.Middleware[];
|
|
102
103
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { addMonths, endOfMonth, format, startOfMonth, subMonths } from 'date-fns';
|
|
2
|
+
import { GraphQLError } from 'graphql';
|
|
3
|
+
import { Injector } from 'graphql-modules';
|
|
4
|
+
import type { IGetContractsByIdsResult } from '@modules/contracts/types.js';
|
|
5
|
+
import { normalizeDocumentType } from '@modules/documents/resolvers/common.js';
|
|
6
|
+
import { BusinessesProvider } from '@modules/financial-entities/providers/businesses.provider.js';
|
|
7
|
+
import { ClientsProvider } from '@modules/financial-entities/providers/clients.provider.js';
|
|
8
|
+
import { Currency } from '@shared/enums';
|
|
9
|
+
import { NewDocumentInfo } from '@shared/gql-types';
|
|
10
|
+
import { dateToTimelessDateString } from '@shared/helpers';
|
|
11
|
+
import { TimelessDateString } from '@shared/types';
|
|
12
|
+
import { getClientFromGreenInvoiceClient } from './issue-document.helper.js';
|
|
13
|
+
|
|
14
|
+
export const convertContractToDraft = async (
|
|
15
|
+
contract: IGetContractsByIdsResult,
|
|
16
|
+
injector: Injector,
|
|
17
|
+
issueMonth: TimelessDateString,
|
|
18
|
+
) => {
|
|
19
|
+
const businessPromise = injector
|
|
20
|
+
.get(BusinessesProvider)
|
|
21
|
+
.getBusinessByIdLoader.load(contract.client_id);
|
|
22
|
+
const clientPromise = injector.get(ClientsProvider).getClientByIdLoader.load(contract.client_id);
|
|
23
|
+
const greenInvoiceClientPromise = getClientFromGreenInvoiceClient(injector, contract.client_id);
|
|
24
|
+
const [business, client, greenInvoiceClient] = await Promise.all([
|
|
25
|
+
businessPromise,
|
|
26
|
+
clientPromise,
|
|
27
|
+
greenInvoiceClientPromise,
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
if (!business) {
|
|
31
|
+
throw new GraphQLError(`Business ID="${contract.client_id}" not found`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!client) {
|
|
35
|
+
throw new GraphQLError(`Client not found for business ID="${contract.client_id}"`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!greenInvoiceClient) {
|
|
39
|
+
throw new GraphQLError(`Green invoice match not found for business ID="${contract.client_id}"`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const today = issueMonth ? addMonths(new Date(issueMonth), 1) : new Date();
|
|
43
|
+
const monthStart = dateToTimelessDateString(startOfMonth(today));
|
|
44
|
+
const monthEnd = dateToTimelessDateString(endOfMonth(today));
|
|
45
|
+
const year = today.getFullYear() + (today.getMonth() === 0 ? -1 : 0);
|
|
46
|
+
const month = format(subMonths(today, 1), 'MMMM');
|
|
47
|
+
|
|
48
|
+
const documentInput: NewDocumentInfo = {
|
|
49
|
+
remarks: `${contract.purchase_orders[0] ? `PO: ${contract.purchase_orders[0]}${contract.remarks ? ', ' : ''}` : ''}${contract.remarks ?? ''}`,
|
|
50
|
+
description: `GraphQL Hive Enterprise License - ${month} ${year}`,
|
|
51
|
+
type: normalizeDocumentType(contract.document_type),
|
|
52
|
+
date: monthStart,
|
|
53
|
+
dueDate: monthEnd,
|
|
54
|
+
lang: 'ENGLISH',
|
|
55
|
+
currency: contract.currency as Currency,
|
|
56
|
+
vatType: 'EXEMPT',
|
|
57
|
+
rounding: false,
|
|
58
|
+
signed: true,
|
|
59
|
+
client: {
|
|
60
|
+
...greenInvoiceClient,
|
|
61
|
+
emails: [...((client.emails?.filter(Boolean) as string[]) ?? [])],
|
|
62
|
+
},
|
|
63
|
+
income: [
|
|
64
|
+
{
|
|
65
|
+
description: `GraphQL Hive Enterprise License - ${month} ${year}`,
|
|
66
|
+
quantity: 1,
|
|
67
|
+
price: contract.amount,
|
|
68
|
+
currency: contract.currency as Currency,
|
|
69
|
+
vatType: 'EXEMPT',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return documentInput;
|
|
75
|
+
};
|