@accounter/server 0.0.8-alpha-20251029235231-f14290dbb5dedec255de3cef292d3b4c5c71298e → 0.0.8-alpha-20251030162201-d2f279aafe537912ec3546af855cbd3a38ac0f5c
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 +20 -5
- package/dist/green-invoice-graphql/src/mesh-artifacts/index.d.ts +1 -1
- package/dist/server/src/__generated__/types.d.ts +70 -18
- package/dist/server/src/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/financial-entities/__generated__/admin-businesses.types.d.ts +57 -0
- package/dist/server/src/modules/financial-entities/__generated__/admin-businesses.types.js +0 -1
- 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 +33 -10
- package/dist/server/src/modules/financial-entities/__generated__/types.js.map +1 -1
- package/dist/server/src/modules/financial-entities/helpers/admin-businesses.helper.d.ts +31 -0
- package/dist/server/src/modules/financial-entities/helpers/admin-businesses.helper.js +27 -0
- package/dist/server/src/modules/financial-entities/helpers/admin-businesses.helper.js.map +1 -0
- package/dist/server/src/modules/financial-entities/providers/admin-businesses.provider.d.ts +2 -1
- package/dist/server/src/modules/financial-entities/providers/admin-businesses.provider.js +37 -0
- 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 +46 -11
- 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 +49 -16
- 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/package.json +3 -3
- package/src/__generated__/types.ts +76 -18
- package/src/modules/financial-entities/__generated__/admin-businesses.types.ts +60 -0
- package/src/modules/financial-entities/__generated__/types.ts +33 -10
- package/src/modules/financial-entities/helpers/admin-businesses.helper.ts +33 -0
- package/src/modules/financial-entities/providers/admin-businesses.provider.ts +44 -0
- package/src/modules/financial-entities/resolvers/admin-businesses.resolver.ts +53 -11
- package/src/modules/financial-entities/typeDefs/admin-businesses.graphql.ts +49 -16
- package/src/modules/financial-entities/types.ts +1 -1
|
@@ -3,10 +3,14 @@ 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';
|
|
6
7
|
import type {
|
|
7
8
|
IGetAdminBusinessesByIdsQuery,
|
|
8
9
|
IGetAllAdminBusinessesQuery,
|
|
9
10
|
IGetAllAdminBusinessesResult,
|
|
11
|
+
IUpdateAdminBusinessesParams,
|
|
12
|
+
IUpdateAdminBusinessesQuery,
|
|
13
|
+
IUpdateAdminBusinessesResult,
|
|
10
14
|
} from '../types.js';
|
|
11
15
|
|
|
12
16
|
const getAdminBusinessesByIds = sql<IGetAdminBusinessesByIdsQuery>`
|
|
@@ -28,6 +32,37 @@ const getAllAdminBusinesses = sql<IGetAllAdminBusinessesQuery>`
|
|
|
28
32
|
INNER JOIN accounter_schema.financial_entities fe
|
|
29
33
|
USING (id);`;
|
|
30
34
|
|
|
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
|
+
|
|
31
66
|
@Injectable({
|
|
32
67
|
scope: Scope.Operation,
|
|
33
68
|
global: true,
|
|
@@ -69,6 +104,15 @@ export class AdminBusinessesProvider {
|
|
|
69
104
|
});
|
|
70
105
|
}
|
|
71
106
|
|
|
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
|
+
|
|
72
116
|
public clearCache() {
|
|
73
117
|
this.cache.clear();
|
|
74
118
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
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';
|
|
3
5
|
import { AdminBusinessesProvider } from '../providers/admin-businesses.provider.js';
|
|
4
6
|
import { BusinessesProvider } from '../providers/businesses.provider.js';
|
|
5
7
|
import type { FinancialEntitiesModule } from '../types.js';
|
|
@@ -22,6 +24,41 @@ export const adminBusinessesResolvers: FinancialEntitiesModule.Resolvers = {
|
|
|
22
24
|
return adminBusinesses;
|
|
23
25
|
},
|
|
24
26
|
},
|
|
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
|
+
},
|
|
25
62
|
AdminBusiness: {
|
|
26
63
|
id: admin => admin.id,
|
|
27
64
|
name: admin => admin.name,
|
|
@@ -31,6 +68,12 @@ export const adminBusinessesResolvers: FinancialEntitiesModule.Resolvers = {
|
|
|
31
68
|
}
|
|
32
69
|
return admin.vat_number;
|
|
33
70
|
},
|
|
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
|
+
},
|
|
34
77
|
business: async (admin, _, { injector }) => {
|
|
35
78
|
const business = await injector.get(BusinessesProvider).getBusinessByIdLoader.load(admin.id);
|
|
36
79
|
if (!business) {
|
|
@@ -38,17 +81,16 @@ export const adminBusinessesResolvers: FinancialEntitiesModule.Resolvers = {
|
|
|
38
81
|
}
|
|
39
82
|
return business;
|
|
40
83
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
84
|
+
taxAdvancesAnnualIds: admin => yearlyIdsSchema.parse(admin.tax_advances_ids),
|
|
85
|
+
taxAdvancesRates: admin =>
|
|
86
|
+
taxAdvancesRatesSchema.parse(admin.advance_tax_rates) as Array<{
|
|
87
|
+
date: TimelessDateString;
|
|
88
|
+
rate: number;
|
|
89
|
+
}>,
|
|
90
|
+
withholdingTaxCompanyId: admin => admin.company_tax_id,
|
|
91
|
+
withholdingTaxAnnualIds: admin => yearlyIdsSchema.parse(admin.withholding_tax_annual_ids),
|
|
92
|
+
socialSecurityDeductionsId: admin => `${admin.company_tax_id}00`,
|
|
93
|
+
socialSecurityEmployerIds: admin => yearlyIdsSchema.parse(admin.social_security_employer_ids),
|
|
52
94
|
},
|
|
53
95
|
LtdFinancialEntity: {
|
|
54
96
|
adminInfo: async (parentBusiness, _, { injector }) => {
|
|
@@ -19,34 +19,67 @@ export default gql`
|
|
|
19
19
|
id: UUID!
|
|
20
20
|
name: String!
|
|
21
21
|
governmentId: String!
|
|
22
|
-
business: LtdFinancialEntity!
|
|
23
|
-
withholdingTaxBookNumber: String
|
|
24
|
-
withholdingTaxFileNumber: String
|
|
25
|
-
socialSecurityEmployerId: String
|
|
26
|
-
taxAdvancesRate: Float
|
|
27
|
-
taxAdvancesId: String
|
|
28
22
|
registrationDate: TimelessDate!
|
|
23
|
+
business: LtdFinancialEntity!
|
|
24
|
+
" Tax Advances Info "
|
|
25
|
+
taxAdvancesAnnualIds: [AnnualId!]!
|
|
26
|
+
taxAdvancesRates: [TaxAdvancesRate!]!
|
|
27
|
+
" Withholding Tax Info "
|
|
28
|
+
withholdingTaxCompanyId: String
|
|
29
|
+
withholdingTaxAnnualIds: [AnnualId!]!
|
|
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!
|
|
29
45
|
}
|
|
30
46
|
|
|
31
47
|
" Input type for creating a new admin business. "
|
|
32
48
|
input CreateAdminBusinessInput {
|
|
33
49
|
businessId: UUID!
|
|
34
|
-
withholdingTaxBookNumber: String
|
|
35
|
-
withholdingTaxFileNumber: String
|
|
36
|
-
socialSecurityEmployerId: String
|
|
37
|
-
taxAdvancesRate: Float
|
|
38
|
-
taxAdvancesId: String
|
|
39
50
|
registrationDate: TimelessDate!
|
|
51
|
+
companyTaxId: String!
|
|
52
|
+
taxAdvancesAnnualId: String
|
|
53
|
+
taxAdvancesRate: Float
|
|
54
|
+
withholdingTaxAnnualId: String
|
|
55
|
+
socialSecurityEmployerId: String
|
|
40
56
|
}
|
|
41
57
|
|
|
42
58
|
" Input type for updating admin business details. "
|
|
43
59
|
input UpdateAdminBusinessInput {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
socialSecurityEmployerId: String
|
|
47
|
-
taxAdvancesRate: Float
|
|
48
|
-
taxAdvancesId: String
|
|
60
|
+
name: String
|
|
61
|
+
governmentId: String
|
|
49
62
|
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!
|
|
50
83
|
}
|
|
51
84
|
|
|
52
85
|
extend type LtdFinancialEntity {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './__generated__/types.js';
|
|
2
|
-
export type { Json, pcn874_record_type } from './__generated__/businesses.types.js';
|
|
2
|
+
export type { Json, pcn874_record_type, DateOrString } 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';
|