@apptimate/core-lib 4.9.0 → 5.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apptimate/core-lib",
3
- "version": "4.9.0",
3
+ "version": "5.2.0",
4
4
  "main": "src/index.ts",
5
5
  "types": "src/index.ts",
6
6
  "publishConfig": {
@@ -15,6 +15,14 @@ export async function getItemBatches(itemId: number, params: Record<string, stri
15
15
  return response.responseData as IApiResponse;
16
16
  }
17
17
 
18
+ export async function checkHasActivePriceLists(): Promise<IApiResponse> {
19
+ const response = await sendRequest({
20
+ url: `${process.env.NEXT_PUBLIC_API_URL}/api/sales/price-lists/has-active?t=${new Date().getTime()}`,
21
+ method: "GET"
22
+ });
23
+ return response.responseData as IApiResponse;
24
+ }
25
+
18
26
  export async function evaluatePriceLists(data: {
19
27
  party_id?: number | null;
20
28
  transaction_type: string;
@@ -111,6 +111,7 @@ export const MENU_ITEM_REGISTRY: RegistryItem[] = [
111
111
  { key: 'sales__orders', label: 'Sales Orders', path: '/sales/orders', module: 'Sales', defaultGroup: 'Orders', permission: null },
112
112
  { key: 'sales__goods_issue_notes', label: 'Goods Issue Notes', path: '/sales/delivery-notes', module: 'Sales', defaultGroup: 'Fulfillment', permission: null },
113
113
  { key: 'sales__returns', label: 'Sales Returns', path: '/sales/returns', module: 'Sales', defaultGroup: 'Post-Sales', permission: null },
114
+ { key: 'sales__invoices', label: 'Sales Invoices', path: '/sales/invoices', module: 'Sales', defaultGroup: 'Post-Sales', permission: null },
114
115
  { key: 'sales__credit_notes', label: 'Credit Notes', path: '/sales/credit-notes', module: 'Sales', defaultGroup: 'Post-Sales', permission: null },
115
116
  { key: 'sales__pos', label: 'POS Terminal', path: '/sales/pos', module: 'Sales', defaultGroup: 'POS', permission: null },
116
117
  { key: 'sales__pos_sessions', label: 'Terminal Sessions', path: '/sales/pos/sessions', module: 'Sales', defaultGroup: 'POS', permission: null },
@@ -249,16 +250,10 @@ export const MENU_ITEM_REGISTRY: RegistryItem[] = [
249
250
  { key: 'construction__ipcs', label: 'Progress Billing', path: '/construction/contracts/ipcs', module: 'Construction', defaultGroup: 'Contracts & Billing', permission: null },
250
251
  { key: 'construction__variations', label: 'Subcontractor Variations', path: '/construction/variations', module: 'Construction', defaultGroup: 'Contracts & Billing', permission: null },
251
252
 
252
- { key: 'construction__prs', label: 'Purchase Requisitions', path: '/construction/procurement/prs', module: 'Construction', defaultGroup: 'Procurement', permission: null },
253
- { key: 'construction__pos', label: 'Purchase Orders', path: '/construction/procurement/pos', module: 'Construction', defaultGroup: 'Procurement', permission: null },
254
- { key: 'construction__grns', label: 'Goods Receipt', path: '/construction/procurement/grns', module: 'Construction', defaultGroup: 'Procurement', permission: null },
255
- { key: 'construction__mtrs', label: 'Transfer Requests', path: '/construction/procurement/mtrs', module: 'Construction', defaultGroup: 'Procurement', permission: null },
256
253
 
257
- { key: 'construction__site_ledger', label: 'Project Ledger', path: '/construction/site-inventory/ledger', module: 'Construction', defaultGroup: 'Project Inventory', permission: null },
258
- { key: 'construction__site_issues', label: 'Project Issues', path: '/construction/site-inventory/issues', module: 'Construction', defaultGroup: 'Project Inventory', permission: null },
259
- { key: 'construction__wastage_returns', label: 'Wastage & Returns', path: '/construction/site-inventory/wastage-returns', module: 'Construction', defaultGroup: 'Project Inventory', permission: null },
260
-
254
+
261
255
  { key: 'construction__workforce', label: 'Workforce Master', path: '/construction/workforce', module: 'Construction', defaultGroup: 'Workforce', permission: null },
256
+ { key: 'construction__workforce_allocation', label: 'Workforce Allocation', path: '/construction/workforce/allocation', module: 'Construction', defaultGroup: 'Workforce', permission: null },
262
257
  { key: 'construction__shifts', label: 'Shift Master', path: '/construction/shifts', module: 'Construction', defaultGroup: 'Workforce', permission: null },
263
258
  { key: 'construction__attendance', label: 'Attendance & Timesheets', path: '/construction/attendance', module: 'Construction', defaultGroup: 'Workforce', permission: null },
264
259
 
@@ -398,7 +393,7 @@ export const MENU_PRESETS: MenuPreset[] = [
398
393
  secondaryItems: [
399
394
  'sales__price_lists',
400
395
  'sales__quotations', 'sales__orders', 'sales__goods_issue_notes',
401
- 'sales__returns', 'sales__credit_notes',
396
+ 'sales__invoices', 'sales__returns', 'sales__credit_notes',
402
397
  'sales__pos', 'sales__pos_sessions',
403
398
  'sales__settings'
404
399
  ],
@@ -519,6 +514,7 @@ export const MENU_PRESETS: MenuPreset[] = [
519
514
  'construction__wastage_returns',
520
515
  'construction__variations',
521
516
  'construction__workforce',
517
+ 'construction__workforce_allocation',
522
518
  'construction__shifts',
523
519
  'construction__attendance',
524
520
  'construction__equipment_types',
@@ -4,6 +4,7 @@ export interface IPricingRule {
4
4
  min_quantity: number;
5
5
  rate: number | null;
6
6
  markdown_percentage: number | null;
7
+ batch_id?: number | null;
7
8
  final_rate?: number;
8
9
  }
9
10
 
@@ -14,21 +15,30 @@ export class PriceCalculationService {
14
15
  public static calculatePriceDetails(
15
16
  basePrice: number,
16
17
  quantity: number,
17
- rules?: IPricingRule[]
18
+ rules?: IPricingRule[],
19
+ batchId?: number | null
18
20
  ): { unitPrice: number; discountPercent: number; discountAmount: number; appliedRule?: IPricingRule } {
19
21
  if (!rules || rules.length === 0) {
20
22
  return { unitPrice: basePrice, discountPercent: 0, discountAmount: 0 };
21
23
  }
22
24
 
23
- // Filter rules that match the quantity condition
24
- const applicableRules = rules.filter(r => quantity >= r.min_quantity);
25
+ // Filter rules that match the quantity condition and batch condition
26
+ const applicableRules = rules.filter(r => {
27
+ if (quantity < r.min_quantity) return false;
28
+ if (r.batch_id && String(r.batch_id) !== String(batchId)) return false;
29
+ return true;
30
+ });
25
31
 
26
32
  if (applicableRules.length === 0) {
27
33
  return { unitPrice: basePrice, discountPercent: 0, discountAmount: 0 };
28
34
  }
29
35
 
30
- // Sort by min_quantity descending (highest threshold wins)
31
- applicableRules.sort((a, b) => b.min_quantity - a.min_quantity);
36
+ // Sort by batch specificity first, then min_quantity descending (highest threshold wins)
37
+ applicableRules.sort((a, b) => {
38
+ if (a.batch_id && !b.batch_id) return -1;
39
+ if (!a.batch_id && b.batch_id) return 1;
40
+ return b.min_quantity - a.min_quantity;
41
+ });
32
42
 
33
43
  const activeRule = applicableRules[0];
34
44