@react-pakistan/util-functions 1.24.65 → 1.24.67
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/README.md +6 -3
- package/api/stellar-solutions/app-user/index.d.ts +63 -14
- package/api/stellar-solutions/app-user/index.js +106 -52
- package/api/stellar-solutions/bank/index.d.ts +65 -16
- package/api/stellar-solutions/bank/index.js +115 -65
- package/api/stellar-solutions/branch/index.d.ts +64 -15
- package/api/stellar-solutions/branch/index.js +119 -65
- package/api/stellar-solutions/company/index.d.ts +58 -24
- package/api/stellar-solutions/company/index.js +106 -78
- package/api/stellar-solutions/company-report/index.d.ts +12 -5
- package/api/stellar-solutions/company-report/index.js +12 -7
- package/api/stellar-solutions/contact/index.d.ts +54 -20
- package/api/stellar-solutions/contact/index.js +109 -88
- package/api/stellar-solutions/currency/index.d.ts +63 -14
- package/api/stellar-solutions/currency/index.js +113 -61
- package/api/stellar-solutions/customer/index.d.ts +70 -28
- package/api/stellar-solutions/customer/index.js +131 -101
- package/api/stellar-solutions/expense/index.d.ts +58 -22
- package/api/stellar-solutions/expense/index.js +128 -92
- package/api/stellar-solutions/expense-category/index.d.ts +58 -22
- package/api/stellar-solutions/expense-category/index.js +125 -86
- package/api/stellar-solutions/lead/index.js +0 -1
- package/api/stellar-solutions/menu-order/index.d.ts +29 -7
- package/api/stellar-solutions/menu-order/index.js +74 -27
- package/api/stellar-solutions/payment/index.d.ts +62 -27
- package/api/stellar-solutions/payment/index.js +144 -123
- package/api/stellar-solutions/payment-mode/index.d.ts +44 -12
- package/api/stellar-solutions/payment-mode/index.js +115 -49
- package/api/stellar-solutions/preference/index.d.ts +14 -3
- package/api/stellar-solutions/preference/index.js +44 -14
- package/api/stellar-solutions/product/index.d.ts +48 -31
- package/api/stellar-solutions/product/index.js +153 -115
- package/api/stellar-solutions/product-category/index.d.ts +44 -27
- package/api/stellar-solutions/product-category/index.js +123 -87
- package/api/stellar-solutions/profile/index.d.ts +48 -17
- package/api/stellar-solutions/profile/index.js +124 -65
- package/api/stellar-solutions/quote-invoice/index.d.ts +67 -8
- package/api/stellar-solutions/quote-invoice/index.js +123 -57
- package/api/stellar-solutions/quote-invoice-report/index.d.ts +12 -5
- package/api/stellar-solutions/quote-invoice-report/index.js +10 -5
- package/api/stellar-solutions/tax/index.d.ts +46 -14
- package/api/stellar-solutions/tax/index.js +135 -63
- package/api/stellar-solutions/type.d.ts +178 -112
- package/api/stellar-solutions/type.js +60 -2
- package/constants/countries-timezones.js +0 -1
- package/constants/currencies.js +0 -1
- package/general/basic-get.js +22 -21
- package/general/basic-post.js +19 -18
- package/general/calculate-pages.js +3 -1
- package/general/check-even-odd-length.js +3 -2
- package/general/delete-image-from-private-supabase.js +0 -1
- package/general/delete-image-from-public-supabase.js +0 -1
- package/general/dynamic-page-limit.js +3 -2
- package/general/enum-to-text.js +7 -4
- package/general/fetch-data.js +0 -1
- package/general/fetch-supabase-image.js +0 -1
- package/general/fetch-supabase-private-assets.js +15 -14
- package/general/format-date.js +8 -8
- package/general/format-number.js +3 -2
- package/general/format-time.js +3 -2
- package/general/full-year-range.js +2 -2
- package/general/generate-blog-schema.d.ts +3 -3
- package/general/generate-blog-schema.js +20 -13
- package/general/generate-breadcrumb-schema.d.ts +4 -4
- package/general/generate-breadcrumb-schema.js +9 -10
- package/general/generate-faq-schema.d.ts +5 -5
- package/general/generate-faq-schema.js +18 -11
- package/general/generate-grid.js +0 -1
- package/general/generate-organization-schema.d.ts +3 -3
- package/general/generate-organization-schema.js +25 -18
- package/general/get-available-page-limit.js +2 -2
- package/general/get-calendar-dates.js +14 -3
- package/general/get-full-name.d.ts +1 -1
- package/general/get-number-of-days-in-month.d.ts +1 -1
- package/general/get-pathname.js +4 -1
- package/general/is-odd.js +1 -1
- package/general/is-previous-button-disabled.js +3 -1
- package/general/parse-frontmatter.js +0 -1
- package/general/remove-data-image-prefix.js +3 -2
- package/general/repeat-times.js +0 -1
- package/general/resolve-current-date.js +1 -2
- package/general/resolve-grid.js +3 -2
- package/general/slugify.js +11 -9
- package/general/text-to-enum.js +6 -1
- package/general/text-to-sentence-case.js +3 -1
- package/general/time-out.js +5 -4
- package/general/truncate-text.js +3 -1
- package/general/upload-blob-to-private-supabase.js +2 -2
- package/general/upload-blob-to-public-supabase.js +2 -2
- package/general/upload-image-to-private-supabase.js +2 -2
- package/general/upload-image-to-public-supabase.js +2 -2
- package/general/validate-email.js +1 -1
- package/hooks/use-fetch.js +11 -12
- package/hooks/use-module-entity.js +5 -6
- package/hooks/use-sticky.js +0 -1
- package/hooks/with-seo.d.ts +1 -1
- package/hooks/with-seo.js +3 -4
- package/local-storage/get-storage-value.js +0 -1
- package/package.json +22 -13
- package/setupTests.js +1 -2
- package/storybook/generate-sitemap.js +0 -1
- package/storybook/preview.js +1 -4
- package/storybook/react-design-story-script.js +0 -2
- package/storybook/react-emoji-collection.js +8 -6
- package/storybook/react-emoji-story-script.js +0 -2
- package/storybook/react-icon-collection.js +4 -3
- package/storybook/react-icon-story-script.js +0 -2
- package/storybook/react-logo-collection.js +4 -3
- package/storybook/react-logo-story-script.js +0 -2
- package/storybook/responsive-component.js +14 -7
|
@@ -1,26 +1,85 @@
|
|
|
1
1
|
import { QuoteInvoiceBE } from '../type';
|
|
2
|
+
type PrismaClient = any;
|
|
2
3
|
interface GetQuotesInvoicesArgs {
|
|
3
|
-
prisma:
|
|
4
|
+
prisma: PrismaClient;
|
|
4
5
|
}
|
|
5
6
|
interface GetQuoteInvoiceByIdArgs {
|
|
6
7
|
id: string;
|
|
7
|
-
prisma:
|
|
8
|
+
prisma: PrismaClient;
|
|
8
9
|
}
|
|
9
10
|
interface PostQuotesInvoicesArgs {
|
|
10
11
|
currentPage: number;
|
|
11
12
|
pageLimit: number;
|
|
12
|
-
prisma:
|
|
13
|
-
queryWhere
|
|
13
|
+
prisma: PrismaClient;
|
|
14
|
+
queryWhere?: {
|
|
14
15
|
[key: string]: any;
|
|
15
16
|
};
|
|
16
17
|
}
|
|
18
|
+
interface PostQuoteInvoiceArgs {
|
|
19
|
+
address?: string;
|
|
20
|
+
category: string;
|
|
21
|
+
city?: string;
|
|
22
|
+
companyId?: string;
|
|
23
|
+
country?: string;
|
|
24
|
+
currency: string;
|
|
25
|
+
customerId?: string;
|
|
26
|
+
date: string;
|
|
27
|
+
discount?: string;
|
|
28
|
+
discountUnit: string;
|
|
29
|
+
email?: string;
|
|
30
|
+
expiryDate: string;
|
|
31
|
+
firstName?: string;
|
|
32
|
+
id?: string;
|
|
33
|
+
invoiceStatus: string;
|
|
34
|
+
lastName?: string;
|
|
35
|
+
mode: 'Create' | 'Edit';
|
|
36
|
+
note: string;
|
|
37
|
+
phone?: string;
|
|
38
|
+
prisma: PrismaClient;
|
|
39
|
+
products?: Array<{
|
|
40
|
+
id: string;
|
|
41
|
+
quantity: string;
|
|
42
|
+
}>;
|
|
43
|
+
quoteStatus: string;
|
|
44
|
+
ref: string;
|
|
45
|
+
services?: Array<any>;
|
|
46
|
+
subTotal: string;
|
|
47
|
+
taxRate: string;
|
|
48
|
+
total: string;
|
|
49
|
+
}
|
|
17
50
|
interface DeleteQuoteInvoiceArgs {
|
|
18
|
-
prisma:
|
|
51
|
+
prisma: PrismaClient;
|
|
19
52
|
id: string;
|
|
20
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves all quotes/invoices with related data
|
|
56
|
+
* @param {GetQuotesInvoicesArgs} args - Object containing prisma client
|
|
57
|
+
* @returns {Promise<Array<QuoteInvoiceBE>>} Array of quotes/invoices with related entities (company, customer, payments, products, services)
|
|
58
|
+
*/
|
|
21
59
|
export declare const getQuotesInvoices: ({ prisma, }: GetQuotesInvoicesArgs) => Promise<Array<QuoteInvoiceBE>>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves a quote/invoice by its ID with related data
|
|
62
|
+
* @param {GetQuoteInvoiceByIdArgs} args - Object containing prisma client and quote/invoice ID
|
|
63
|
+
* @returns {Promise<QuoteInvoiceBE | null>} Quote/invoice with related entities or null if not found
|
|
64
|
+
*/
|
|
65
|
+
export declare const getQuoteInvoiceById: ({ prisma, id, }: GetQuoteInvoiceByIdArgs) => Promise<QuoteInvoiceBE | null>;
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves paginated quotes/invoices with filtering
|
|
68
|
+
* @param {PostQuotesInvoicesArgs} args - Object containing prisma client, pagination, and filtering options
|
|
69
|
+
* @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple of [total count, quotes/invoices array]
|
|
70
|
+
*/
|
|
71
|
+
export declare const postQuotesInvoices: ({ currentPage, pageLimit, prisma, queryWhere, }: PostQuotesInvoicesArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new quote/invoice or updates an existing one
|
|
74
|
+
* Handles complex business logic including customer/company associations and service management
|
|
75
|
+
* @param {PostQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice data
|
|
76
|
+
* @returns {Promise<QuoteInvoiceBE>} Created or updated quote/invoice
|
|
77
|
+
*/
|
|
78
|
+
export declare const postQuoteInvoice: ({ address, category, city, companyId, country, currency, customerId, date, discount, discountUnit, email, expiryDate, firstName, id, invoiceStatus, lastName, mode, note, phone, prisma, products, quoteStatus, ref, services, subTotal, taxRate, total, }: PostQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
|
|
79
|
+
/**
|
|
80
|
+
* Deletes a quote/invoice by ID
|
|
81
|
+
* @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice ID
|
|
82
|
+
* @returns {Promise<QuoteInvoiceBE>} Deleted quote/invoice
|
|
83
|
+
*/
|
|
25
84
|
export declare const deleteQuoteInvoice: ({ prisma, id, }: DeleteQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
|
|
26
85
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any, no-restricted-globals, @typescript-eslint/array-type */
|
|
3
2
|
var __assign = (this && this.__assign) || function () {
|
|
4
3
|
__assign = Object.assign || function(t) {
|
|
5
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -49,6 +48,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
48
|
};
|
|
50
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
50
|
exports.deleteQuoteInvoice = exports.postQuoteInvoice = exports.postQuotesInvoices = exports.getQuoteInvoiceById = exports.getQuotesInvoices = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves all quotes/invoices with related data
|
|
53
|
+
* @param {GetQuotesInvoicesArgs} args - Object containing prisma client
|
|
54
|
+
* @returns {Promise<Array<QuoteInvoiceBE>>} Array of quotes/invoices with related entities (company, customer, payments, products, services)
|
|
55
|
+
*/
|
|
52
56
|
var getQuotesInvoices = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
53
57
|
var quotesInvoices;
|
|
54
58
|
var prisma = _b.prisma;
|
|
@@ -73,23 +77,32 @@ var getQuotesInvoices = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
73
77
|
});
|
|
74
78
|
}); };
|
|
75
79
|
exports.getQuotesInvoices = getQuotesInvoices;
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves a quote/invoice by its ID with related data
|
|
82
|
+
* @param {GetQuoteInvoiceByIdArgs} args - Object containing prisma client and quote/invoice ID
|
|
83
|
+
* @returns {Promise<QuoteInvoiceBE | null>} Quote/invoice with related entities or null if not found
|
|
84
|
+
*/
|
|
76
85
|
var getQuoteInvoiceById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
77
86
|
var quoteInvoice;
|
|
78
87
|
var prisma = _b.prisma, id = _b.id;
|
|
79
88
|
return __generator(this, function (_c) {
|
|
80
89
|
switch (_c.label) {
|
|
81
|
-
case 0:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
case 0:
|
|
91
|
+
if (!id) {
|
|
92
|
+
throw new Error('Quote/invoice ID is required');
|
|
93
|
+
}
|
|
94
|
+
return [4 /*yield*/, prisma.quoteInvoice.findUnique({
|
|
95
|
+
where: {
|
|
96
|
+
id: id,
|
|
97
|
+
},
|
|
98
|
+
include: {
|
|
99
|
+
company: true,
|
|
100
|
+
customer: true,
|
|
101
|
+
payments: true,
|
|
102
|
+
products: true,
|
|
103
|
+
services: true,
|
|
104
|
+
},
|
|
105
|
+
})];
|
|
93
106
|
case 1:
|
|
94
107
|
quoteInvoice = _c.sent();
|
|
95
108
|
return [2 /*return*/, quoteInvoice];
|
|
@@ -97,38 +110,56 @@ var getQuoteInvoiceById = function (_a) { return __awaiter(void 0, [_a], void 0,
|
|
|
97
110
|
});
|
|
98
111
|
}); };
|
|
99
112
|
exports.getQuoteInvoiceById = getQuoteInvoiceById;
|
|
113
|
+
/**
|
|
114
|
+
* Retrieves paginated quotes/invoices with filtering
|
|
115
|
+
* @param {PostQuotesInvoicesArgs} args - Object containing prisma client, pagination, and filtering options
|
|
116
|
+
* @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple of [total count, quotes/invoices array]
|
|
117
|
+
*/
|
|
100
118
|
var postQuotesInvoices = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
101
119
|
var quotesInvoices;
|
|
102
|
-
var
|
|
103
|
-
return __generator(this, function (
|
|
104
|
-
switch (
|
|
105
|
-
case 0:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
var _c = _b.currentPage, currentPage = _c === void 0 ? 1 : _c, _d = _b.pageLimit, pageLimit = _d === void 0 ? 10 : _d, prisma = _b.prisma, _e = _b.queryWhere, queryWhere = _e === void 0 ? {} : _e;
|
|
121
|
+
return __generator(this, function (_f) {
|
|
122
|
+
switch (_f.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
if (currentPage < 1) {
|
|
125
|
+
throw new Error('Current page must be greater than 0');
|
|
126
|
+
}
|
|
127
|
+
if (pageLimit < 1) {
|
|
128
|
+
throw new Error('Page limit must be greater than 0');
|
|
129
|
+
}
|
|
130
|
+
return [4 /*yield*/, prisma.$transaction([
|
|
131
|
+
prisma.quoteInvoice.count({
|
|
132
|
+
where: queryWhere,
|
|
133
|
+
}),
|
|
134
|
+
prisma.quoteInvoice.findMany({
|
|
135
|
+
orderBy: {
|
|
136
|
+
createdAt: 'desc',
|
|
137
|
+
},
|
|
138
|
+
include: {
|
|
139
|
+
company: true,
|
|
140
|
+
customer: true,
|
|
141
|
+
payments: true,
|
|
142
|
+
products: true,
|
|
143
|
+
services: true,
|
|
144
|
+
},
|
|
145
|
+
where: queryWhere,
|
|
146
|
+
take: pageLimit,
|
|
147
|
+
skip: (currentPage - 1) * pageLimit,
|
|
148
|
+
}),
|
|
149
|
+
])];
|
|
125
150
|
case 1:
|
|
126
|
-
quotesInvoices =
|
|
151
|
+
quotesInvoices = _f.sent();
|
|
127
152
|
return [2 /*return*/, quotesInvoices];
|
|
128
153
|
}
|
|
129
154
|
});
|
|
130
155
|
}); };
|
|
131
156
|
exports.postQuotesInvoices = postQuotesInvoices;
|
|
157
|
+
/**
|
|
158
|
+
* Creates a new quote/invoice or updates an existing one
|
|
159
|
+
* Handles complex business logic including customer/company associations and service management
|
|
160
|
+
* @param {PostQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice data
|
|
161
|
+
* @returns {Promise<QuoteInvoiceBE>} Created or updated quote/invoice
|
|
162
|
+
*/
|
|
132
163
|
var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
133
164
|
var quoteInvoice, mappedServices, foundQuoteInvoice, filteredEditServices, filteredCreateServices;
|
|
134
165
|
var _c, _d;
|
|
@@ -136,6 +167,24 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
136
167
|
return __generator(this, function (_e) {
|
|
137
168
|
switch (_e.label) {
|
|
138
169
|
case 0:
|
|
170
|
+
if (!category ||
|
|
171
|
+
!currency ||
|
|
172
|
+
!date ||
|
|
173
|
+
!discountUnit ||
|
|
174
|
+
!expiryDate ||
|
|
175
|
+
!invoiceStatus ||
|
|
176
|
+
!mode ||
|
|
177
|
+
!note ||
|
|
178
|
+
!quoteStatus ||
|
|
179
|
+
!ref ||
|
|
180
|
+
!subTotal ||
|
|
181
|
+
!taxRate ||
|
|
182
|
+
!total) {
|
|
183
|
+
throw new Error('Category, currency, date, discount unit, expiry date, invoice status, mode, note, quote status, ref, sub total, tax rate, and total are required');
|
|
184
|
+
}
|
|
185
|
+
if (mode !== 'Create' && mode !== 'Edit') {
|
|
186
|
+
throw new Error('Mode must be either "Create" or "Edit"');
|
|
187
|
+
}
|
|
139
188
|
if (!(mode === 'Create')) return [3 /*break*/, 5];
|
|
140
189
|
mappedServices = void 0;
|
|
141
190
|
if (services === null || services === void 0 ? void 0 : services.length) {
|
|
@@ -152,7 +201,7 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
152
201
|
companyId: companyId,
|
|
153
202
|
})), { currency: currency }), (customerId && {
|
|
154
203
|
customerId: customerId,
|
|
155
|
-
})), { date: date, discount: discount, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total }), (mappedServices && {
|
|
204
|
+
})), { date: date, discount: discount || null, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total }), (mappedServices && {
|
|
156
205
|
services: {
|
|
157
206
|
createMany: {
|
|
158
207
|
data: mappedServices,
|
|
@@ -187,31 +236,36 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
187
236
|
_e.sent();
|
|
188
237
|
return [3 /*break*/, 5];
|
|
189
238
|
case 3: return [4 /*yield*/, prisma.quoteInvoice.create({
|
|
190
|
-
data: __assign(__assign(__assign(__assign({ category: category }, (companyId && {
|
|
239
|
+
data: __assign(__assign(__assign(__assign(__assign({ category: category }, (companyId && {
|
|
191
240
|
companyId: companyId,
|
|
192
241
|
})), { currency: currency }), (customerId && {
|
|
193
242
|
customerId: customerId,
|
|
194
|
-
})), { date: date, discount: discount, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total, customer: {
|
|
243
|
+
})), { date: date, discount: discount || null, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total, customer: {
|
|
195
244
|
create: {
|
|
196
|
-
address: address,
|
|
197
|
-
city: city,
|
|
198
|
-
country: country,
|
|
199
|
-
email: email,
|
|
200
|
-
firstName: firstName,
|
|
201
|
-
lastName: lastName,
|
|
202
|
-
phone: phone,
|
|
245
|
+
address: address || '',
|
|
246
|
+
city: city || '',
|
|
247
|
+
country: country || '',
|
|
248
|
+
email: email || '',
|
|
249
|
+
firstName: firstName || '',
|
|
250
|
+
lastName: lastName || '',
|
|
251
|
+
phone: phone || '',
|
|
203
252
|
},
|
|
204
|
-
},
|
|
253
|
+
} }), (mappedServices && {
|
|
254
|
+
services: {
|
|
205
255
|
createMany: {
|
|
206
256
|
data: mappedServices,
|
|
207
257
|
},
|
|
208
|
-
}
|
|
258
|
+
},
|
|
259
|
+
})),
|
|
209
260
|
})];
|
|
210
261
|
case 4:
|
|
211
262
|
quoteInvoice = _e.sent();
|
|
212
263
|
_e.label = 5;
|
|
213
264
|
case 5:
|
|
214
265
|
if (!(mode === 'Edit')) return [3 /*break*/, 10];
|
|
266
|
+
if (!id) {
|
|
267
|
+
throw new Error('Quote/invoice ID is required for Edit mode');
|
|
268
|
+
}
|
|
215
269
|
return [4 /*yield*/, prisma.quoteInvoice.findUnique({
|
|
216
270
|
where: {
|
|
217
271
|
id: id,
|
|
@@ -219,6 +273,9 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
219
273
|
})];
|
|
220
274
|
case 6:
|
|
221
275
|
foundQuoteInvoice = _e.sent();
|
|
276
|
+
if (!foundQuoteInvoice) {
|
|
277
|
+
throw new Error('Quote/invoice not found');
|
|
278
|
+
}
|
|
222
279
|
filteredEditServices = services === null || services === void 0 ? void 0 : services.filter(function (_a) {
|
|
223
280
|
var _mode = _a.mode;
|
|
224
281
|
return _mode === 'Edit';
|
|
@@ -229,7 +286,7 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
229
286
|
})) === null || _d === void 0 ? void 0 : _d.map(function (item) {
|
|
230
287
|
var toReturn = __assign({}, item);
|
|
231
288
|
delete toReturn.mode;
|
|
232
|
-
return
|
|
289
|
+
return __assign(__assign({}, toReturn), { quoteInvoiceId: id });
|
|
233
290
|
});
|
|
234
291
|
if (filteredEditServices === null || filteredEditServices === void 0 ? void 0 : filteredEditServices.length) {
|
|
235
292
|
filteredEditServices === null || filteredEditServices === void 0 ? void 0 : filteredEditServices.map(function (item) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -256,7 +313,7 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
256
313
|
}); });
|
|
257
314
|
}
|
|
258
315
|
if (!(filteredCreateServices === null || filteredCreateServices === void 0 ? void 0 : filteredCreateServices.length)) return [3 /*break*/, 8];
|
|
259
|
-
return [4 /*yield*/, prisma.
|
|
316
|
+
return [4 /*yield*/, prisma.service.createMany({
|
|
260
317
|
data: filteredCreateServices,
|
|
261
318
|
})];
|
|
262
319
|
case 7:
|
|
@@ -266,7 +323,7 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
266
323
|
where: {
|
|
267
324
|
id: id,
|
|
268
325
|
},
|
|
269
|
-
data: __assign(__assign({}, foundQuoteInvoice), { category: category, companyId: companyId, currency: currency, customerId: customerId, date: date, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total }),
|
|
326
|
+
data: __assign(__assign({}, foundQuoteInvoice), { category: category, companyId: companyId || null, currency: currency, customerId: customerId || null, date: date, discount: discount || null, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total }),
|
|
270
327
|
})];
|
|
271
328
|
case 9:
|
|
272
329
|
quoteInvoice = _e.sent();
|
|
@@ -276,16 +333,25 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
276
333
|
});
|
|
277
334
|
}); };
|
|
278
335
|
exports.postQuoteInvoice = postQuoteInvoice;
|
|
336
|
+
/**
|
|
337
|
+
* Deletes a quote/invoice by ID
|
|
338
|
+
* @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice ID
|
|
339
|
+
* @returns {Promise<QuoteInvoiceBE>} Deleted quote/invoice
|
|
340
|
+
*/
|
|
279
341
|
var deleteQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
280
342
|
var quoteInvoice;
|
|
281
343
|
var prisma = _b.prisma, id = _b.id;
|
|
282
344
|
return __generator(this, function (_c) {
|
|
283
345
|
switch (_c.label) {
|
|
284
|
-
case 0:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
346
|
+
case 0:
|
|
347
|
+
if (!id) {
|
|
348
|
+
throw new Error('Quote/invoice ID is required');
|
|
349
|
+
}
|
|
350
|
+
return [4 /*yield*/, prisma.quoteInvoice.delete({
|
|
351
|
+
where: {
|
|
352
|
+
id: id,
|
|
353
|
+
},
|
|
354
|
+
})];
|
|
289
355
|
case 1:
|
|
290
356
|
quoteInvoice = _c.sent();
|
|
291
357
|
return [2 /*return*/, quoteInvoice];
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { QuoteInvoiceBE } from '../type';
|
|
2
|
+
type PrismaClient = any;
|
|
2
3
|
interface PostQuotesInvoicesReportArgs {
|
|
3
|
-
include
|
|
4
|
+
include?: {
|
|
4
5
|
[key: string]: any;
|
|
5
6
|
};
|
|
6
|
-
orderBy
|
|
7
|
+
orderBy?: {
|
|
7
8
|
[key: string]: any;
|
|
8
9
|
};
|
|
9
|
-
prisma:
|
|
10
|
-
queryWhere
|
|
10
|
+
prisma: PrismaClient;
|
|
11
|
+
queryWhere?: {
|
|
11
12
|
[key: string]: any;
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Generates a report of all quotes/invoices with filtering and sorting (no pagination)
|
|
17
|
+
* Returns all matching records for reporting purposes
|
|
18
|
+
* @param {PostQuotesInvoicesReportArgs} args - Object containing prisma client, filtering, including, and sorting options
|
|
19
|
+
* @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple of [total count, all matching quotes/invoices array]
|
|
20
|
+
*/
|
|
21
|
+
export declare const postQuotesInvoicesReport: ({ include, orderBy, prisma, queryWhere, }: PostQuotesInvoicesReportArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
|
|
15
22
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any, no-restricted-globals, @typescript-eslint/array-type */
|
|
3
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -38,11 +37,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
37
|
};
|
|
39
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
39
|
exports.postQuotesInvoicesReport = void 0;
|
|
40
|
+
/**
|
|
41
|
+
* Generates a report of all quotes/invoices with filtering and sorting (no pagination)
|
|
42
|
+
* Returns all matching records for reporting purposes
|
|
43
|
+
* @param {PostQuotesInvoicesReportArgs} args - Object containing prisma client, filtering, including, and sorting options
|
|
44
|
+
* @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple of [total count, all matching quotes/invoices array]
|
|
45
|
+
*/
|
|
41
46
|
var postQuotesInvoicesReport = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
47
|
var quotesInvoices;
|
|
43
|
-
var
|
|
44
|
-
return __generator(this, function (
|
|
45
|
-
switch (
|
|
48
|
+
var _c = _b.include, include = _c === void 0 ? {} : _c, _d = _b.orderBy, orderBy = _d === void 0 ? { createdAt: 'desc' } : _d, prisma = _b.prisma, _e = _b.queryWhere, queryWhere = _e === void 0 ? {} : _e;
|
|
49
|
+
return __generator(this, function (_f) {
|
|
50
|
+
switch (_f.label) {
|
|
46
51
|
case 0: return [4 /*yield*/, prisma.$transaction([
|
|
47
52
|
prisma.quoteInvoice.count({
|
|
48
53
|
where: queryWhere,
|
|
@@ -54,7 +59,7 @@ var postQuotesInvoicesReport = function (_a) { return __awaiter(void 0, [_a], vo
|
|
|
54
59
|
}),
|
|
55
60
|
])];
|
|
56
61
|
case 1:
|
|
57
|
-
quotesInvoices =
|
|
62
|
+
quotesInvoices = _f.sent();
|
|
58
63
|
return [2 /*return*/, quotesInvoices];
|
|
59
64
|
}
|
|
60
65
|
});
|
|
@@ -1,27 +1,59 @@
|
|
|
1
1
|
import { TaxBE } from '../type';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type PrismaClient = any;
|
|
3
|
+
interface ListTaxArgs {
|
|
4
|
+
currentPage?: number;
|
|
5
|
+
include?: any;
|
|
6
|
+
orderBy?: any;
|
|
7
|
+
pageLimit?: number;
|
|
8
|
+
prisma: PrismaClient;
|
|
9
|
+
queryWhere?: any;
|
|
4
10
|
}
|
|
5
|
-
interface
|
|
11
|
+
interface UnitTaxByIdArgs {
|
|
6
12
|
id: string;
|
|
7
|
-
|
|
13
|
+
include?: any;
|
|
14
|
+
prisma: PrismaClient;
|
|
15
|
+
queryWhere?: any;
|
|
8
16
|
}
|
|
9
|
-
interface
|
|
10
|
-
description
|
|
11
|
-
enabled:
|
|
17
|
+
interface UpdateTaxArgs {
|
|
18
|
+
description?: string;
|
|
19
|
+
enabled: boolean;
|
|
12
20
|
id: string;
|
|
13
|
-
|
|
21
|
+
include?: any;
|
|
22
|
+
isDefault: boolean;
|
|
14
23
|
preferenceId: string;
|
|
24
|
+
prisma: PrismaClient;
|
|
25
|
+
queryWhere?: any;
|
|
15
26
|
taxName: string;
|
|
16
27
|
taxRate: string;
|
|
17
|
-
prisma: any;
|
|
18
28
|
}
|
|
19
29
|
interface DeleteTaxArgs {
|
|
20
|
-
prisma: any;
|
|
21
30
|
id: string;
|
|
31
|
+
include?: any;
|
|
32
|
+
prisma: PrismaClient;
|
|
33
|
+
queryWhere?: any;
|
|
22
34
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves a paginated list of taxes
|
|
37
|
+
* @param {ListTaxArgs} args - Object containing prisma client, pagination, and filter options
|
|
38
|
+
* @returns {Promise<[number, Array<TaxBE>]>} Tuple of [total count, tax array]
|
|
39
|
+
*/
|
|
40
|
+
export declare const listTax: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListTaxArgs) => Promise<[number, Array<TaxBE>]>;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves a single tax by its ID
|
|
43
|
+
* @param {UnitTaxByIdArgs} args - Object containing prisma client, tax ID, and optional filters
|
|
44
|
+
* @returns {Promise<TaxBE | null>} Tax or null if not found
|
|
45
|
+
*/
|
|
46
|
+
export declare const unitTaxById: ({ id, include, prisma, queryWhere, }: UnitTaxByIdArgs) => Promise<TaxBE | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Creates or updates a tax
|
|
49
|
+
* @param {UpdateTaxArgs} args - Object containing prisma client and tax data
|
|
50
|
+
* @returns {Promise<TaxBE>} Created or updated tax
|
|
51
|
+
*/
|
|
52
|
+
export declare const updateTax: ({ description, enabled, id, include, isDefault, preferenceId, prisma, queryWhere, taxName, taxRate, }: UpdateTaxArgs) => Promise<TaxBE>;
|
|
53
|
+
/**
|
|
54
|
+
* Deletes a tax by ID
|
|
55
|
+
* @param {DeleteTaxArgs} args - Object containing prisma client, tax ID, and optional filters
|
|
56
|
+
* @returns {Promise<TaxBE>} Deleted tax
|
|
57
|
+
*/
|
|
58
|
+
export declare const deleteTax: ({ id, include, prisma, queryWhere, }: DeleteTaxArgs) => Promise<TaxBE>;
|
|
27
59
|
export {};
|