@floristcloud/api-lib 1.2.52 → 1.2.53
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/build/commands/index.js +1 -0
- package/build/commands/payment-invoice/create-payment-invoice.command.js +19 -0
- package/build/commands/payment-invoice/delete-payment-invoice.command.js +16 -0
- package/build/commands/payment-invoice/get-payment-invoice-list.query.js +23 -0
- package/build/commands/payment-invoice/get-payment-invoice.query.js +15 -0
- package/build/commands/payment-invoice/index.js +20 -0
- package/build/constant/error.js +7 -0
- package/build/enum/client-statement-type.enum.js +1 -0
- package/build/helpers/date.helper.js +8 -1
- package/build/schemas/index.js +1 -0
- package/build/schemas/payment-invoice/payment-invoice.schema.js +13 -0
- package/build/schemas/settings/settings.schema.js +9 -0
- package/commands/index.ts +1 -0
- package/commands/payment-invoice/create-payment-invoice.command.ts +21 -0
- package/commands/payment-invoice/delete-payment-invoice.command.ts +18 -0
- package/commands/payment-invoice/get-payment-invoice-list.query.ts +25 -0
- package/commands/payment-invoice/get-payment-invoice.query.ts +17 -0
- package/commands/payment-invoice/index.ts +4 -0
- package/constant/error.ts +8 -0
- package/enum/client-statement-type.enum.ts +1 -0
- package/helpers/date.helper.ts +8 -0
- package/package.json +1 -1
- package/schemas/index.ts +1 -0
- package/schemas/payment-invoice/payment-invoice.schema.ts +11 -0
- package/schemas/settings/settings.schema.ts +9 -0
package/build/commands/index.js
CHANGED
|
@@ -49,6 +49,7 @@ __exportStar(require("./user"), exports);
|
|
|
49
49
|
__exportStar(require("./work-session"), exports);
|
|
50
50
|
__exportStar(require("./write-off"), exports);
|
|
51
51
|
__exportStar(require("./report"), exports);
|
|
52
|
+
__exportStar(require("./payment-invoice"), exports);
|
|
52
53
|
__exportStar(require("./action-log"), exports);
|
|
53
54
|
__exportStar(require("./client/import-client.command"), exports);
|
|
54
55
|
__exportStar(require("./delivery-route"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreatePaymentInvoiceContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const payment_invoice_schema_1 = require("../../schemas/payment-invoice/payment-invoice.schema");
|
|
6
|
+
const CreatePaymentInvoiceRequestSchema = zod_1.z.object({
|
|
7
|
+
clientUUID: zod_1.z.uuid(),
|
|
8
|
+
invoiceDate: zod_1.z.coerce.date(),
|
|
9
|
+
amount: zod_1.z.coerce.number().positive(),
|
|
10
|
+
});
|
|
11
|
+
const CreatePaymentInvoiceResponseSchema = zod_1.z.object({
|
|
12
|
+
message: zod_1.z.string().optional(),
|
|
13
|
+
data: payment_invoice_schema_1.PaymentInvoiceSchema,
|
|
14
|
+
});
|
|
15
|
+
var CreatePaymentInvoiceContractCommand;
|
|
16
|
+
(function (CreatePaymentInvoiceContractCommand) {
|
|
17
|
+
CreatePaymentInvoiceContractCommand.RequestSchema = CreatePaymentInvoiceRequestSchema;
|
|
18
|
+
CreatePaymentInvoiceContractCommand.ResponseSchema = CreatePaymentInvoiceResponseSchema;
|
|
19
|
+
})(CreatePaymentInvoiceContractCommand || (exports.CreatePaymentInvoiceContractCommand = CreatePaymentInvoiceContractCommand = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeletePaymentInvoiceContractCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const DeletePaymentInvoiceRequestSchema = zod_1.z.object({});
|
|
6
|
+
const DeletePaymentInvoiceResponseSchema = zod_1.z.object({
|
|
7
|
+
message: zod_1.z.string().optional(),
|
|
8
|
+
data: zod_1.z.object({
|
|
9
|
+
success: zod_1.z.boolean(),
|
|
10
|
+
}),
|
|
11
|
+
});
|
|
12
|
+
var DeletePaymentInvoiceContractCommand;
|
|
13
|
+
(function (DeletePaymentInvoiceContractCommand) {
|
|
14
|
+
DeletePaymentInvoiceContractCommand.RequestSchema = DeletePaymentInvoiceRequestSchema;
|
|
15
|
+
DeletePaymentInvoiceContractCommand.ResponseSchema = DeletePaymentInvoiceResponseSchema;
|
|
16
|
+
})(DeletePaymentInvoiceContractCommand || (exports.DeletePaymentInvoiceContractCommand = DeletePaymentInvoiceContractCommand = {}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetPaymentInvoiceListContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const payment_invoice_schema_1 = require("../../schemas/payment-invoice/payment-invoice.schema");
|
|
6
|
+
const GetPaymentInvoiceListRequestSchema = zod_1.z.object({
|
|
7
|
+
page: zod_1.z.string().transform(value => Number(value) || 1),
|
|
8
|
+
count: zod_1.z.string().transform(value => Number(value) || 10),
|
|
9
|
+
searchQuery: zod_1.z.string().optional(),
|
|
10
|
+
clientUUID: zod_1.z.uuid().optional(),
|
|
11
|
+
});
|
|
12
|
+
const GetPaymentInvoiceListResponseSchema = zod_1.z.object({
|
|
13
|
+
message: zod_1.z.string().optional(),
|
|
14
|
+
data: zod_1.z.object({
|
|
15
|
+
list: payment_invoice_schema_1.PaymentInvoiceSchema.array(),
|
|
16
|
+
total: zod_1.z.number(),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
var GetPaymentInvoiceListContractQuery;
|
|
20
|
+
(function (GetPaymentInvoiceListContractQuery) {
|
|
21
|
+
GetPaymentInvoiceListContractQuery.RequestSchema = GetPaymentInvoiceListRequestSchema;
|
|
22
|
+
GetPaymentInvoiceListContractQuery.ResponseSchema = GetPaymentInvoiceListResponseSchema;
|
|
23
|
+
})(GetPaymentInvoiceListContractQuery || (exports.GetPaymentInvoiceListContractQuery = GetPaymentInvoiceListContractQuery = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetPaymentInvoiceContractQuery = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const payment_invoice_schema_1 = require("../../schemas/payment-invoice/payment-invoice.schema");
|
|
6
|
+
const GetPaymentInvoiceRequestSchema = zod_1.z.object({});
|
|
7
|
+
const GetPaymentInvoiceResponseSchema = zod_1.z.object({
|
|
8
|
+
message: zod_1.z.string().optional(),
|
|
9
|
+
data: payment_invoice_schema_1.PaymentInvoiceSchema,
|
|
10
|
+
});
|
|
11
|
+
var GetPaymentInvoiceContractQuery;
|
|
12
|
+
(function (GetPaymentInvoiceContractQuery) {
|
|
13
|
+
GetPaymentInvoiceContractQuery.RequestSchema = GetPaymentInvoiceRequestSchema;
|
|
14
|
+
GetPaymentInvoiceContractQuery.ResponseSchema = GetPaymentInvoiceResponseSchema;
|
|
15
|
+
})(GetPaymentInvoiceContractQuery || (exports.GetPaymentInvoiceContractQuery = GetPaymentInvoiceContractQuery = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./create-payment-invoice.command"), exports);
|
|
18
|
+
__exportStar(require("./get-payment-invoice-list.query"), exports);
|
|
19
|
+
__exportStar(require("./get-payment-invoice.query"), exports);
|
|
20
|
+
__exportStar(require("./delete-payment-invoice.command"), exports);
|
package/build/constant/error.js
CHANGED
|
@@ -891,6 +891,13 @@ exports.ERRORS = {
|
|
|
891
891
|
REPORT_FETCH_FAILED: { code: 'REP001', message: 'Failed to fetch report', httpCode: 500 },
|
|
892
892
|
REPORT_EXPORT_FAILED: { code: 'REP002', message: 'Failed to export report', httpCode: 500 },
|
|
893
893
|
REPORT_NO_DATA: { code: 'REP003', message: 'No data available for the selected period', httpCode: 404 },
|
|
894
|
+
STATEMENT_PERIOD_TOO_LONG: { code: 'REP004', message: 'Statement period must not exceed 1 year', httpCode: 400 },
|
|
895
|
+
// PAYMENT INVOICE
|
|
896
|
+
PAYMENT_INVOICE_CREATE_FAILED: { code: 'PINV001', message: 'Failed to create payment invoice', httpCode: 500 },
|
|
897
|
+
PAYMENT_INVOICE_EXPORT_FAILED: { code: 'PINV002', message: 'Failed to generate payment invoice document', httpCode: 500 },
|
|
898
|
+
PAYMENT_INVOICE_NOT_FOUND: { code: 'PINV003', message: 'Payment invoice not found', httpCode: 404 },
|
|
899
|
+
PAYMENT_INVOICE_FETCH_FAILED: { code: 'PINV004', message: 'Failed to fetch payment invoices', httpCode: 500 },
|
|
900
|
+
PAYMENT_INVOICE_DELETE_FAILED: { code: 'PINV005', message: 'Failed to delete payment invoice', httpCode: 500 },
|
|
894
901
|
// AUTH GATEWAY
|
|
895
902
|
AUTH_GATEWAY_VOICE_FAILED: { code: 'AG001', message: 'Failed to send code via voice call', httpCode: 500 },
|
|
896
903
|
AUTH_GATEWAY_TELEGRAM_FAILED: { code: 'AG002', message: 'Failed to send code via Telegram', httpCode: 500 },
|
|
@@ -6,4 +6,5 @@ var ClientStatementTypeEnum;
|
|
|
6
6
|
ClientStatementTypeEnum["ORDER"] = "ORDER";
|
|
7
7
|
ClientStatementTypeEnum["TRANSACTION"] = "TRANSACTION";
|
|
8
8
|
ClientStatementTypeEnum["WRITE_OFF"] = "WRITE_OFF";
|
|
9
|
+
ClientStatementTypeEnum["OPENING_BALANCE"] = "OPENING_BALANCE";
|
|
9
10
|
})(ClientStatementTypeEnum || (exports.ClientStatementTypeEnum = ClientStatementTypeEnum = {}));
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setEndDay = exports.setStartDay = exports.dateRangeCheck = void 0;
|
|
3
|
+
exports.setEndDay = exports.setStartDay = exports.isStatementPeriodWithinLimit = exports.STATEMENT_MAX_PERIOD_DAYS = exports.dateRangeCheck = void 0;
|
|
4
4
|
const dateRangeCheck = (startDate, endDate) => {
|
|
5
5
|
return endDate > startDate;
|
|
6
6
|
};
|
|
7
7
|
exports.dateRangeCheck = dateRangeCheck;
|
|
8
|
+
// 1 year + 1 day to tolerate leap years.
|
|
9
|
+
exports.STATEMENT_MAX_PERIOD_DAYS = 366;
|
|
10
|
+
const isStatementPeriodWithinLimit = (startDate, endDate) => {
|
|
11
|
+
const diffDays = Math.ceil(Math.abs(endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));
|
|
12
|
+
return diffDays <= exports.STATEMENT_MAX_PERIOD_DAYS;
|
|
13
|
+
};
|
|
14
|
+
exports.isStatementPeriodWithinLimit = isStatementPeriodWithinLimit;
|
|
8
15
|
const setStartDay = (date) => {
|
|
9
16
|
return new Date(date.setUTCHours(0, 0, 0, 0));
|
|
10
17
|
};
|
package/build/schemas/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __exportStar(require("./transaction/transaction-list.schema"), exports);
|
|
|
33
33
|
__exportStar(require("./file"), exports);
|
|
34
34
|
__exportStar(require("./product-image/product-image.schema"), exports);
|
|
35
35
|
__exportStar(require("./settings/settings.schema"), exports);
|
|
36
|
+
__exportStar(require("./payment-invoice/payment-invoice.schema"), exports);
|
|
36
37
|
__exportStar(require("./money-account/money-account.schema"), exports);
|
|
37
38
|
__exportStar(require("./domain/domain.schema"), exports);
|
|
38
39
|
__exportStar(require("./category/category.schema"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaymentInvoiceSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.PaymentInvoiceSchema = zod_1.z.object({
|
|
6
|
+
uuid: zod_1.z.string(),
|
|
7
|
+
number: zod_1.z.string(),
|
|
8
|
+
invoiceDate: zod_1.z.coerce.date(),
|
|
9
|
+
amount: zod_1.z.coerce.number(),
|
|
10
|
+
clientUUID: zod_1.z.string(),
|
|
11
|
+
fileUrl: zod_1.z.string().nullable(),
|
|
12
|
+
createdAt: zod_1.z.coerce.date(),
|
|
13
|
+
});
|
|
@@ -45,6 +45,9 @@ exports.SettingsSchema = zod_1.z.object({
|
|
|
45
45
|
legalAddress: zod_1.z.string().nullable(),
|
|
46
46
|
bankName: zod_1.z.string().nullable(),
|
|
47
47
|
bankAccountNumber: zod_1.z.string().nullable(),
|
|
48
|
+
bankBic: zod_1.z.string().nullable(),
|
|
49
|
+
correspondentAccount: zod_1.z.string().nullable(),
|
|
50
|
+
invoiceNumberPrefix: zod_1.z.string(),
|
|
48
51
|
isShowPriceAnonymous: zod_1.z.boolean(),
|
|
49
52
|
orderExpirationWarningMin: zod_1.z.number().nullable(),
|
|
50
53
|
orderExpirationMin: zod_1.z.number().nullable(),
|
|
@@ -118,6 +121,9 @@ exports.CreateSettingsSchema = zod_1.z.object({
|
|
|
118
121
|
legalAddress: zod_1.z.string().optional(),
|
|
119
122
|
bankName: zod_1.z.string().optional(),
|
|
120
123
|
bankAccountNumber: zod_1.z.string().optional(),
|
|
124
|
+
bankBic: zod_1.z.string().nullable().optional(),
|
|
125
|
+
correspondentAccount: zod_1.z.string().nullable().optional(),
|
|
126
|
+
invoiceNumberPrefix: zod_1.z.string().optional(),
|
|
121
127
|
orderExpirationWarningMin: zod_1.z.coerce.number().nullable().optional(),
|
|
122
128
|
orderExpirationMin: zod_1.z.coerce.number().nullable().optional(),
|
|
123
129
|
paymentGraceDaysAfterCompletion: zod_1.z.coerce.number().nullable().optional(),
|
|
@@ -180,6 +186,9 @@ exports.UpdateSettingsRequestSchema = zod_1.z.object({
|
|
|
180
186
|
legalAddress: zod_1.z.string().optional().nullable(),
|
|
181
187
|
bankName: zod_1.z.string().optional().nullable(),
|
|
182
188
|
bankAccountNumber: zod_1.z.string().optional().nullable(),
|
|
189
|
+
bankBic: zod_1.z.string().optional().nullable(),
|
|
190
|
+
correspondentAccount: zod_1.z.string().optional().nullable(),
|
|
191
|
+
invoiceNumberPrefix: zod_1.z.string().optional(),
|
|
183
192
|
isShowPriceAnonymous: zod_1.z.coerce.boolean().optional(),
|
|
184
193
|
orderExpirationWarningMin: zod_1.z.coerce.number().nullable().optional(),
|
|
185
194
|
orderExpirationMin: zod_1.z.coerce.number().nullable().optional(),
|
package/commands/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ export * from './user';
|
|
|
32
32
|
export * from './work-session';
|
|
33
33
|
export * from './write-off';
|
|
34
34
|
export * from './report';
|
|
35
|
+
export * from './payment-invoice';
|
|
35
36
|
export * from './action-log';
|
|
36
37
|
export * from './client/import-client.command';
|
|
37
38
|
export * from './delivery-route';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PaymentInvoiceSchema } from '../../schemas/payment-invoice/payment-invoice.schema';
|
|
3
|
+
|
|
4
|
+
const CreatePaymentInvoiceRequestSchema = z.object({
|
|
5
|
+
clientUUID: z.uuid(),
|
|
6
|
+
invoiceDate: z.coerce.date(),
|
|
7
|
+
amount: z.coerce.number().positive(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const CreatePaymentInvoiceResponseSchema = z.object({
|
|
11
|
+
message: z.string().optional(),
|
|
12
|
+
data: PaymentInvoiceSchema,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export namespace CreatePaymentInvoiceContractCommand {
|
|
16
|
+
export const RequestSchema = CreatePaymentInvoiceRequestSchema;
|
|
17
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
18
|
+
|
|
19
|
+
export const ResponseSchema = CreatePaymentInvoiceResponseSchema;
|
|
20
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const DeletePaymentInvoiceRequestSchema = z.object({});
|
|
4
|
+
|
|
5
|
+
const DeletePaymentInvoiceResponseSchema = z.object({
|
|
6
|
+
message: z.string().optional(),
|
|
7
|
+
data: z.object({
|
|
8
|
+
success: z.boolean(),
|
|
9
|
+
}),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export namespace DeletePaymentInvoiceContractCommand {
|
|
13
|
+
export const RequestSchema = DeletePaymentInvoiceRequestSchema;
|
|
14
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
15
|
+
|
|
16
|
+
export const ResponseSchema = DeletePaymentInvoiceResponseSchema;
|
|
17
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PaymentInvoiceSchema } from '../../schemas/payment-invoice/payment-invoice.schema';
|
|
3
|
+
|
|
4
|
+
const GetPaymentInvoiceListRequestSchema = z.object({
|
|
5
|
+
page: z.string().transform(value => Number(value) || 1),
|
|
6
|
+
count: z.string().transform(value => Number(value) || 10),
|
|
7
|
+
searchQuery: z.string().optional(),
|
|
8
|
+
clientUUID: z.uuid().optional(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const GetPaymentInvoiceListResponseSchema = z.object({
|
|
12
|
+
message: z.string().optional(),
|
|
13
|
+
data: z.object({
|
|
14
|
+
list: PaymentInvoiceSchema.array(),
|
|
15
|
+
total: z.number(),
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export namespace GetPaymentInvoiceListContractQuery {
|
|
20
|
+
export const RequestSchema = GetPaymentInvoiceListRequestSchema;
|
|
21
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
22
|
+
|
|
23
|
+
export const ResponseSchema = GetPaymentInvoiceListResponseSchema;
|
|
24
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PaymentInvoiceSchema } from '../../schemas/payment-invoice/payment-invoice.schema';
|
|
3
|
+
|
|
4
|
+
const GetPaymentInvoiceRequestSchema = z.object({});
|
|
5
|
+
|
|
6
|
+
const GetPaymentInvoiceResponseSchema = z.object({
|
|
7
|
+
message: z.string().optional(),
|
|
8
|
+
data: PaymentInvoiceSchema,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export namespace GetPaymentInvoiceContractQuery {
|
|
12
|
+
export const RequestSchema = GetPaymentInvoiceRequestSchema;
|
|
13
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
14
|
+
|
|
15
|
+
export const ResponseSchema = GetPaymentInvoiceResponseSchema;
|
|
16
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
17
|
+
}
|
package/constant/error.ts
CHANGED
|
@@ -934,6 +934,14 @@ export const ERRORS = {
|
|
|
934
934
|
REPORT_FETCH_FAILED: { code: 'REP001', message: 'Failed to fetch report', httpCode: 500 },
|
|
935
935
|
REPORT_EXPORT_FAILED: { code: 'REP002', message: 'Failed to export report', httpCode: 500 },
|
|
936
936
|
REPORT_NO_DATA: { code: 'REP003', message: 'No data available for the selected period', httpCode: 404 },
|
|
937
|
+
STATEMENT_PERIOD_TOO_LONG: { code: 'REP004', message: 'Statement period must not exceed 1 year', httpCode: 400 },
|
|
938
|
+
|
|
939
|
+
// PAYMENT INVOICE
|
|
940
|
+
PAYMENT_INVOICE_CREATE_FAILED: { code: 'PINV001', message: 'Failed to create payment invoice', httpCode: 500 },
|
|
941
|
+
PAYMENT_INVOICE_EXPORT_FAILED: { code: 'PINV002', message: 'Failed to generate payment invoice document', httpCode: 500 },
|
|
942
|
+
PAYMENT_INVOICE_NOT_FOUND: { code: 'PINV003', message: 'Payment invoice not found', httpCode: 404 },
|
|
943
|
+
PAYMENT_INVOICE_FETCH_FAILED: { code: 'PINV004', message: 'Failed to fetch payment invoices', httpCode: 500 },
|
|
944
|
+
PAYMENT_INVOICE_DELETE_FAILED: { code: 'PINV005', message: 'Failed to delete payment invoice', httpCode: 500 },
|
|
937
945
|
|
|
938
946
|
// AUTH GATEWAY
|
|
939
947
|
AUTH_GATEWAY_VOICE_FAILED: { code: 'AG001', message: 'Failed to send code via voice call', httpCode: 500 },
|
package/helpers/date.helper.ts
CHANGED
|
@@ -2,6 +2,14 @@ export const dateRangeCheck = (startDate: Date, endDate: Date) => {
|
|
|
2
2
|
return endDate > startDate;
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
+
// 1 year + 1 day to tolerate leap years.
|
|
6
|
+
export const STATEMENT_MAX_PERIOD_DAYS = 366;
|
|
7
|
+
|
|
8
|
+
export const isStatementPeriodWithinLimit = (startDate: Date, endDate: Date): boolean => {
|
|
9
|
+
const diffDays = Math.ceil(Math.abs(endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24));
|
|
10
|
+
return diffDays <= STATEMENT_MAX_PERIOD_DAYS;
|
|
11
|
+
};
|
|
12
|
+
|
|
5
13
|
export const setStartDay = (date: Date) => {
|
|
6
14
|
return new Date(date.setUTCHours(0, 0, 0, 0));
|
|
7
15
|
};
|
package/package.json
CHANGED
package/schemas/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from './transaction/transaction-list.schema';
|
|
|
17
17
|
export * from './file';
|
|
18
18
|
export * from './product-image/product-image.schema';
|
|
19
19
|
export * from './settings/settings.schema';
|
|
20
|
+
export * from './payment-invoice/payment-invoice.schema';
|
|
20
21
|
export * from './money-account/money-account.schema';
|
|
21
22
|
export * from './domain/domain.schema';
|
|
22
23
|
export * from './category/category.schema';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const PaymentInvoiceSchema = z.object({
|
|
4
|
+
uuid: z.string(),
|
|
5
|
+
number: z.string(),
|
|
6
|
+
invoiceDate: z.coerce.date(),
|
|
7
|
+
amount: z.coerce.number(),
|
|
8
|
+
clientUUID: z.string(),
|
|
9
|
+
fileUrl: z.string().nullable(),
|
|
10
|
+
createdAt: z.coerce.date(),
|
|
11
|
+
});
|
|
@@ -45,6 +45,9 @@ export const SettingsSchema = z.object({
|
|
|
45
45
|
legalAddress: z.string().nullable(),
|
|
46
46
|
bankName: z.string().nullable(),
|
|
47
47
|
bankAccountNumber: z.string().nullable(),
|
|
48
|
+
bankBic: z.string().nullable(),
|
|
49
|
+
correspondentAccount: z.string().nullable(),
|
|
50
|
+
invoiceNumberPrefix: z.string(),
|
|
48
51
|
isShowPriceAnonymous: z.boolean(),
|
|
49
52
|
orderExpirationWarningMin: z.number().nullable(),
|
|
50
53
|
orderExpirationMin: z.number().nullable(),
|
|
@@ -120,6 +123,9 @@ export const CreateSettingsSchema = z.object({
|
|
|
120
123
|
legalAddress: z.string().optional(),
|
|
121
124
|
bankName: z.string().optional(),
|
|
122
125
|
bankAccountNumber: z.string().optional(),
|
|
126
|
+
bankBic: z.string().nullable().optional(),
|
|
127
|
+
correspondentAccount: z.string().nullable().optional(),
|
|
128
|
+
invoiceNumberPrefix: z.string().optional(),
|
|
123
129
|
orderExpirationWarningMin: z.coerce.number().nullable().optional(),
|
|
124
130
|
orderExpirationMin: z.coerce.number().nullable().optional(),
|
|
125
131
|
paymentGraceDaysAfterCompletion: z.coerce.number().nullable().optional(),
|
|
@@ -185,6 +191,9 @@ export const UpdateSettingsRequestSchema = z.object({
|
|
|
185
191
|
legalAddress: z.string().optional().nullable(),
|
|
186
192
|
bankName: z.string().optional().nullable(),
|
|
187
193
|
bankAccountNumber: z.string().optional().nullable(),
|
|
194
|
+
bankBic: z.string().optional().nullable(),
|
|
195
|
+
correspondentAccount: z.string().optional().nullable(),
|
|
196
|
+
invoiceNumberPrefix: z.string().optional(),
|
|
188
197
|
isShowPriceAnonymous: z.coerce.boolean().optional(),
|
|
189
198
|
orderExpirationWarningMin: z.coerce.number().nullable().optional(),
|
|
190
199
|
orderExpirationMin: z.coerce.number().nullable().optional(),
|