From f84ebbd95583e770c7b322dda625beb275695ac0 Mon Sep 17 00:00:00 2001
From: Yoga Pangestu
Date: Sat, 13 Jun 2026 12:14:45 +0700
Subject: [PATCH] feat: add inline quantity adjustment controls to POS product
and purchase forms
---
.../admin/manage/orders/OrderPosForm.vue | 35 ++++++++++++++++---
.../manage/purchases/PurchasePosForm.vue | 34 ++++++++++++++++--
2 files changed, 62 insertions(+), 7 deletions(-)
diff --git a/resources/js/components/admin/manage/orders/OrderPosForm.vue b/resources/js/components/admin/manage/orders/OrderPosForm.vue
index 26d1137..e0e1302 100644
--- a/resources/js/components/admin/manage/orders/OrderPosForm.vue
+++ b/resources/js/components/admin/manage/orders/OrderPosForm.vue
@@ -179,6 +179,17 @@ function getVariantPrice(variant: ProductVariantItem): ProductPriceItem | undefi
return variant.prices.find((price) => price.type === form.price_type);
}
+function getCartItem(variantId: number): OrderCartItem | undefined {
+ return cart.value.find((item) => item.product_variant_id === variantId);
+}
+
+async function decreaseVariantQty(variantId: number) {
+ const index = cart.value.findIndex((item) => item.product_variant_id === variantId);
+ if (index !== -1) {
+ await adjustQuantity(index, -1);
+ }
+}
+
function lineSubtotal(item: OrderCartItem): number {
const quantity = Number(item.quantity) || 0;
@@ -374,9 +385,12 @@ function submit() {
Belum ada varian
+ class="flex items-center gap-2.5 px-3 py-2.5 transition-all duration-200"
+ :class="[
+ getVariantPrice(variant) ? 'cursor-pointer hover:bg-muted/30' : 'opacity-60',
+ getCartItem(variant.id) ? 'border-2 border-primary bg-primary/5 rounded-md mx-1 my-0.5' : ''
+ ]"
+ @click="getVariantPrice(variant) && !getCartItem(variant.id) && addToCart(product, variant)">
@@ -391,7 +405,20 @@ function submit() {
-
-
+
diff --git a/resources/js/components/admin/manage/purchases/PurchasePosForm.vue b/resources/js/components/admin/manage/purchases/PurchasePosForm.vue
index dfdbd34..76998ae 100644
--- a/resources/js/components/admin/manage/purchases/PurchasePosForm.vue
+++ b/resources/js/components/admin/manage/purchases/PurchasePosForm.vue
@@ -156,6 +156,17 @@ const discountAmount = computed(() => Number(parseRupiah(form.discount)) || 0);
const total = computed(() => Math.max(subtotal.value - discountAmount.value, 0));
+function getCartItem(priceId: number): PurchaseCartItem | undefined {
+ return cart.value.find((item) => item.raw_material_price_id === priceId);
+}
+
+async function decreasePriceQty(priceId: number) {
+ const index = cart.value.findIndex((item) => item.raw_material_price_id === priceId);
+ if (index !== -1) {
+ await adjustQuantity(index, -1);
+ }
+}
+
function lineSubtotal(item: PurchaseCartItem): number {
const quantity = Number(item.quantity) || 0;
@@ -358,8 +369,12 @@ function submit() {
Belum ada varian
+ class="flex items-center gap-2.5 px-3 py-2.5 transition-all duration-200"
+ :class="[
+ 'cursor-pointer hover:bg-muted/30',
+ getCartItem(price.id) ? 'border-2 border-primary bg-primary/5 rounded-md mx-1 my-0.5' : ''
+ ]"
+ @click="!getCartItem(price.id) && addToCart(rawMaterial, price)">
@@ -369,7 +384,20 @@ function submit() {
{{ price.price_formatted }}
-
+
+
+
+
+ {{ getCartItem(price.id)!.quantity }}
+
+
+
+
+
+