@managesome/eposmatic-toolkit 0.4.76 → 0.4.78

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 (34) hide show
  1. package/esm/constants/ENUMS.js +1 -0
  2. package/esm/constants/enums/customer.js +5 -0
  3. package/esm/helpers/order/generate-warehouse-purchase-order.js +4 -0
  4. package/esm/helpers/store/common-tenant-purchase-order-actions.js +1 -0
  5. package/esm/helpers/store/common-warehouse-purchase-order-actions.js +1 -0
  6. package/esm/helpers/store/tenant-purchase-orders-cart-actions.js +14 -1
  7. package/esm/helpers/store/warehouse-purchase-orders-cart-actions.js +16 -2
  8. package/esm/helpers/utils/warehouse-purchase-order-x-report-helpers.js +5 -2
  9. package/esm/schemas/models/customers.js +0 -5
  10. package/esm/schemas/models/tenant_purchase_orders.js +3 -0
  11. package/esm/schemas/models/warehouse_purchase_orders.js +9 -0
  12. package/lib/constants/ENUMS.d.ts +1 -0
  13. package/lib/constants/ENUMS.js +1 -0
  14. package/lib/constants/WAREHOUSE_ANALYTICS.d.ts +1 -0
  15. package/lib/constants/enums/customer.d.ts +4 -0
  16. package/lib/constants/enums/customer.js +8 -0
  17. package/lib/helpers/order/generate-warehouse-purchase-order.js +4 -0
  18. package/lib/helpers/store/common-tenant-purchase-order-actions.js +1 -0
  19. package/lib/helpers/store/common-warehouse-purchase-order-actions.js +1 -0
  20. package/lib/helpers/store/tenant-purchase-orders-cart-actions.js +14 -1
  21. package/lib/helpers/store/warehouse-purchase-orders-cart-actions.d.ts +1 -0
  22. package/lib/helpers/store/warehouse-purchase-orders-cart-actions.js +16 -2
  23. package/lib/helpers/types/api-types.d.ts +13 -33
  24. package/lib/helpers/types/email-templates.d.ts +1 -1
  25. package/lib/helpers/utils/warehouse-purchase-order-x-report-helpers.js +5 -2
  26. package/lib/schemas/models/customers.d.ts +0 -5
  27. package/lib/schemas/models/customers.js +0 -5
  28. package/lib/schemas/models/tenant_purchase_orders.d.ts +12 -0
  29. package/lib/schemas/models/tenant_purchase_orders.js +3 -0
  30. package/lib/schemas/models/warehouse_purchase_orders.d.ts +12 -0
  31. package/lib/schemas/models/warehouse_purchase_orders.js +9 -0
  32. package/lib/schemas/types/tenant_purchase_orders.d.ts +1 -0
  33. package/lib/schemas/types/warehouse_purchase_orders.d.ts +1 -0
  34. package/package.json +1 -1
@@ -3,6 +3,7 @@
3
3
  export * from './enums/accounting';
4
4
  export * from './enums/cash';
5
5
  export * from './enums/communications';
6
+ export * from './enums/customer';
6
7
  export * from './enums/delivery';
7
8
  export * from './enums/geo';
8
9
  export * from './enums/hr';
@@ -0,0 +1,5 @@
1
+ export var CUSTOMER_EMAIL_LOGIN_STATUS_ENUM;
2
+ (function (CUSTOMER_EMAIL_LOGIN_STATUS_ENUM) {
3
+ CUSTOMER_EMAIL_LOGIN_STATUS_ENUM["LOGGED_IN"] = "logged_in";
4
+ CUSTOMER_EMAIL_LOGIN_STATUS_ENUM["NEEDS_PHONE"] = "needs_phone";
5
+ })(CUSTOMER_EMAIL_LOGIN_STATUS_ENUM || (CUSTOMER_EMAIL_LOGIN_STATUS_ENUM = {}));
@@ -19,6 +19,7 @@ function getCommonOptionalBoolFieldsPurchaseOrderIteration(order, partial) {
19
19
  return {
20
20
  is_gst_inclusive: order.is_gst_inclusive || defaultValue,
21
21
  exclude_discount_from_gst: order.exclude_discount_from_gst || defaultValue,
22
+ is_gst_percentage: order.is_gst_percentage ?? (partial ? undefined : true),
22
23
  };
23
24
  }
