Skip to content

Commit

Permalink
fix: added validations for return in POS
Browse files Browse the repository at this point in the history
  • Loading branch information
AbleKSaju committed Jan 8, 2025
1 parent 60d5756 commit b262a2d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/pages/POS/PaymentModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ export default defineComponent({
if (
(this.sinvDoc.grandTotal?.float as number) < 1 &&
this.fyo.pesa(this.paidAmount.float).isZero()
this.fyo.pesa(this.paidAmount.float).isZero() &&
!this.sinvDoc.returnAgainst
) {
return true;
}
Expand All @@ -334,7 +335,8 @@ export default defineComponent({
disablePayButton(): boolean {
if (
(this.sinvDoc.grandTotal?.float as number) < 1 &&
this.fyo.pesa(this.paidAmount.float).isZero()
this.fyo.pesa(this.paidAmount.float).isZero() &&
!this.sinvDoc.returnAgainst
) {
return true;
}
Expand All @@ -345,6 +347,7 @@ export default defineComponent({
) {
return true;
}
return false;
},
},
Expand Down
11 changes: 8 additions & 3 deletions src/utils/pos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,20 @@ export function validateSinv(sinvDoc: SalesInvoice, itemQtyMap: ItemQtyMap) {
return;
}

validateSinvItems(sinvDoc.items as SalesInvoiceItem[], itemQtyMap);
validateSinvItems(
sinvDoc.items as SalesInvoiceItem[],
itemQtyMap,
sinvDoc.returnAgainst as string
);
}

function validateSinvItems(
sinvItems: SalesInvoiceItem[],
itemQtyMap: ItemQtyMap
itemQtyMap: ItemQtyMap,
isReturn?: string
) {
for (const item of sinvItems) {
if (!item.quantity || item.quantity < 1) {
if (!item.quantity || (item.quantity < 1 && !isReturn)) {
throw new ValidationError(
t`Invalid Quantity for Item ${item.item as string}`
);
Expand Down

0 comments on commit b262a2d

Please sign in to comment.