| Product |
Batch |
- Strips |
- Loose |
+ Packs |
+ Loose |
Price |
Total |
|
@@ -391,25 +394,25 @@ function BillingPage() {
)}
-
- updateItem(idx, "strips", Number(e.target.value))}
- className="w-full px-2 py-1.5 border border-slate-200 rounded text-xs text-center"
- min={0}
- disabled={!products?.find((p) => p.id === item.product_id)?.units_per_strip}
- />
- |
-
- updateItem(idx, "loose", Number(e.target.value))}
- className="w-full px-2 py-1.5 border border-slate-200 rounded text-xs text-center"
- min={0}
- />
- |
+
+ updateItem(idx, "packs", Number(e.target.value))}
+ className="w-full px-2 py-1.5 border border-slate-200 rounded text-xs text-center"
+ min={0}
+ />
+ |
+
+ updateItem(idx, "loose", Number(e.target.value))}
+ className="w-full px-2 py-1.5 border border-slate-200 rounded text-xs text-center"
+ min={0}
+ disabled={!products?.find((p) => p.id === item.product_id)?.loose_sale_allowed}
+ />
+ |
-
- Subtotal
- ₹{subtotal.toFixed(2)}
-
-
- Tax (18% GST)
- ₹{tax.toFixed(2)}
-
Total
₹{total.toFixed(2)}
diff --git a/apps/pharmanager/src/routes/products/$id.tsx b/apps/pharmanager/src/routes/products/$id.tsx
index d3b0e4d..323e6c5 100644
--- a/apps/pharmanager/src/routes/products/$id.tsx
+++ b/apps/pharmanager/src/routes/products/$id.tsx
@@ -73,7 +73,7 @@ function ProductDetailsPage() {
{product.units_per_strip && (
-
+
)}
@@ -84,6 +84,7 @@ function ProductDetailsPage() {
Inventory
+
diff --git a/apps/pharmanager/src/routes/products/add.tsx b/apps/pharmanager/src/routes/products/add.tsx
index ed98d44..cd95eb0 100644
--- a/apps/pharmanager/src/routes/products/add.tsx
+++ b/apps/pharmanager/src/routes/products/add.tsx
@@ -27,7 +27,8 @@ const formSchema = CreateProductInput.extend({
selling_price: z.coerce.number().min(0, "Must be ≥ 0"),
size: z.coerce.number().int().default(0),
reorder_level: z.coerce.number().int().default(0),
- units_per_strip: z.coerce.number().int().nullable().optional(),
+ units_per_pack: z.coerce.number().int().nullable().optional(),
+ loose_sale_allowed: z.coerce.boolean().default(false),
});
type FormValues = z.infer;
@@ -87,7 +88,8 @@ function AddProductPage() {
selling_price: 0,
size: 0,
reorder_level: 0,
- units_per_strip: null,
+ units_per_pack: null,
+ loose_sale_allowed: false,
hide_product_from_public: false,
hide_price_from_public: false,
compositions: [{ drug_name: "", quantity: "", unit_name: "" }],
@@ -99,9 +101,15 @@ function AddProductPage() {
name: "compositions",
});
- const category = watch("category");
const hideProduct = watch("hide_product_from_public");
- const showUnitsPerStrip = category === "Tablets" || category === "Capsules";
+ const looseSaleAllowed = watch("loose_sale_allowed");
+ const showUnitsPerPack = looseSaleAllowed;
+
+ useEffect(() => {
+ if (!looseSaleAllowed) {
+ setValue("units_per_pack", null);
+ }
+ }, [looseSaleAllowed, setValue]);
useEffect(() => {
if (hideProduct) {
@@ -122,7 +130,8 @@ function AddProductPage() {
selling_price: existingProduct.selling_price,
size: existingProduct.size,
reorder_level: existingProduct.reorder_level,
- units_per_strip: existingProduct.units_per_strip,
+ units_per_pack: existingProduct.units_per_pack,
+ loose_sale_allowed: existingProduct.loose_sale_allowed,
hide_product_from_public: existingProduct.hide_product_from_public,
hide_price_from_public: existingProduct.hide_price_from_public,
compositions: existingProduct.compositions.map((c) => ({
@@ -212,12 +221,19 @@ function AddProductPage() {
/>
- {showUnitsPerStrip && (
+
+
+
+
+ {showUnitsPerPack && (
-
+
)}
@@ -240,7 +256,7 @@ function AddProductPage() {
{errors.unit_name && {errors.unit_name.message} }
-
+
|