Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions POS/src/components/sale/EditItemDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,23 @@
</div>
<!-- Item Info -->
<div class="flex-1 min-w-0">
<h3 class="text-base font-semibold text-gray-900 truncate">
{{ localItem.item_name }}
</h3>
<p class="text-sm text-gray-500 truncate">
<p class="text-sm text-gray-500 truncate mb-1">
{{ formatCurrency(localItem.price_list_rate || localItem.rate) }} / {{ localItem.stock_uom || 'Nos' }}
</p>
</div>
</div>

<!-- Item Name Editor -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Item Name</label>
<input
v-model="localItemName"
type="text"
class="w-full h-10 border border-gray-300 rounded-lg px-3 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
placeholder="Enter item name"
/>
</div>

<!-- Two Column Layout for Quantity, UOM, Rate, Warehouse -->
<div class="grid grid-cols-2 gap-4">
<!-- Left Column: Quantity and Rate -->
Expand Down Expand Up @@ -246,6 +254,7 @@ const emit = defineEmits(["update:modelValue", "update-item"])

// Local state
const localItem = ref(null)
const localItemName = ref("")
const localQuantity = ref(1)
const localUom = ref("")
const localRate = ref(0)
Expand Down Expand Up @@ -278,6 +287,7 @@ watch(
(newItem) => {
if (newItem) {
localItem.value = { ...newItem }
localItemName.value = newItem.item_name || ""
localQuantity.value = newItem.quantity || 1
localUom.value = newItem.uom || newItem.stock_uom || "Nos"
localRate.value = newItem.rate || 0
Expand Down Expand Up @@ -455,6 +465,7 @@ function formatCurrency(amount) {
function updateItem() {
const updatedItem = {
...localItem.value,
item_name: localItemName.value,
quantity: localQuantity.value,
uom: localUom.value,
rate: localRate.value,
Expand Down Expand Up @@ -495,6 +506,7 @@ input[type="number"]::-webkit-outer-spin-button {
}

input[type="number"] {
appearance: textfield;
-moz-appearance: textfield;
}
</style>
47 changes: 24 additions & 23 deletions POS/src/stores/posCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,29 +506,30 @@ export const usePOSCartStore = defineStore("posCart", () => {
}
}

// Update all provided details
if (updatedDetails.quantity !== undefined) {
cartItem.quantity = updatedDetails.quantity
}
// Don't update rate directly - let recalculateItem compute it from price_list_rate and discount
// if (updatedDetails.rate !== undefined) {
// cartItem.rate = updatedDetails.rate
// }
if (updatedDetails.warehouse !== undefined) {
cartItem.warehouse = updatedDetails.warehouse
}
if (updatedDetails.discount_percentage !== undefined) {
cartItem.discount_percentage = updatedDetails.discount_percentage
}
if (updatedDetails.discount_amount !== undefined) {
cartItem.discount_amount = updatedDetails.discount_amount
}
// Update price_list_rate if provided (for UOM changes)
if (updatedDetails.price_list_rate !== undefined) {
cartItem.price_list_rate = updatedDetails.price_list_rate
}

// Recalculate item totals (this will compute the correct rate from price_list_rate and discount)
// Update all provided details
if (updatedDetails.item_name !== undefined) {
cartItem.item_name = updatedDetails.item_name
}
if (updatedDetails.quantity !== undefined) {
cartItem.quantity = updatedDetails.quantity
}
// Don't update rate directly - let recalculateItem compute it from price_list_rate and discount
// if (updatedDetails.rate !== undefined) {
// cartItem.rate = updatedDetails.rate
// }
if (updatedDetails.warehouse !== undefined) {
cartItem.warehouse = updatedDetails.warehouse
}
if (updatedDetails.discount_percentage !== undefined) {
cartItem.discount_percentage = updatedDetails.discount_percentage
}
if (updatedDetails.discount_amount !== undefined) {
cartItem.discount_amount = updatedDetails.discount_amount
}
// Update price_list_rate if provided (for UOM changes)
if (updatedDetails.price_list_rate !== undefined) {
cartItem.price_list_rate = updatedDetails.price_list_rate
} // Recalculate item totals (this will compute the correct rate from price_list_rate and discount)
recalculateItem(cartItem)

// Rebuild cache after item update to ensure totals are accurate
Expand Down