This commit is contained in:
2026-03-23 16:56:23 -05:00
parent 1f0986a94d
commit ee26ffe75c
6 changed files with 128 additions and 38 deletions

View File

@@ -8,6 +8,7 @@ import type {
JournalEntryRow,
KitRow,
LowStockRow,
OrderItemOption,
PartRow,
PurchaseOrderListRow,
SalesOrderListRow,
@@ -94,6 +95,28 @@ export function getParts(): PartRow[] {
.all() as PartRow[];
}
export function getOrderItemOptions(): OrderItemOption[] {
return db()
.prepare(
`
SELECT
p.id,
p.sku,
p.name,
p.kind,
COALESCE(ib.quantity_on_hand, 0) AS quantityOnHand,
p.sale_price AS salePrice,
p.unit_cost AS unitCost,
p.unit_of_measure AS unitOfMeasure
FROM parts p
LEFT JOIN inventory_balances ib ON ib.part_id = p.id
WHERE p.is_active = 1
ORDER BY p.kind DESC, p.sku ASC
`
)
.all() as OrderItemOption[];
}
export function getAssembliesWithComponents(): KitRow[] {
return db()
.prepare(