@apptimate/ui 3.8.0 → 3.9.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/ui",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "main": "src/index.tsx",
5
5
  "types": "src/index.tsx",
6
6
  "dependencies": {
@@ -260,7 +260,7 @@ export function ProductSelectionPanel({
260
260
  }
261
261
  };
262
262
 
263
- const updateLineInput = (uid: string, field: 'quantity' | 'unit_price', value: string) => {
263
+ const updateLineInput = (uid: string, field: 'quantity' | 'unit_price' | 'free_qty' | 'uom_id', value: string) => {
264
264
  const num = value === '' ? 0 : Number(value);
265
265
  const line = lineItems.find(l => l.uid === uid);
266
266
  if (!line) return;
@@ -273,6 +273,16 @@ export function ProductSelectionPanel({
273
273
 
274
274
  const discAmt = (price * qty * line.discount_percent) / 100;
275
275
 
276
+ if (field === 'free_qty') {
277
+ onUpdateLine(uid, { free_qty: Math.max(0, num) });
278
+ return;
279
+ }
280
+
281
+ if (field === 'uom_id') {
282
+ onUpdateLine(uid, { uom_id: Number(value) });
283
+ return;
284
+ }
285
+
276
286
  onUpdateLine(uid, {
277
287
  quantity: qty,
278
288
  unit_price: price,
@@ -502,6 +512,8 @@ export function ProductSelectionPanel({
502
512
  <TRow>
503
513
  <TCell isHeader className="w-[45%]">Item</TCell>
504
514
  <TCell isHeader>Qty</TCell>
515
+ {config.enablePurchaseUnit && <TCell isHeader>Unit</TCell>}
516
+ {config.enableFreeQty && <TCell isHeader>Free Qty</TCell>}
505
517
  {config.showPrices && <TCell isHeader>Rate</TCell>}
506
518
  {config.showPrices && <TCell isHeader className="text-right">Total</TCell>}
507
519
  <TCell isHeader className="w-10 text-center"></TCell>
@@ -596,6 +608,33 @@ export function ProductSelectionPanel({
596
608
  />
597
609
  </TCell>
598
610
 
611
+ {config.enablePurchaseUnit && (
612
+ <TCell label="Unit" className="py-2.5">
613
+ <select
614
+ value={line.uom_id || line.item.uom_id || ''}
615
+ onChange={(e) => updateLineInput(line.uid, 'uom_id', e.target.value)}
616
+ className="h-8 px-2 text-[13px] font-medium bg-surface-1 border border-border-subtle rounded-md focus:border-primary/50 focus:outline-none transition-colors min-w-[80px]"
617
+ >
618
+ {line.item.uom?.uom_group?.uoms?.map((uom: any) => (
619
+ <option key={uom.id} value={uom.id}>{uom.abbreviation}</option>
620
+ ))}
621
+ </select>
622
+ </TCell>
623
+ )}
624
+
625
+ {config.enableFreeQty && (
626
+ <TCell label="Free Qty" className="py-2.5">
627
+ <input
628
+ type="number"
629
+ value={line.free_qty || 0}
630
+ onChange={(e) => updateLineInput(line.uid, 'free_qty', e.target.value)}
631
+ className="w-20 h-8 px-2 text-[13px] text-center font-medium bg-surface-1 border border-border-subtle rounded-md focus:border-primary/50 focus:outline-none transition-colors"
632
+ min={0}
633
+ step="any"
634
+ />
635
+ </TCell>
636
+ )}
637
+
599
638
  {config.showPrices && (
600
639
  <TCell label="Rate" className="py-2.5">
601
640
  <input
@@ -178,6 +178,8 @@ export function ProductTransactionScreen({
178
178
  selling_price: b.selling_price,
179
179
  serial_numbers: undefined,
180
180
  quantity: b.quantity,
181
+ free_qty: l.free_qty,
182
+ uom_id: l.uom_id,
181
183
  unit_price: l.unit_price,
182
184
  discount_percent: l.discount_percent,
183
185
  discount_amount: (l.discount_amount / l.quantity) * b.quantity,
@@ -195,6 +197,8 @@ export function ProductTransactionScreen({
195
197
  selling_price: undefined,
196
198
  serial_numbers: l.serial_numbers,
197
199
  quantity: l.quantity,
200
+ free_qty: l.free_qty,
201
+ uom_id: l.uom_id,
198
202
  unit_price: l.unit_price,
199
203
  discount_percent: l.discount_percent,
200
204
  discount_amount: l.discount_amount,
@@ -19,7 +19,15 @@ export interface TransactionItem {
19
19
  is_discountable: boolean;
20
20
  category?: { id: number; name: string };
21
21
  brand?: { id: number; name: string };
22
- uom?: { id: number; name: string; abbreviation: string };
22
+ uom?: {
23
+ id: number;
24
+ name: string;
25
+ abbreviation: string;
26
+ uom_group?: {
27
+ id: number;
28
+ uoms: { id: number; name: string; abbreviation: string; base_uom_id?: number | null }[];
29
+ };
30
+ };
23
31
  variants?: TransactionItemVariant[];
24
32
  primary_image?: { id: number; url: string } | null;
25
33
  stock?: { qty_on_hand: number; qty_allocated: number; qty_available: number };
@@ -66,6 +74,8 @@ export interface TransactionLineItem {
66
74
  batches?: TransactionLineBatch[];
67
75
  serial_numbers?: string[];
68
76
  quantity: number;
77
+ free_qty?: number;
78
+ uom_id?: number;
69
79
  unit_price: number;
70
80
  discount_percent: number;
71
81
  discount_amount: number;
@@ -134,6 +144,10 @@ export interface TransactionScreenConfig {
134
144
  allowEditPrice?: boolean;
135
145
  /** Whether to show available stock for variants in the search dropdown */
136
146
  showStock?: boolean;
147
+ /** Enable free quantity input (dynamic setting) */
148
+ enableFreeQty?: boolean;
149
+ /** Enable purchase unit selection (dynamic setting) */
150
+ enablePurchaseUnit?: boolean;
137
151
  }
138
152
 
139
153
  // ── Module Presets ──
@@ -288,6 +302,8 @@ export interface TransactionPayload {
288
302
  selling_price?: number;
289
303
  serial_numbers?: string[];
290
304
  quantity: number;
305
+ free_qty?: number;
306
+ uom_id?: number;
291
307
  unit_price: number;
292
308
  discount_percent: number;
293
309
  discount_amount: number;
package/src/index.tsx CHANGED
@@ -19,6 +19,7 @@ export * from './base-components/TableMobileOptions';
19
19
  export * from './base-components/DesktopSearchPopover';
20
20
  export * from './base-components/DesktopFilterPopover';
21
21
  export * from './base-components/Input';
22
+ export * from './base-components/Textarea';
22
23
  export * from './base-components/Label';
23
24
  export * from './base-components/Modal';
24
25
  export * from './base-components/ActionModal';