@react-pakistan/util-functions 1.24.99 → 1.25.1

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.
Files changed (73) hide show
  1. package/api/stellar-solutions/app-user/index.d.ts +9 -9
  2. package/api/stellar-solutions/app-user/index.js +4 -4
  3. package/api/stellar-solutions/bank/cache.d.ts +99 -0
  4. package/api/stellar-solutions/bank/cache.js +256 -0
  5. package/api/stellar-solutions/bank/index.d.ts +10 -10
  6. package/api/stellar-solutions/bank/index.js +19 -4
  7. package/api/stellar-solutions/branch/cache.d.ts +97 -0
  8. package/api/stellar-solutions/branch/cache.js +256 -0
  9. package/api/stellar-solutions/branch/index.d.ts +10 -10
  10. package/api/stellar-solutions/branch/index.js +19 -4
  11. package/api/stellar-solutions/company/cache.d.ts +106 -0
  12. package/api/stellar-solutions/company/cache.js +307 -0
  13. package/api/stellar-solutions/company/index.d.ts +10 -10
  14. package/api/stellar-solutions/company/index.js +19 -4
  15. package/api/stellar-solutions/company-report/index.d.ts +3 -3
  16. package/api/stellar-solutions/company-report/index.js +1 -1
  17. package/api/stellar-solutions/constants.d.ts +12 -0
  18. package/api/stellar-solutions/constants.js +13 -1
  19. package/api/stellar-solutions/contact/cache.d.ts +108 -0
  20. package/api/stellar-solutions/contact/cache.js +307 -0
  21. package/api/stellar-solutions/contact/index.d.ts +10 -10
  22. package/api/stellar-solutions/contact/index.js +19 -4
  23. package/api/stellar-solutions/currency/cache.d.ts +99 -0
  24. package/api/stellar-solutions/currency/cache.js +256 -0
  25. package/api/stellar-solutions/currency/index.d.ts +10 -10
  26. package/api/stellar-solutions/currency/index.js +19 -4
  27. package/api/stellar-solutions/customer/cache.d.ts +108 -0
  28. package/api/stellar-solutions/customer/cache.js +307 -0
  29. package/api/stellar-solutions/customer/index.d.ts +12 -12
  30. package/api/stellar-solutions/customer/index.js +20 -5
  31. package/api/stellar-solutions/expense/cache.d.ts +106 -0
  32. package/api/stellar-solutions/expense/cache.js +307 -0
  33. package/api/stellar-solutions/expense/index.d.ts +10 -10
  34. package/api/stellar-solutions/expense/index.js +19 -4
  35. package/api/stellar-solutions/expense-category/cache.d.ts +94 -0
  36. package/api/stellar-solutions/expense-category/cache.js +280 -0
  37. package/api/stellar-solutions/expense-category/index.d.ts +10 -10
  38. package/api/stellar-solutions/expense-category/index.js +19 -4
  39. package/api/stellar-solutions/lead/index.d.ts +9 -9
  40. package/api/stellar-solutions/lead/index.js +4 -4
  41. package/api/stellar-solutions/menu-order/index.d.ts +9 -9
  42. package/api/stellar-solutions/menu-order/index.js +4 -4
  43. package/api/stellar-solutions/payment/index.d.ts +9 -9
  44. package/api/stellar-solutions/payment/index.js +4 -4
  45. package/api/stellar-solutions/payment-mode/cache.d.ts +97 -0
  46. package/api/stellar-solutions/payment-mode/cache.js +256 -0
  47. package/api/stellar-solutions/payment-mode/index.d.ts +10 -10
  48. package/api/stellar-solutions/payment-mode/index.js +19 -4
  49. package/api/stellar-solutions/preference/cache.d.ts +85 -0
  50. package/api/stellar-solutions/preference/cache.js +229 -0
  51. package/api/stellar-solutions/preference/index.d.ts +6 -6
  52. package/api/stellar-solutions/preference/index.js +17 -2
  53. package/api/stellar-solutions/product/cache.d.ts +9 -9
  54. package/api/stellar-solutions/product/cache.js +4 -4
  55. package/api/stellar-solutions/product/index.d.ts +10 -10
  56. package/api/stellar-solutions/product/index.js +6 -6
  57. package/api/stellar-solutions/product-category/cache.d.ts +9 -9
  58. package/api/stellar-solutions/product-category/cache.js +4 -4
  59. package/api/stellar-solutions/product-category/index.d.ts +9 -9
  60. package/api/stellar-solutions/product-category/index.js +4 -4
  61. package/api/stellar-solutions/profile/index.d.ts +13 -13
  62. package/api/stellar-solutions/profile/index.js +6 -6
  63. package/api/stellar-solutions/quote-invoice/index.d.ts +9 -9
  64. package/api/stellar-solutions/quote-invoice/index.js +4 -4
  65. package/api/stellar-solutions/quote-invoice-report/index.d.ts +3 -3
  66. package/api/stellar-solutions/quote-invoice-report/index.js +1 -1
  67. package/api/stellar-solutions/tax/cache.d.ts +97 -0
  68. package/api/stellar-solutions/tax/cache.js +256 -0
  69. package/api/stellar-solutions/tax/index.d.ts +10 -10
  70. package/api/stellar-solutions/tax/index.js +19 -4
  71. package/api/stellar-solutions/type.d.ts +57 -46
  72. package/api/stellar-solutions/type.js +11 -0
  73. package/package.json +1 -1