24
25
  function getCommonOptionalNumFieldsPurchaseOrderIteration(order, partial) {
@@ -100,6 +101,7 @@ export function generateWarehousePurchaseOrderOnCreate(order, withIterations) {
100
101
  delete newOrder.gst;
101
102
  delete newOrder.gst_amount;
102
103
  delete newOrder.is_gst_inclusive;
104
+ delete newOrder.is_gst_percentage;
103
105
  }
104
106
  else {
105
107
  if (newOrder.gst_amount === 0) {
@@ -160,8 +162,10 @@ export function generateWarehousePurchaseOrderOnUpdate(partialUpdatedOrder) {
160
162
  if (set.gst === 0) {
161
163
  delete set.gst;
162
164
  delete set.gst_amount;
165
+ delete set.is_gst_percentage;
163
166
  unset['gst'] = '';
164
167
  unset['gst_amount'] = '';
168
+ unset['is_gst_percentage'] = '';
165
169
  }
166
170
  else {
167
171
  if (set.gst_amount === 0) {
@@ -142,6 +142,7 @@ function getCommonOptionalBoolFieldsTenantPurchaseOrder(order, partial) {
142
142
  is_gst_inclusive: order['is_gst_inclusive'] || defaultValue,
143
143
  is_reopened: order['is_reopened'] || defaultValue,
144
144
  exclude_discount_from_gst: order['exclude_discount_from_gst'] || defaultValue,
145
+ is_gst_percentage: order['is_gst_percentage'] ?? (partial ? undefined : true),
145
146
  };
146
147
  }
147
148
  function getCommonOptionalNumFieldsTenantPurchaseOrder(order, partial) {
@@ -146,6 +146,7 @@ function getCommonOptionalBoolFieldsPurchaseOrder(order, partial) {
146
146
  return {
147
147
  is_gst_inclusive: order['is_gst_inclusive'] || defaultValue,
148
148
  is_reopened: order['is_reopened'] || defaultValue,
149
+ is_gst_percentage: order['is_gst_percentage'] ?? (partial ? undefined : true),
149
150
  };
150
151
  }
151
152
  function getCommonOptionalNumFieldsPurchaseOrder(order, partial) {
@@ -89,7 +89,20 @@ export function calculateCartTenantPurchaseOrderInfoAndSyncData(data, calculateI
89
89
  }
90
90
  let gst_amount = 0;
91
91
  const gst = data.gst ?? 0;
92
- if (data.is_gst_inclusive) {
92
+ const isGstPercentage = data.is_gst_percentage !== false;
93
+ if (!isGstPercentage) {
94
+ // Fixed amount. Inclusive means the tax is already contained in the
95
+ // prices, so the total does not change and the tax can never exceed it.
96
+ const fixedGst = parseNum(Math.max(0, gst));
97
+ if (data.is_gst_inclusive) {
98
+ gst_amount = Math.min(fixedGst, Math.max(0, grand_total));
99
+ }
100
+ else {
101
+ gst_amount = fixedGst;
102
+ grand_total += fixedGst;
103
+ }
104
+ }
105
+ else if (data.is_gst_inclusive) {
93
106
  gst_amount = parseFloatCeil((grand_total * gst) / (100 + gst));
94
107
  }
95
108
  else {
@@ -84,10 +84,24 @@ export function calculateCartWarehousePurchaseOrderInfoAndSyncData(data, calcula
84
84
  if (!applyGSTOnOriginalPrice) {
85
85
  grand_total -= total_discount_applied;
86
86
  }
87
- // GST is represented in percentage. We convert it to decimal
87
+ // GST can be entered as a percentage (default) or as a fixed amount.
88
+ // In both cases `gst_amount` is the computed tax total.
88
89
  let gst_amount = 0;
89
90
  const gst = data.gst ?? 0;
90
- if (data.is_gst_inclusive) {
91
+ const isGstPercentage = data.is_gst_percentage !== false;
92
+ if (!isGstPercentage) {
93
+ // Fixed amount. Inclusive means the tax is already contained in the
94
+ // prices, so the total does not change and the tax can never exceed it.
95
+ const fixedGst = parseNum(Math.max(0, gst));
96
+ if (data.is_gst_inclusive) {
97
+ gst_amount = Math.min(fixedGst, Math.max(0, grand_total));
98
+ }
99
+ else {
100
+ gst_amount = fixedGst;
101
+ grand_total += fixedGst;
102
+ }
103
+ }
104
+ else if (data.is_gst_inclusive) {
91
105
  // If GST is inclusive, it means that the Tax is already included in the Sale Value
92
106
  // However, we need to calculate the Sale Value without the Tax
93
107
  // And then calculate the Tax amount from the Sale Value without Tax
@@ -1190,15 +1190,18 @@ const generateVendorWiseData = (data, currencySymbol, gstName) => {
1190
1190
  const vendorId = item.vendor_id ?? VENDOR_ID;
1191
1191
  const vendorName = vendorNamesMap[vendorId];
1192
1192
  if (vendorName != null) {
1193
+ const isGstPercentage = item.is_gst_percentage !== false;
1194
+ // For percentage rows `gst` is a rate, for fixed rows it is the tax amount.
1193
1195
  const gst = convertIntToDecimal(item.gst);
1194
1196
  const amount = item.grossAmount;
1195
1197
  const obj = {
1196
1198
  _id: vendorId,
1197
- ref: gst,
1199
+ // Keep percentage and fixed rows with the same numeric value apart.
1200
+ ref: `${isGstPercentage ? 'pct' : 'amt'}:${gst}`,
1198
1201
  type: WAREHOUSE_PURCHASE_ORDER_X_REPORT_TYPE_ENUM.GST,
1199
1202
  staff_name: vendorName,
1200
1203
  title: gstName,
1201
- description: `${gst}%`,
1204
+ description: isGstPercentage ? `${gst}%` : `Fixed ${localeAmount(currencySymbol, gst)}`,
1202
1205
  count: item.count,
1203
1206
  amount,
1204
1207
  sortIndex: 4,
@@ -220,7 +220,6 @@ export const CUSTOMER_COLLECTION_NAME = 'customers';
220
220
  * - `_id`: unique primary key.
221
221
  * - `brand_id__phone_number`: per-brand customer lookups by phone number.
222
222
  * - `brand_id__email`: per-brand customer lookups by email (email/Google login).
223
- * - `brand_id__uid`: per-brand customer lookups by Firebase uid.
224
223
  * - `brand_id__createdAt`: per-brand customer lookups newest first.
225
224
  * - `brand_id__total_spent`: per-brand customer lookups by total spent.
226
225
  * - `brand_id__total_orders`: per-brand customer lookups by total orders.
@@ -240,10 +239,6 @@ export const CUSTOMER_COLLECTION_INDEXES = {
240
239
  brand_id: 1,
241
240
  email: 1,
242
241
  }, // per-brand customer lookups by email (email login / account resolution)
243
- brand_id__uid: {
244
- brand_id: 1,
245
- uid: 1,
246
- }, // per-brand customer lookups by Firebase uid
247
242
  brand_id__createdAt: {
248
243
  brand_id: 1,
249
244
  createdAt: -1,
@@ -92,6 +92,7 @@ const IterationsOrderSchema = new Schema({
92
92
  gst: { type: Number, min: 0, required: false },
93
93
  gst_amount: { type: Number, min: 0, required: false },
94
94
  is_gst_inclusive: { type: Boolean, required: false },
95
+ is_gst_percentage: { type: Boolean, required: false },
95
96
  tax_number: { type: String, default: '' },
96
97
  updatedAt: { type: Schema.Types.Date, required: true },
97
98
  }, { _id: false, timestamps: false, versionKey: false });
@@ -131,6 +132,8 @@ export const TenantPurchaseOrderSchema = new Schema({
131
132
  gst: { type: Number, min: 0, required: false },
132
133
  gst_amount: { type: Number, min: 0, required: false },
133
134
  is_gst_inclusive: { type: Boolean, required: false },
135
+ // true/undefined => `gst` is a percentage, false => `gst` is a fixed amount
136
+ is_gst_percentage: { type: Boolean, required: false },
134
137
  is_deleted: { type: Boolean, default: false },
135
138
  order_status_updated_at: {
136
139
  type: Schema.Types.Date,
@@ -199,6 +199,10 @@ const IterationsOrderSchema = new Schema({
199
199
  type: Boolean,
200
200
  required: false,
201
201
  },
202
+ is_gst_percentage: {
203
+ type: Boolean,
204
+ required: false,
205
+ },
202
206
  tax_number: {
203
207
  type: String,
204
208
  default: '',
@@ -327,6 +331,11 @@ export const PurchaseOrderSchema = new Schema({
327
331
  type: Boolean,
328
332
  required: false,
329
333
  },
334
+ // true/undefined => `gst` is a percentage, false => `gst` is a fixed amount
335
+ is_gst_percentage: {
336
+ type: Boolean,
337
+ required: false,
338
+ },
330
339
  //
331
340
  is_deleted: {
332
341
  type: Boolean,
@@ -1,6 +1,7 @@
1
1
  export * from './enums/accounting';
2
2
  export * from './enums/cash';
3
3
  export * from './enums/communications';
4
+ export * from './enums/customer';
4
5
  export * from './enums/delivery';
5
6
  export * from './enums/geo';
6
7
  export * from './enums/hr';
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  __exportStar(require("./enums/accounting"), exports);
20
20
  __exportStar(require("./enums/cash"), exports);
21
21
  __exportStar(require("./enums/communications"), exports);
22
+ __exportStar(require("./enums/customer"), exports);
22
23
  __exportStar(require("./enums/delivery"), exports);
23
24
  __exportStar(require("./enums/geo"), exports);
24
25
  __exportStar(require("./enums/hr"), exports);
@@ -179,6 +179,7 @@ export interface IWarehousePurchaseOrderXReport {
179
179
  count: number;
180
180
  grossAmount: number;
181
181
  gst: number;
182
+ is_gst_percentage?: boolean;
182
183
  vendor_id: string;
183
184
  }[];
184
185
  [WAREHOUSE_PURCHASE_ORDER_X_REPORT_TYPE_ENUM.TOTAL_PAYMENT_SALES]: {
@@ -0,0 +1,4 @@
1
+ export declare enum CUSTOMER_EMAIL_LOGIN_STATUS_ENUM {
2
+ LOGGED_IN = "logged_in",
3
+ NEEDS_PHONE = "needs_phone"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CUSTOMER_EMAIL_LOGIN_STATUS_ENUM = void 0;
4
+ var CUSTOMER_EMAIL_LOGIN_STATUS_ENUM;
5
+ (function (CUSTOMER_EMAIL_LOGIN_STATUS_ENUM) {
6
+ CUSTOMER_EMAIL_LOGIN_STATUS_ENUM["LOGGED_IN"] = "logged_in";
7
+ CUSTOMER_EMAIL_LOGIN_STATUS_ENUM["NEEDS_PHONE"] = "needs_phone";
8
+ })(CUSTOMER_EMAIL_LOGIN_STATUS_ENUM || (exports.CUSTOMER_EMAIL_LOGIN_STATUS_ENUM = CUSTOMER_EMAIL_LOGIN_STATUS_ENUM = {}));
@@ -28,6 +28,7 @@ function getCommonOptionalBoolFieldsPurchaseOrderIteration(order, partial) {
28
28
  return {
29
29
  is_gst_inclusive: order.is_gst_inclusive || defaultValue,
30
30
  exclude_discount_from_gst: order.exclude_discount_from_gst || defaultValue,
31
+ is_gst_percentage: order.is_gst_percentage ?? (partial ? undefined : true),
31
32
  };
32
33
  }
33
34
  function getCommonOptionalNumFieldsPurchaseOrderIteration(order, partial) {
@@ -109,6 +110,7 @@ function generateWarehousePurchaseOrderOnCreate(order, withIterations) {
109
110
  delete newOrder.gst;
110
111
  delete newOrder.gst_amount;
111
112
  delete newOrder.is_gst_inclusive;
113
+ delete newOrder.is_gst_percentage;
112
114
  }
113
115
  else {
114
116
  if (newOrder.gst_amount === 0) {
@@ -169,8 +171,10 @@ function generateWarehousePurchaseOrderOnUpdate(partialUpdatedOrder) {
169
171
  if (set.gst === 0) {
170
172
  delete set.gst;
171
173
  delete set.gst_amount;
174
+ delete set.is_gst_percentage;
172
175
  unset['gst'] = '';
173
176
  unset['gst_amount'] = '';
177
+ unset['is_gst_percentage'] = '';
174
178
  }
175
179
  else {
176
180
  if (set.gst_amount === 0) {
@@ -159,6 +159,7 @@ function getCommonOptionalBoolFieldsTenantPurchaseOrder(order, partial) {
159
159
  is_gst_inclusive: order['is_gst_inclusive'] || defaultValue,
160
160
  is_reopened: order['is_reopened'] || defaultValue,
161
161
  exclude_discount_from_gst: order['exclude_discount_from_gst'] || defaultValue,
162
+ is_gst_percentage: order['is_gst_percentage'] ?? (partial ? undefined : true),
162
163
  };
163
164
  }
164
165
  function getCommonOptionalNumFieldsTenantPurchaseOrder(order, partial) {
@@ -162,6 +162,7 @@ function getCommonOptionalBoolFieldsPurchaseOrder(order, partial) {
162
162
  return {
163
163
  is_gst_inclusive: order['is_gst_inclusive'] || defaultValue,
164
164
  is_reopened: order['is_reopened'] || defaultValue,
165
+ is_gst_percentage: order['is_gst_percentage'] ?? (partial ? undefined : true),
165
166
  };
166
167
  }
167
168
  function getCommonOptionalNumFieldsPurchaseOrder(order, partial) {
@@ -105,7 +105,20 @@ function calculateCartTenantPurchaseOrderInfoAndSyncData(data, calculateItemMeta
105
105
  }
106
106
  let gst_amount = 0;
107
107
  const gst = data.gst ?? 0;
108
- if (data.is_gst_inclusive) {
108
+ const isGstPercentage = data.is_gst_percentage !== false;
109
+ if (!isGstPercentage) {
110
+ // Fixed amount. Inclusive means the tax is already contained in the
111
+ // prices, so the total does not change and the tax can never exceed it.
112
+ const fixedGst = (0, utils_1.parseNum)(Math.max(0, gst));
113
+ if (data.is_gst_inclusive) {
114
+ gst_amount = Math.min(fixedGst, Math.max(0, grand_total));
115
+ }
116
+ else {
117
+ gst_amount = fixedGst;
118
+ grand_total += fixedGst;
119
+ }
120
+ }
121
+ else if (data.is_gst_inclusive) {
109
122
  gst_amount = (0, utils_1.parseFloatCeil)((grand_total * gst) / (100 + gst));
110
123
  }
111
124
  else {
@@ -29,6 +29,7 @@ export declare function getUpdatedWarehousePurchaseOrderCartInfoOnInit(data: Par
29
29
  categories?: IWarehousePurchaseOrderCategory[] | undefined;
30
30
  staff_details?: import("../../schemas").IStaffDetails | undefined;
31
31
  is_gst_inclusive?: boolean;
32
+ is_gst_percentage?: boolean;
32
33
  gst?: number | null;
33
34
  gst_amount?: number | null;
34
35
  special_instructions?: string | undefined;
@@ -100,10 +100,24 @@ function calculateCartWarehousePurchaseOrderInfoAndSyncData(data, calculateItemM
100
100
  if (!applyGSTOnOriginalPrice) {
101
101
  grand_total -= total_discount_applied;
102
102
  }
103
- // GST is represented in percentage. We convert it to decimal
103
+ // GST can be entered as a percentage (default) or as a fixed amount.
104
+ // In both cases `gst_amount` is the computed tax total.
104
105
  let gst_amount = 0;
105
106
  const gst = data.gst ?? 0;
106
- if (data.is_gst_inclusive) {
107
+ const isGstPercentage = data.is_gst_percentage !== false;
108
+ if (!isGstPercentage) {
109
+ // Fixed amount. Inclusive means the tax is already contained in the
110
+ // prices, so the total does not change and the tax can never exceed it.
111
+ const fixedGst = (0, utils_1.parseNum)(Math.max(0, gst));
112
+ if (data.is_gst_inclusive) {
113
+ gst_amount = Math.min(fixedGst, Math.max(0, grand_total));
114
+ }
115
+ else {
116
+ gst_amount = fixedGst;
117
+ grand_total += fixedGst;
118
+ }
119
+ }
120
+ else if (data.is_gst_inclusive) {
107
121
  // If GST is inclusive, it means that the Tax is already included in the Sale Value
108
122
  // However, we need to calculate the Sale Value without the Tax
109
123
  // And then calculate the Tax amount from the Sale Value without Tax
@@ -1,5 +1,5 @@
1
+ import { CUSTOMER_EMAIL_LOGIN_STATUS_ENUM } from '../../constants/enums/customer';
1
2
  import { CUSTOMER_TARGET_MODE_ENUM, DIALER_TYPES_ENUM, WALLET_ASSET_TYPE_ENUM, WALLET_ASSIGNMENT_BEHAVIOR_ENUM } from '../../constants';
2
- import { ICustomer } from '../../schemas/types/customers';
3
3
  /**
4
4
  * Request/response contracts for backend service APIs, shared between apps and
5
5
  * services (items-service, POS frontends, provider integrations).
@@ -311,37 +311,17 @@ export interface IGoogleMapsRouteResponse {
311
311
  distanceMeters: number;
312
312
  }
313
313
  /**
314
- * Response for `GET /customer-auth/session` (items-service).
314
+ * Response for `POST /email/auth/verify-otp` (items-service).
315
315
  *
316
- * `uid` is the session's Firebase uid. When an email/Google credential maps to
317
- * a phone-verified account, the backend returns `canonical_token`; signing in
318
- * with it switches the session to that uid before wallet data is read.
319
- * `needs_phone` is true when the account has no customer record yet.
316
+ * - `logged_in`: the brand customer already proves both the email and the
317
+ * phone; `custom_token` opens the phone user's Firebase session.
318
+ * - `needs_phone`: verify the phone through the existing OTP flow, then
319
+ * exchange `email_proof` at `POST /email/auth/link-email`.
320
320
  */
321
- export interface ICustomerAccountSessionResponse {
322
- uid: string;
323
- email: string | null;
324
- email_verified: boolean;
325
- phone_number: string | null;
326
- phone_verified: boolean;
327
- needs_phone: boolean;
328
- customer: ICustomer | null;
329
- canonical_token: string | null;
330
- }
331
- /**
332
- * Outcome of `POST /customer-auth/link-phone` (items-service).
333
- *
334
- * - `created`: the phone was free and a new unverified row was created.
335
- * - `linked`: the row already belonged to this identity.
336
- * - `requires_otp`: an unverified row owned by someone else; send a code via
337
- * `/wa/auth/send-otp` or `/sms/auth/send-otp`, then call again with `otp`.
338
- * - `conflict`: a verified row owned by another account.
339
- * - `verified`: the submitted `otp` was accepted and the phone now belongs to
340
- * this account.
341
- */
342
- export type TCustomerPhoneLinkStatus = 'created' | 'linked' | 'requires_otp' | 'conflict' | 'verified';
343
- export interface ICustomerPhoneLinkResponse {
344
- status: TCustomerPhoneLinkStatus;
345
- phone_number_verified: boolean;
346
- customer?: ICustomer | null;
347
- }
321
+ export type TCustomerEmailLoginResponse = {
322
+ status: CUSTOMER_EMAIL_LOGIN_STATUS_ENUM.LOGGED_IN;
323
+ custom_token: string;
324
+ } | {
325
+ status: CUSTOMER_EMAIL_LOGIN_STATUS_ENUM.NEEDS_PHONE;
326
+ email_proof: string;
327
+ };
@@ -246,7 +246,7 @@ export interface IEmailTemplateForOTP {
246
246
  brand_name: string;
247
247
  brand_logo_url: string;
248
248
  header_color: string;
249
- footer_color: string;
249
+ theme_contrast: string;
250
250
  user_name: string;
251
251
  user_email: string;
252
252
  otp_code: string;
@@ -1197,15 +1197,18 @@ const generateVendorWiseData = (data, currencySymbol, gstName) => {
1197
1197
  const vendorId = item.vendor_id ?? VENDOR_ID;
1198
1198
  const vendorName = vendorNamesMap[vendorId];
1199
1199
  if (vendorName != null) {
1200
+ const isGstPercentage = item.is_gst_percentage !== false;
1201
+ // For percentage rows `gst` is a rate, for fixed rows it is the tax amount.
1200
1202
  const gst = (0, price_conversion_1.convertIntToDecimal)(item.gst);
1201
1203
  const amount = item.grossAmount;
1202
1204
  const obj = {
1203
1205
  _id: vendorId,
1204
- ref: gst,
1206
+ // Keep percentage and fixed rows with the same numeric value apart.
1207
+ ref: `${isGstPercentage ? 'pct' : 'amt'}:${gst}`,
1205
1208
  type: constants_1.WAREHOUSE_PURCHASE_ORDER_X_REPORT_TYPE_ENUM.GST,
1206
1209
  staff_name: vendorName,
1207
1210
  title: gstName,
1208
- description: `${gst}%`,
1211
+ description: isGstPercentage ? `${gst}%` : `Fixed ${(0, common_1.localeAmount)(currencySymbol, gst)}`,
1209
1212
  count: item.count,
1210
1213
  amount,
1211
1214
  sortIndex: 4,
@@ -573,7 +573,6 @@ export declare const CUSTOMER_COLLECTION_NAME = "customers";
573
573
  * - `_id`: unique primary key.
574
574
  * - `brand_id__phone_number`: per-brand customer lookups by phone number.
575
575
  * - `brand_id__email`: per-brand customer lookups by email (email/Google login).
576
- * - `brand_id__uid`: per-brand customer lookups by Firebase uid.
577
576
  * - `brand_id__createdAt`: per-brand customer lookups newest first.
578
577
  * - `brand_id__total_spent`: per-brand customer lookups by total spent.
579
578
  * - `brand_id__total_orders`: per-brand customer lookups by total orders.
@@ -595,10 +594,6 @@ export declare const CUSTOMER_COLLECTION_INDEXES: {
595
594
  brand_id: number;
596
595
  email: number;
597
596
  };
598
- brand_id__uid: {
599
- brand_id: number;
600
- uid: number;
601
- };
602
597
  brand_id__createdAt: {
603
598
  brand_id: number;
604
599
  createdAt: number;
@@ -223,7 +223,6 @@ exports.CUSTOMER_COLLECTION_NAME = 'customers';
223
223
  * - `_id`: unique primary key.
224
224
  * - `brand_id__phone_number`: per-brand customer lookups by phone number.
225
225
  * - `brand_id__email`: per-brand customer lookups by email (email/Google login).
226
- * - `brand_id__uid`: per-brand customer lookups by Firebase uid.
227
226
  * - `brand_id__createdAt`: per-brand customer lookups newest first.
228
227
  * - `brand_id__total_spent`: per-brand customer lookups by total spent.
229
228
  * - `brand_id__total_orders`: per-brand customer lookups by total orders.
@@ -243,10 +242,6 @@ exports.CUSTOMER_COLLECTION_INDEXES = {
243
242
  brand_id: 1,
244
243
  email: 1,
245
244
  }, // per-brand customer lookups by email (email login / account resolution)
246
- brand_id__uid: {
247
- brand_id: 1,
248
- uid: 1,
249
- }, // per-brand customer lookups by Firebase uid
250
245
  brand_id__createdAt: {
251
246
  brand_id: 1,
252
247
  createdAt: -1,
@@ -561,6 +561,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
561
561
  is_gst_inclusive?: boolean | null | undefined;
562
562
  gst?: number | null | undefined;
563
563
  gst_amount?: number | null | undefined;
564
+ is_gst_percentage?: boolean | null | undefined;
564
565
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
565
566
  updatedAt: NativeDate;
566
567
  categories: import("mongoose").Types.DocumentArray<{
@@ -879,6 +880,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
879
880
  is_gst_inclusive?: boolean | null | undefined;
880
881
  gst?: number | null | undefined;
881
882
  gst_amount?: number | null | undefined;
883
+ is_gst_percentage?: boolean | null | undefined;
882
884
  }> & {
883
885
  updatedAt: NativeDate;
884
886
  categories: import("mongoose").Types.DocumentArray<{
@@ -1197,6 +1199,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
1197
1199
  is_gst_inclusive?: boolean | null | undefined;
1198
1200
  gst?: number | null | undefined;
1199
1201
  gst_amount?: number | null | undefined;
1202
+ is_gst_percentage?: boolean | null | undefined;
1200
1203
  }>;
1201
1204
  special_instructions: string;
1202
1205
  payments: import("mongoose").Types.DocumentArray<{
@@ -1295,6 +1298,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
1295
1298
  is_gst_inclusive?: boolean | null | undefined;
1296
1299
  gst?: number | null | undefined;
1297
1300
  gst_amount?: number | null | undefined;
1301
+ is_gst_percentage?: boolean | null | undefined;
1298
1302
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
1299
1303
  createdAt: NativeDate;
1300
1304
  updatedAt: NativeDate;
@@ -1853,6 +1857,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
1853
1857
  is_gst_inclusive?: boolean | null | undefined;
1854
1858
  gst?: number | null | undefined;
1855
1859
  gst_amount?: number | null | undefined;
1860
+ is_gst_percentage?: boolean | null | undefined;
1856
1861
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
1857
1862
  updatedAt: NativeDate;
1858
1863
  categories: import("mongoose").Types.DocumentArray<{
@@ -2171,6 +2176,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
2171
2176
  is_gst_inclusive?: boolean | null | undefined;
2172
2177
  gst?: number | null | undefined;
2173
2178
  gst_amount?: number | null | undefined;
2179
+ is_gst_percentage?: boolean | null | undefined;
2174
2180
  }> & {
2175
2181
  updatedAt: NativeDate;
2176
2182
  categories: import("mongoose").Types.DocumentArray<{
@@ -2489,6 +2495,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
2489
2495
  is_gst_inclusive?: boolean | null | undefined;
2490
2496
  gst?: number | null | undefined;
2491
2497
  gst_amount?: number | null | undefined;
2498
+ is_gst_percentage?: boolean | null | undefined;
2492
2499
  }>;
2493
2500
  special_instructions: string;
2494
2501
  payments: import("mongoose").Types.DocumentArray<{
@@ -2587,6 +2594,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
2587
2594
  is_gst_inclusive?: boolean | null | undefined;
2588
2595
  gst?: number | null | undefined;
2589
2596
  gst_amount?: number | null | undefined;
2597
+ is_gst_percentage?: boolean | null | undefined;
2590
2598
  }>> & import("mongoose").FlatRecord<{
2591
2599
  createdAt: NativeDate;
2592
2600
  updatedAt: NativeDate;
@@ -3145,6 +3153,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
3145
3153
  is_gst_inclusive?: boolean | null | undefined;
3146
3154
  gst?: number | null | undefined;
3147
3155
  gst_amount?: number | null | undefined;
3156
+ is_gst_percentage?: boolean | null | undefined;
3148
3157
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
3149
3158
  updatedAt: NativeDate;
3150
3159
  categories: import("mongoose").Types.DocumentArray<{
@@ -3463,6 +3472,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
3463
3472
  is_gst_inclusive?: boolean | null | undefined;
3464
3473
  gst?: number | null | undefined;
3465
3474
  gst_amount?: number | null | undefined;
3475
+ is_gst_percentage?: boolean | null | undefined;
3466
3476
  }> & {
3467
3477
  updatedAt: NativeDate;
3468
3478
  categories: import("mongoose").Types.DocumentArray<{
@@ -3781,6 +3791,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
3781
3791
  is_gst_inclusive?: boolean | null | undefined;
3782
3792
  gst?: number | null | undefined;
3783
3793
  gst_amount?: number | null | undefined;
3794
+ is_gst_percentage?: boolean | null | undefined;
3784
3795
  }>;
3785
3796
  special_instructions: string;
3786
3797
  payments: import("mongoose").Types.DocumentArray<{
@@ -3879,6 +3890,7 @@ export declare const TenantPurchaseOrderSchema: Schema<any, import("mongoose").M
3879
3890
  is_gst_inclusive?: boolean | null | undefined;
3880
3891
  gst?: number | null | undefined;
3881
3892
  gst_amount?: number | null | undefined;
3893
+ is_gst_percentage?: boolean | null | undefined;
3882
3894
  }> & Required<{
3883
3895
  _id: import("mongoose").Types.ObjectId;
3884
3896
  }> & {
@@ -95,6 +95,7 @@ const IterationsOrderSchema = new mongoose_1.Schema({
95
95
  gst: { type: Number, min: 0, required: false },
96
96
  gst_amount: { type: Number, min: 0, required: false },
97
97
  is_gst_inclusive: { type: Boolean, required: false },
98
+ is_gst_percentage: { type: Boolean, required: false },
98
99
  tax_number: { type: String, default: '' },
99
100
  updatedAt: { type: mongoose_1.Schema.Types.Date, required: true },
100
101
  }, { _id: false, timestamps: false, versionKey: false });
@@ -134,6 +135,8 @@ exports.TenantPurchaseOrderSchema = new mongoose_1.Schema({
134
135
  gst: { type: Number, min: 0, required: false },
135
136
  gst_amount: { type: Number, min: 0, required: false },
136
137
  is_gst_inclusive: { type: Boolean, required: false },
138
+ // true/undefined => `gst` is a percentage, false => `gst` is a fixed amount
139
+ is_gst_percentage: { type: Boolean, required: false },
137
140
  is_deleted: { type: Boolean, default: false },
138
141
  order_status_updated_at: {
139
142
  type: mongoose_1.Schema.Types.Date,
@@ -543,6 +543,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
543
543
  is_gst_inclusive?: boolean | null | undefined;
544
544
  gst?: number | null | undefined;
545
545
  gst_amount?: number | null | undefined;
546
+ is_gst_percentage?: boolean | null | undefined;
546
547
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
547
548
  updatedAt: NativeDate;
548
549
  categories: import("mongoose").Types.DocumentArray<{
@@ -852,6 +853,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
852
853
  is_gst_inclusive?: boolean | null | undefined;
853
854
  gst?: number | null | undefined;
854
855
  gst_amount?: number | null | undefined;
856
+ is_gst_percentage?: boolean | null | undefined;
855
857
  }> & {
856
858
  updatedAt: NativeDate;
857
859
  categories: import("mongoose").Types.DocumentArray<{
@@ -1161,6 +1163,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
1161
1163
  is_gst_inclusive?: boolean | null | undefined;
1162
1164
  gst?: number | null | undefined;
1163
1165
  gst_amount?: number | null | undefined;
1166
+ is_gst_percentage?: boolean | null | undefined;
1164
1167
  }>;
1165
1168
  special_instructions: string;
1166
1169
  payments: import("mongoose").Types.DocumentArray<{
@@ -1261,6 +1264,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
1261
1264
  gst?: number | null | undefined;
1262
1265
  gst_amount?: number | null | undefined;
1263
1266
  rfq_id?: import("mongoose").Types.ObjectId | null | undefined;
1267
+ is_gst_percentage?: boolean | null | undefined;
1264
1268
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
1265
1269
  createdAt: NativeDate;
1266
1270
  updatedAt: NativeDate;
@@ -1800,6 +1804,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
1800
1804
  is_gst_inclusive?: boolean | null | undefined;
1801
1805
  gst?: number | null | undefined;
1802
1806
  gst_amount?: number | null | undefined;
1807
+ is_gst_percentage?: boolean | null | undefined;
1803
1808
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
1804
1809
  updatedAt: NativeDate;
1805
1810
  categories: import("mongoose").Types.DocumentArray<{
@@ -2109,6 +2114,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
2109
2114
  is_gst_inclusive?: boolean | null | undefined;
2110
2115
  gst?: number | null | undefined;
2111
2116
  gst_amount?: number | null | undefined;
2117
+ is_gst_percentage?: boolean | null | undefined;
2112
2118
  }> & {
2113
2119
  updatedAt: NativeDate;
2114
2120
  categories: import("mongoose").Types.DocumentArray<{
@@ -2418,6 +2424,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
2418
2424
  is_gst_inclusive?: boolean | null | undefined;
2419
2425
  gst?: number | null | undefined;
2420
2426
  gst_amount?: number | null | undefined;
2427
+ is_gst_percentage?: boolean | null | undefined;
2421
2428
  }>;
2422
2429
  special_instructions: string;
2423
2430
  payments: import("mongoose").Types.DocumentArray<{
@@ -2518,6 +2525,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
2518
2525
  gst?: number | null | undefined;
2519
2526
  gst_amount?: number | null | undefined;
2520
2527
  rfq_id?: import("mongoose").Types.ObjectId | null | undefined;
2528
+ is_gst_percentage?: boolean | null | undefined;
2521
2529
  }>> & import("mongoose").FlatRecord<{
2522
2530
  createdAt: NativeDate;
2523
2531
  updatedAt: NativeDate;
@@ -3057,6 +3065,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
3057
3065
  is_gst_inclusive?: boolean | null | undefined;
3058
3066
  gst?: number | null | undefined;
3059
3067
  gst_amount?: number | null | undefined;
3068
+ is_gst_percentage?: boolean | null | undefined;
3060
3069
  }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId, any, {
3061
3070
  updatedAt: NativeDate;
3062
3071
  categories: import("mongoose").Types.DocumentArray<{
@@ -3366,6 +3375,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
3366
3375
  is_gst_inclusive?: boolean | null | undefined;
3367
3376
  gst?: number | null | undefined;
3368
3377
  gst_amount?: number | null | undefined;
3378
+ is_gst_percentage?: boolean | null | undefined;
3369
3379
  }> & {
3370
3380
  updatedAt: NativeDate;
3371
3381
  categories: import("mongoose").Types.DocumentArray<{
@@ -3675,6 +3685,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
3675
3685
  is_gst_inclusive?: boolean | null | undefined;
3676
3686
  gst?: number | null | undefined;
3677
3687
  gst_amount?: number | null | undefined;
3688
+ is_gst_percentage?: boolean | null | undefined;
3678
3689
  }>;
3679
3690
  special_instructions: string;
3680
3691
  payments: import("mongoose").Types.DocumentArray<{
@@ -3775,6 +3786,7 @@ export declare const PurchaseOrderSchema: Schema<any, import("mongoose").Model<a
3775
3786
  gst?: number | null | undefined;
3776
3787
  gst_amount?: number | null | undefined;
3777
3788
  rfq_id?: import("mongoose").Types.ObjectId | null | undefined;
3789
+ is_gst_percentage?: boolean | null | undefined;
3778
3790
  }> & Required<{
3779
3791
  _id: import("mongoose").Types.ObjectId;
3780
3792
  }> & {
@@ -202,6 +202,10 @@ const IterationsOrderSchema = new mongoose_1.Schema({
202
202
  type: Boolean,
203
203
  required: false,
204
204
  },
205
+ is_gst_percentage: {
206
+ type: Boolean,
207
+ required: false,
208
+ },
205
209
  tax_number: {
206
210
  type: String,
207
211
  default: '',
@@ -330,6 +334,11 @@ exports.PurchaseOrderSchema = new mongoose_1.Schema({
330
334
  type: Boolean,
331
335
  required: false,
332
336
  },
337
+ // true/undefined => `gst` is a percentage, false => `gst` is a fixed amount
338
+ is_gst_percentage: {
339
+ type: Boolean,
340
+ required: false,
341
+ },
333
342
  //
334
343
  is_deleted: {
335
344
  type: Boolean,
@@ -42,6 +42,7 @@ interface ITenantPurchaseOrderIterationBase<TCategory, TStatus> {
42
42
  categories: TCategory[];
43
43
  staff_details: IStaffDetails;
44
44
  is_gst_inclusive?: boolean;
45
+ is_gst_percentage?: boolean;
45
46
  gst?: number | null;
46
47
  gst_amount?: number | null;
47
48
  special_instructions: string;
@@ -34,6 +34,7 @@ export interface IWarehousePurchaseOrderIteration {
34
34
  categories: IWarehousePurchaseOrderCategory[];
35
35
  staff_details: IStaffDetails;
36
36
  is_gst_inclusive?: boolean;
37
+ is_gst_percentage?: boolean;
37
38
  gst?: number | null;
38
39
  gst_amount?: number | null;
39
40
  special_instructions: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.4.76",
3
+ "version": "0.4.78",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",