@@ -76,7 +76,7 @@ var multi_part_search_1 = require("../../../general/multi-part-search");
76
76
  /**
77
77
  * Retrieves a paginated list of product categories
78
78
  * @param {ListProductCategoryArgs} args - Object containing prisma client, pagination, filtering, and ordering options
79
- * @returns {Promise<[number, Array<ProductCategoryTypeBE>]>} Tuple containing total count and array of product categories
79
+ * @returns {Promise<[number, Array<ProductCategoryBE>]>} Tuple containing total count and array of product categories
80
80
  */
81
81
  var listProductCategory = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
82
82
  var include, orderBy, idSearchQuery, nameSearchQuery, descriptionSearchQuery, where, _c, count, items;
@@ -134,7 +134,7 @@ exports.listProductCategory = listProductCategory;
134
134
  /**
135
135
  * Retrieves a single product category by its ID
136
136
  * @param {UnitProductCategoryByIdArgs} args - Object containing prisma client, product category ID, and optional query parameters
137
- * @returns {Promise<ProductCategoryTypeBE | null>} Product category or null if not found
137
+ * @returns {Promise<ProductCategoryBE | null>} Product category or null if not found
138
138
  */
139
139
  var unitProductCategoryById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
140
140
  var include, where, productCategory;
@@ -165,7 +165,7 @@ exports.unitProductCategoryById = unitProductCategoryById;
165
165
  /**
166
166
  * Creates or updates a product category
167
167
  * @param {UpdateProductCategoryArgs} args - Object containing prisma client, product category data, and optional query parameters
168
- * @returns {Promise<ProductCategoryTypeBE>} Created or updated product category
168
+ * @returns {Promise<ProductCategoryBE>} Created or updated product category
169
169
  */
170
170
  var updateProductCategory = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
171
171
  var productCategoryData, where, productCategory;
@@ -201,7 +201,7 @@ exports.updateProductCategory = updateProductCategory;
201
201
  /**
202
202
  * Deletes a product category by ID
203
203
  * @param {DeleteProductCategoryArgs} args - Object containing prisma client, product category ID, and optional query parameters
204
- * @returns {Promise<ProductCategoryTypeBE>} Deleted product category
204
+ * @returns {Promise<ProductCategoryBE>} Deleted product category
205
205
  */
206
206
  var deleteProductCategory = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
207
207
  var where, productCategory;
@@ -1,4 +1,4 @@
1
- import { ProfileTypeBE } from '../type';
1
+ import { ProfileBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  interface GetProfilesArgs {
4
4
  orderByColumn?: string;
@@ -42,37 +42,37 @@ interface DeleteProfileArgs {
42
42
  /**
43
43
  * Retrieves all profiles
44
44
  * @param {GetProfilesArgs} args - Object containing prisma client
45
- * @returns {Promise<Array<ProfileTypeBE>>} Array of profiles ordered by creation date (newest first)
45
+ * @returns {Promise<Array<ProfileBE>>} Array of profiles ordered by creation date (newest first)
46
46
  */
47
- export declare const getProfiles: ({ orderByColumn, orderByDirection, prisma, }: GetProfilesArgs) => Promise<Array<ProfileTypeBE>>;
47
+ export declare const getProfiles: ({ orderByColumn, orderByDirection, prisma, }: GetProfilesArgs) => Promise<Array<ProfileBE>>;
48
48
  /**
49
49
  * Retrieves a profile by its ID
50
50
  * @param {GetProfileByIdArgs} args - Object containing prisma client and profile ID
51
- * @returns {Promise<ProfileTypeBE | null>} Profile or null if not found
51
+ * @returns {Promise<ProfileBE | null>} Profile or null if not found
52
52
  */
53
- export declare const getProfileById: ({ prisma, id, }: GetProfileByIdArgs) => Promise<ProfileTypeBE | null>;
53
+ export declare const getProfileById: ({ prisma, id, }: GetProfileByIdArgs) => Promise<ProfileBE | null>;
54
54
  /**
55
55
  * Retrieves a profile by user ID
56
56
  * @param {GetProfileByUserIdArgs} args - Object containing prisma client and user ID
57
- * @returns {Promise<ProfileTypeBE | null>} Profile or null if not found
57
+ * @returns {Promise<ProfileBE | null>} Profile or null if not found
58
58
  */
59
- export declare const getProfileByUserId: ({ prisma, userId, }: GetProfileByUserIdArgs) => Promise<ProfileTypeBE | null>;
59
+ export declare const getProfileByUserId: ({ prisma, userId, }: GetProfileByUserIdArgs) => Promise<ProfileBE | null>;
60
60
  /**
61
61
  * Retrieves paginated profiles with filtering
62
62
  * @param {PostProfilesArgs} args - Object containing prisma client, pagination, and filtering options
63
- * @returns {Promise<[number, Array<ProfileTypeBE>]>} Tuple of [total count, profiles array]
63
+ * @returns {Promise<[number, Array<ProfileBE>]>} Tuple of [total count, profiles array]
64
64
  */
65
- export declare const postProfiles: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: PostProfilesArgs) => Promise<[number, Array<ProfileTypeBE>]>;
65
+ export declare const postProfiles: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: PostProfilesArgs) => Promise<[number, Array<ProfileBE>]>;
66
66
  /**
67
67
  * Creates a new profile or updates an existing one
68
68
  * @param {PostProfileArgs} args - Object containing prisma client and profile data
69
- * @returns {Promise<ProfileTypeBE>} Created or updated profile
69
+ * @returns {Promise<ProfileBE>} Created or updated profile
70
70
  */
71
- export declare const postProfile: ({ avatar, dob, email, firstName, gender, id, language, lastName, location, phone, prisma, skill, userId, }: PostProfileArgs) => Promise<ProfileTypeBE>;
71
+ export declare const postProfile: ({ avatar, dob, email, firstName, gender, id, language, lastName, location, phone, prisma, skill, userId, }: PostProfileArgs) => Promise<ProfileBE>;
72
72
  /**
73
73
  * Deletes a profile by ID
74
74
  * @param {DeleteProfileArgs} args - Object containing prisma client and profile ID
75
- * @returns {Promise<ProfileTypeBE>} Deleted profile
75
+ * @returns {Promise<ProfileBE>} Deleted profile
76
76
  */
77
- export declare const deleteProfile: ({ prisma, id, }: DeleteProfileArgs) => Promise<ProfileTypeBE>;
77
+ export declare const deleteProfile: ({ prisma, id, }: DeleteProfileArgs) => Promise<ProfileBE>;
78
78
  export {};
@@ -51,7 +51,7 @@ exports.deleteProfile = exports.postProfile = exports.postProfiles = exports.get
51
51
  /**
52
52
  * Retrieves all profiles
53
53
  * @param {GetProfilesArgs} args - Object containing prisma client
54
- * @returns {Promise<Array<ProfileTypeBE>>} Array of profiles ordered by creation date (newest first)
54
+ * @returns {Promise<Array<ProfileBE>>} Array of profiles ordered by creation date (newest first)
55
55
  */
56
56
  var getProfiles = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
57
  var profiles;
@@ -74,7 +74,7 @@ exports.getProfiles = getProfiles;
74
74
  /**
75
75
  * Retrieves a profile by its ID
76
76
  * @param {GetProfileByIdArgs} args - Object containing prisma client and profile ID
77
- * @returns {Promise<ProfileTypeBE | null>} Profile or null if not found
77
+ * @returns {Promise<ProfileBE | null>} Profile or null if not found
78
78
  */
79
79
  var getProfileById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
80
80
  var profile;
@@ -100,7 +100,7 @@ exports.getProfileById = getProfileById;
100
100
  /**
101
101
  * Retrieves a profile by user ID
102
102
  * @param {GetProfileByUserIdArgs} args - Object containing prisma client and user ID
103
- * @returns {Promise<ProfileTypeBE | null>} Profile or null if not found
103
+ * @returns {Promise<ProfileBE | null>} Profile or null if not found
104
104
  */
105
105
  var getProfileByUserId = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
106
106
  var profile;
@@ -126,7 +126,7 @@ exports.getProfileByUserId = getProfileByUserId;
126
126
  /**
127
127
  * Retrieves paginated profiles with filtering
128
128
  * @param {PostProfilesArgs} args - Object containing prisma client, pagination, and filtering options
129
- * @returns {Promise<[number, Array<ProfileTypeBE>]>} Tuple of [total count, profiles array]
129
+ * @returns {Promise<[number, Array<ProfileBE>]>} Tuple of [total count, profiles array]
130
130
  */
131
131
  var postProfiles = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
132
132
  var profiles;
@@ -161,7 +161,7 @@ exports.postProfiles = postProfiles;
161
161
  /**
162
162
  * Creates a new profile or updates an existing one
163
163
  * @param {PostProfileArgs} args - Object containing prisma client and profile data
164
- * @returns {Promise<ProfileTypeBE>} Created or updated profile
164
+ * @returns {Promise<ProfileBE>} Created or updated profile
165
165
  */
166
166
  var postProfile = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
167
167
  var profileData, profile_1, profile;
@@ -209,7 +209,7 @@ exports.postProfile = postProfile;
209
209
  /**
210
210
  * Deletes a profile by ID
211
211
  * @param {DeleteProfileArgs} args - Object containing prisma client and profile ID
212
- * @returns {Promise<ProfileTypeBE>} Deleted profile
212
+ * @returns {Promise<ProfileBE>} Deleted profile
213
213
  */
214
214
  var deleteProfile = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
215
215
  var profile;
@@ -1,4 +1,4 @@
1
- import { QUOTE_INVOICE_CATEGORY, QuoteInvoiceTypeBE } from '../type';
1
+ import { QUOTE_INVOICE_CATEGORY, QuoteInvoiceBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  export interface ListQuoteInvoiceArgs {
4
4
  category: QUOTE_INVOICE_CATEGORY;
@@ -72,26 +72,26 @@ export interface DeleteQuoteInvoiceArgs {
72
72
  /**
73
73
  * Retrieves a paginated list of quotes/invoices
74
74
  * @param {ListQuoteInvoiceArgs} args - Object containing prisma client, pagination, filtering, and ordering options
75
- * @returns {Promise<[number, Array<QuoteInvoiceTypeBE>]>} Tuple containing total count and array of quotes/invoices
75
+ * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple containing total count and array of quotes/invoices
76
76
  */
77
- export declare const listQuoteInvoice: ({ category, currentPage, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListQuoteInvoiceArgs) => Promise<[number, Array<QuoteInvoiceTypeBE>]>;
77
+ export declare const listQuoteInvoice: ({ category, currentPage, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListQuoteInvoiceArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
78
78
  /**
79
79
  * Retrieves a single quote/invoice by its ID
80
80
  * @param {UnitQuoteInvoiceByIdArgs} args - Object containing prisma client, quote/invoice ID, and optional query parameters
81
- * @returns {Promise<QuoteInvoiceTypeBE | null>} Quote/invoice or null if not found
81
+ * @returns {Promise<QuoteInvoiceBE | null>} Quote/invoice or null if not found
82
82
  */
83
- export declare const unitQuoteInvoiceById: ({ id, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, prisma, }: UnitQuoteInvoiceByIdArgs) => Promise<QuoteInvoiceTypeBE | null>;
83
+ export declare const unitQuoteInvoiceById: ({ id, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, prisma, }: UnitQuoteInvoiceByIdArgs) => Promise<QuoteInvoiceBE | null>;
84
84
  /**
85
85
  * Creates or updates a quote/invoice
86
86
  * Handles complex business logic including customer/company associations and service management
87
87
  * @param {UpdateQuoteInvoiceArgs} args - Object containing prisma client, quote/invoice data, and optional query parameters
88
- * @returns {Promise<QuoteInvoiceTypeBE>} Created or updated quote/invoice
88
+ * @returns {Promise<QuoteInvoiceBE>} Created or updated quote/invoice
89
89
  */
90
- export declare const updateQuoteInvoice: ({ address, category, city, companyId, country, currency, customerId, date, discount, discountUnit, email, expiryDate, firstName, id, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, invoiceStatus, lastName, mode, note, phone, prisma, products, quoteStatus, ref, services, subTotal, taxRate, total, }: UpdateQuoteInvoiceArgs) => Promise<QuoteInvoiceTypeBE>;
90
+ export declare const updateQuoteInvoice: ({ address, category, city, companyId, country, currency, customerId, date, discount, discountUnit, email, expiryDate, firstName, id, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, invoiceStatus, lastName, mode, note, phone, prisma, products, quoteStatus, ref, services, subTotal, taxRate, total, }: UpdateQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
91
91
  /**
92
92
  * Deletes a quote/invoice by ID
93
93
  * @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client, quote/invoice ID, and optional query parameters
94
- * @returns {Promise<QuoteInvoiceTypeBE>} Deleted quote/invoice
94
+ * @returns {Promise<QuoteInvoiceBE>} Deleted quote/invoice
95
95
  */
96
- export declare const deleteQuoteInvoice: ({ id, prisma, }: DeleteQuoteInvoiceArgs) => Promise<QuoteInvoiceTypeBE>;
96
+ export declare const deleteQuoteInvoice: ({ id, prisma, }: DeleteQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
97
97
  export {};
@@ -61,7 +61,7 @@ var multi_part_search_1 = require("../../../general/multi-part-search");
61
61
  /**
62
62
  * Retrieves a paginated list of quotes/invoices
63
63
  * @param {ListQuoteInvoiceArgs} args - Object containing prisma client, pagination, filtering, and ordering options
64
- * @returns {Promise<[number, Array<QuoteInvoiceTypeBE>]>} Tuple containing total count and array of quotes/invoices
64
+ * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple containing total count and array of quotes/invoices
65
65
  */
66
66
  var listQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
67
67
  var include, orderBy, idSearchQuery, noteSearchQuery, refSearchQuery, where, _c, count, items;
@@ -124,7 +124,7 @@ exports.listQuoteInvoice = listQuoteInvoice;
124
124
  /**
125
125
  * Retrieves a single quote/invoice by its ID
126
126
  * @param {UnitQuoteInvoiceByIdArgs} args - Object containing prisma client, quote/invoice ID, and optional query parameters
127
- * @returns {Promise<QuoteInvoiceTypeBE | null>} Quote/invoice or null if not found
127
+ * @returns {Promise<QuoteInvoiceBE | null>} Quote/invoice or null if not found
128
128
  */
129
129
  var unitQuoteInvoiceById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
130
130
  var include, where, quoteInvoice;
@@ -160,7 +160,7 @@ exports.unitQuoteInvoiceById = unitQuoteInvoiceById;
160
160
  * Creates or updates a quote/invoice
161
161
  * Handles complex business logic including customer/company associations and service management
162
162
  * @param {UpdateQuoteInvoiceArgs} args - Object containing prisma client, quote/invoice data, and optional query parameters
163
- * @returns {Promise<QuoteInvoiceTypeBE>} Created or updated quote/invoice
163
+ * @returns {Promise<QuoteInvoiceBE>} Created or updated quote/invoice
164
164
  */
165
165
  var updateQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
166
166
  var include, quoteInvoice, mappedServices, where, foundQuoteInvoice, filteredEditServices, filteredCreateServices;
@@ -343,7 +343,7 @@ exports.updateQuoteInvoice = updateQuoteInvoice;
343
343
  /**
344
344
  * Deletes a quote/invoice by ID
345
345
  * @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client, quote/invoice ID, and optional query parameters
346
- * @returns {Promise<QuoteInvoiceTypeBE>} Deleted quote/invoice
346
+ * @returns {Promise<QuoteInvoiceBE>} Deleted quote/invoice
347
347
  */
348
348
  var deleteQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
349
349
  var where, quoteInvoice;
@@ -1,4 +1,4 @@
1
- import { QuoteInvoiceTypeBE } from '../type';
1
+ import { QuoteInvoiceBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  export interface PostQuotesInvoicesReportArgs {
4
4
  orderByColumn?: string;
@@ -9,7 +9,7 @@ export interface PostQuotesInvoicesReportArgs {
9
9
  * Generates a report of all quotes/invoices with sorting (no pagination)
10
10
  * Returns all records for reporting purposes
11
11
  * @param {PostQuotesInvoicesReportArgs} args - Object containing prisma client and sorting options
12
- * @returns {Promise<[number, Array<QuoteInvoiceTypeBE>]>} Tuple containing total count and array of all quotes/invoices
12
+ * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple containing total count and array of all quotes/invoices
13
13
  */
14
- export declare const postQuotesInvoicesReport: ({ orderByColumn, orderByDirection, prisma, }: PostQuotesInvoicesReportArgs) => Promise<[number, Array<QuoteInvoiceTypeBE>]>;
14
+ export declare const postQuotesInvoicesReport: ({ orderByColumn, orderByDirection, prisma, }: PostQuotesInvoicesReportArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
15
15
  export {};
@@ -41,7 +41,7 @@ exports.postQuotesInvoicesReport = void 0;
41
41
  * Generates a report of all quotes/invoices with sorting (no pagination)
42
42
  * Returns all records for reporting purposes
43
43
  * @param {PostQuotesInvoicesReportArgs} args - Object containing prisma client and sorting options
44
- * @returns {Promise<[number, Array<QuoteInvoiceTypeBE>]>} Tuple containing total count and array of all quotes/invoices
44
+ * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple containing total count and array of all quotes/invoices
45
45
  */
46
46
  var postQuotesInvoicesReport = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
47
47
  var include, orderBy, where, _c, count, items;
@@ -0,0 +1,97 @@
1
+ import { TaxBE } from '../type';
2
+ /**
3
+ * Synchronous utility function to get taxes from cache only
4
+ * Returns cached data immediately if available and fresh, otherwise returns empty array
5
+ * Does not trigger any API calls
6
+ *
7
+ * @returns TaxBE[] - Array of cached taxes or empty array wrapper ({count, items})
8
+ *
9
+ * @example
10
+ * const taxes = getCachedTaxesSync();
11
+ * if (taxes.items.length > 0) {
12
+ * console.log(taxes.items[0].taxName);
13
+ * }
14
+ */
15
+ export declare const getCachedTaxesSync: () => {
16
+ count: number;
17
+ items: TaxBE[];
18
+ };
19
+ /**
20
+ * Utility function to get taxes from cache or fetch from API
21
+ *
22
+ * This function manages a localStorage cache of taxes with the following logic:
23
+ * - If taxes exist in cache and are less than 1 week old, return cached version
24
+ * - If taxes exist but are older than 1 week, fetch fresh data and update cache
25
+ * - If taxes don't exist in cache, fetch from API and cache them
26
+ *
27
+ * @returns Promise<{count:number, items: TaxBE[]}> - Paged taxes
28
+ *
29
+ * @example
30
+ * const taxes = await getCachedTaxes();
31
+ * console.log(taxes.items[0].taxName);
32
+ */
33
+ export declare const getCachedTaxes: () => Promise<{
34
+ count: number;
35
+ items: TaxBE[];
36
+ }>;
37
+ /**
38
+ * Utility function to get a specific tax by ID from cache
39
+ * If not found in cache, returns null (does not trigger API call)
40
+ *
41
+ * @param taxId - The ID of the tax to retrieve
42
+ * @returns TaxBE | null - The tax or null if not found
43
+ *
44
+ * @example
45
+ * const tax = getCachedTaxById('tax-123');
46
+ * if (tax) {
47
+ * console.log(tax.taxName);
48
+ * }
49
+ */
50
+ export declare const getCachedTaxById: (taxId: string) => TaxBE | null;
51
+ /**
52
+ * Utility function to get taxes by name from cache
53
+ * If not found in cache, returns empty array (does not trigger API call)
54
+ *
55
+ * @param taxName - The name of the tax to search for
56
+ * @returns TaxBE[] - Array of matching taxes or empty array
57
+ *
58
+ * @example
59
+ * const taxes = getCachedTaxesByName('VAT');
60
+ * console.log(taxes.length);
61
+ */
62
+ export declare const getCachedTaxesByName: (taxName: string) => TaxBE[];
63
+ /**
64
+ * Utility function to invalidate (remove) taxes from cache
65
+ * Useful when taxes have been updated and you want to force a refresh
66
+ *
67
+ * @example
68
+ * invalidateTaxesCache();
69
+ * const freshTaxes = await getCachedTaxes();
70
+ */
71
+ export declare const invalidateTaxesCache: () => void;
72
+ /**
73
+ * Utility function to preload taxes into cache
74
+ * Useful to call on app initialization or login
75
+ *
76
+ * @returns Promise<{count:number, items: TaxBE[]}> - Array of preloaded taxes
77
+ *
78
+ * @example
79
+ * // On app initialization
80
+ * await preloadTaxes();
81
+ */
82
+ export declare const preloadTaxes: () => Promise<{
83
+ count: number;
84
+ items: TaxBE[];
85
+ }>;
86
+ /**
87
+ * Utility function to check if taxes cache is stale
88
+ * Returns true if cache is older than 1 week or doesn't exist
89
+ *
90
+ * @returns boolean - True if cache is stale or doesn't exist
91
+ *
92
+ * @example
93
+ * if (isTaxesCacheStale()) {
94
+ * await getCachedTaxes(); // This will fetch fresh data
95
+ * }
96
+ */
97
+ export declare const isTaxesCacheStale: () => boolean;
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.isTaxesCacheStale = exports.preloadTaxes = exports.invalidateTaxesCache = exports.getCachedTaxesByName = exports.getCachedTaxById = exports.getCachedTaxes = exports.getCachedTaxesSync = void 0;
40
+ var constants_1 = require("../constants");
41
+ var type_1 = require("../type");
42
+ var api_methods_1 = require("../../../constants/api-methods");
43
+ var fetch_data_1 = require("../../../general/fetch-data");
44
+ var get_storage_value_1 = require("../../../local-storage/get-storage-value");
45
+ var set_storage_value_1 = require("../../../local-storage/set-storage-value");
46
+ /**
47
+ * Synchronous utility function to get taxes from cache only
48
+ * Returns cached data immediately if available and fresh, otherwise returns empty array
49
+ * Does not trigger any API calls
50
+ *
51
+ * @returns TaxBE[] - Array of cached taxes or empty array wrapper ({count, items})
52
+ *
53
+ * @example
54
+ * const taxes = getCachedTaxesSync();
55
+ * if (taxes.items.length > 0) {
56
+ * console.log(taxes.items[0].taxName);
57
+ * }
58
+ */
59
+ var getCachedTaxesSync = function () {
60
+ try {
61
+ var cachedData = (0, get_storage_value_1.getStorageValue)(type_1.LS_KEYS.TAXES);
62
+ if (!cachedData) {
63
+ return { count: 0, items: [] };
64
+ }
65
+ var currentTime = new Date().getTime();
66
+ var cachedTime = new Date(cachedData.cachedAt).getTime();
67
+ var ageInMs = currentTime - cachedTime;
68
+ // If cached data is less than 1 week old, return it
69
+ if (ageInMs < constants_1.ONE_WEEK_IN_MS) {
70
+ return {
71
+ count: cachedData.taxes.length,
72
+ items: cachedData.taxes,
73
+ };
74
+ }
75
+ return { count: 0, items: [] };
76
+ }
77
+ catch (error) {
78
+ console.error('Error getting cached taxes:', error);
79
+ return { count: 0, items: [] };
80
+ }
81
+ };
82
+ exports.getCachedTaxesSync = getCachedTaxesSync;
83
+ /**
84
+ * Utility function to get taxes from cache or fetch from API
85
+ *
86
+ * This function manages a localStorage cache of taxes with the following logic:
87
+ * - If taxes exist in cache and are less than 1 week old, return cached version
88
+ * - If taxes exist but are older than 1 week, fetch fresh data and update cache
89
+ * - If taxes don't exist in cache, fetch from API and cache them
90
+ *
91
+ * @returns Promise<{count:number, items: TaxBE[]}> - Paged taxes
92
+ *
93
+ * @example
94
+ * const taxes = await getCachedTaxes();
95
+ * console.log(taxes.items[0].taxName);
96
+ */
97
+ var getCachedTaxes = function () { return __awaiter(void 0, void 0, void 0, function () {
98
+ var cachedData, currentTime, cachedTime, ageInMs, response, updatedCache, error_1;
99
+ var _a;
100
+ return __generator(this, function (_b) {
101
+ switch (_b.label) {
102
+ case 0:
103
+ _b.trys.push([0, 2, , 3]);
104
+ cachedData = (0, get_storage_value_1.getStorageValue)(type_1.LS_KEYS.TAXES);
105
+ currentTime = new Date().getTime();
106
+ // Check if cached data exists and is still fresh
107
+ if (cachedData) {
108
+ cachedTime = new Date(cachedData.cachedAt).getTime();
109
+ ageInMs = currentTime - cachedTime;
110
+ // If cached data is less than 1 week old, return it
111
+ if (ageInMs < constants_1.ONE_WEEK_IN_MS) {
112
+ return [2 /*return*/, {
113
+ count: cachedData.taxes.length,
114
+ items: cachedData.taxes,
115
+ }];
116
+ }
117
+ }
118
+ return [4 /*yield*/, (0, fetch_data_1.fetchData)({
119
+ url: constants_1.API_ROUTES.TAXES,
120
+ method: api_methods_1.API_METHODS.GET,
121
+ })];
122
+ case 1:
123
+ response = _b.sent();
124
+ if ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.items) {
125
+ updatedCache = {
126
+ taxes: response.data.items,
127
+ cachedAt: new Date().toISOString(),
128
+ };
129
+ (0, set_storage_value_1.setStorageValue)(type_1.LS_KEYS.TAXES, updatedCache);
130
+ return [2 /*return*/, response.data];
131
+ }
132
+ return [2 /*return*/, { count: 0, items: [] }];
133
+ case 2:
134
+ error_1 = _b.sent();
135
+ console.error('Error fetching taxes:', error_1);
136
+ return [2 /*return*/, { count: 0, items: [] }];
137
+ case 3: return [2 /*return*/];
138
+ }
139
+ });
140
+ }); };
141
+ exports.getCachedTaxes = getCachedTaxes;
142
+ /**
143
+ * Utility function to get a specific tax by ID from cache
144
+ * If not found in cache, returns null (does not trigger API call)
145
+ *
146
+ * @param taxId - The ID of the tax to retrieve
147
+ * @returns TaxBE | null - The tax or null if not found
148
+ *
149
+ * @example
150
+ * const tax = getCachedTaxById('tax-123');
151
+ * if (tax) {
152
+ * console.log(tax.taxName);
153
+ * }
154
+ */
155
+ var getCachedTaxById = function (taxId) {
156
+ if (!taxId) {
157
+ return null;
158
+ }
159
+ try {
160
+ var taxes = (0, exports.getCachedTaxesSync)().items;
161
+ return taxes.find(function (tax) { return tax.id === taxId; }) || null;
162
+ }
163
+ catch (error) {
164
+ console.error('Error getting cached tax by ID:', error);
165
+ return null;
166
+ }
167
+ };
168
+ exports.getCachedTaxById = getCachedTaxById;
169
+ /**
170
+ * Utility function to get taxes by name from cache
171
+ * If not found in cache, returns empty array (does not trigger API call)
172
+ *
173
+ * @param taxName - The name of the tax to search for
174
+ * @returns TaxBE[] - Array of matching taxes or empty array
175
+ *
176
+ * @example
177
+ * const taxes = getCachedTaxesByName('VAT');
178
+ * console.log(taxes.length);
179
+ */
180
+ var getCachedTaxesByName = function (taxName) {
181
+ if (!taxName) {
182
+ return [];
183
+ }
184
+ try {
185
+ var taxes = (0, exports.getCachedTaxesSync)().items;
186
+ return taxes.filter(function (tax) {
187
+ return tax.taxName.toLowerCase().includes(taxName.toLowerCase());
188
+ });
189
+ }
190
+ catch (error) {
191
+ console.error('Error getting cached taxes by name:', error);
192
+ return [];
193
+ }
194
+ };
195
+ exports.getCachedTaxesByName = getCachedTaxesByName;
196
+ /**
197
+ * Utility function to invalidate (remove) taxes from cache
198
+ * Useful when taxes have been updated and you want to force a refresh
199
+ *
200
+ * @example
201
+ * invalidateTaxesCache();
202
+ * const freshTaxes = await getCachedTaxes();
203
+ */
204
+ var invalidateTaxesCache = function () {
205
+ try {
206
+ localStorage.removeItem(type_1.LS_KEYS.TAXES);
207
+ }
208
+ catch (error) {
209
+ console.error('Error invalidating taxes cache:', error);
210
+ }
211
+ };
212
+ exports.invalidateTaxesCache = invalidateTaxesCache;
213
+ /**
214
+ * Utility function to preload taxes into cache
215
+ * Useful to call on app initialization or login
216
+ *
217
+ * @returns Promise<{count:number, items: TaxBE[]}> - Array of preloaded taxes
218
+ *
219
+ * @example
220
+ * // On app initialization
221
+ * await preloadTaxes();
222
+ */
223
+ var preloadTaxes = function () { return __awaiter(void 0, void 0, void 0, function () {
224
+ return __generator(this, function (_a) {
225
+ return [2 /*return*/, (0, exports.getCachedTaxes)()];
226
+ });
227
+ }); };
228
+ exports.preloadTaxes = preloadTaxes;
229
+ /**
230
+ * Utility function to check if taxes cache is stale
231
+ * Returns true if cache is older than 1 week or doesn't exist
232
+ *
233
+ * @returns boolean - True if cache is stale or doesn't exist
234
+ *
235
+ * @example
236
+ * if (isTaxesCacheStale()) {
237
+ * await getCachedTaxes(); // This will fetch fresh data
238
+ * }
239
+ */
240
+ var isTaxesCacheStale = function () {
241
+ try {
242
+ var cachedData = (0, get_storage_value_1.getStorageValue)(type_1.LS_KEYS.TAXES);
243
+ if (!cachedData) {
244
+ return true;
245
+ }
246
+ var currentTime = new Date().getTime();
247
+ var cachedTime = new Date(cachedData.cachedAt).getTime();
248
+ var ageInMs = currentTime - cachedTime;
249
+ return ageInMs >= constants_1.ONE_WEEK_IN_MS;
250
+ }
251
+ catch (error) {
252
+ console.error('Error checking taxes cache staleness:', error);
253
+ return true;
254
+ }
255
+ };
256
+ exports.isTaxesCacheStale = isTaxesCacheStale;
@@ -1,4 +1,5 @@
1
- import { TaxTypeBE } from '../type';
1
+ export * from './cache';
2
+ import { TaxBE } from '../type';
2
3
  type PrismaClient = any;
3
4
  export interface ListTaxArgs {
4
5
  currentPage?: number;
@@ -31,25 +32,24 @@ export interface DeleteTaxArgs {
31
32
  /**
32
33
  * Retrieves a paginated list of taxes
33
34
  * @param {ListTaxArgs} args - Object containing prisma client, pagination, filtering, and ordering options
34
- * @returns {Promise<[number, Array<TaxTypeBE>]>} Tuple containing total count and array of taxes
35
+ * @returns {Promise<[number, Array<TaxBE>]>} Tuple containing total count and array of taxes
35
36
  */
36
- export declare const listTax: ({ currentPage, includePreference, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListTaxArgs) => Promise<[number, Array<TaxTypeBE>]>;
37
+ export declare const listTax: ({ currentPage, includePreference, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListTaxArgs) => Promise<[number, Array<TaxBE>]>;
37
38
  /**
38
39
  * Retrieves a single tax by its ID
39
40
  * @param {UnitTaxByIdArgs} args - Object containing prisma client, tax ID, and optional query parameters
40
- * @returns {Promise<TaxTypeBE | null>} Tax or null if not found
41
+ * @returns {Promise<TaxBE | null>} Tax or null if not found
41
42
  */
42
- export declare const unitTaxById: ({ id, includePreference, prisma, }: UnitTaxByIdArgs) => Promise<TaxTypeBE | null>;
43
+ export declare const unitTaxById: ({ id, includePreference, prisma, }: UnitTaxByIdArgs) => Promise<TaxBE | null>;
43
44
  /**
44
45
  * Creates or updates a tax
45
46
  * @param {UpdateTaxArgs} args - Object containing prisma client, tax data, and optional query parameters
46
- * @returns {Promise<TaxTypeBE>} Created or updated tax
47
+ * @returns {Promise<TaxBE>} Created or updated tax
47
48
  */
48
- export declare const updateTax: ({ description, enabled, id, isDefault, preferenceId, prisma, taxName, taxRate, }: UpdateTaxArgs) => Promise<TaxTypeBE>;
49
+ export declare const updateTax: ({ description, enabled, id, isDefault, preferenceId, prisma, taxName, taxRate, }: UpdateTaxArgs) => Promise<TaxBE>;
49
50
  /**
50
51
  * Deletes a tax by ID
51
52
  * @param {DeleteTaxArgs} args - Object containing prisma client, tax ID, and optional query parameters
52
- * @returns {Promise<TaxTypeBE>} Deleted tax
53
+ * @returns {Promise<TaxBE>} Deleted tax
53
54
  */
54
- export declare const deleteTax: ({ id, prisma, }: DeleteTaxArgs) => Promise<TaxTypeBE>;
55
- export {};
55
+ export declare const deleteTax: ({ id, prisma, }: DeleteTaxArgs) => Promise<TaxBE>;