Merge pull request #1295 from frappe/fix-serial-stock

fix: increase stock instead of decreasing when returning serial numbered item
This commit is contained in:
Able k Saju
2025-07-22 15:52:39 +05:30
committed by GitHub
4 changed files with 16 additions and 6 deletions
+1
View File
@@ -735,6 +735,7 @@ export abstract class Invoice extends Transactional {
serialNumber,
name: undefined,
quantity: quantity,
transferQuantity: quantity,
});
}
+10 -4
View File
@@ -285,7 +285,8 @@ class StockManagerItem {
const snStockLedgerEntries = this.#getSerialNumberedStockLedgerEntries(
location,
isOutward,
serialNumbers
serialNumbers,
quantity
);
this.stockLedgerEntries?.push(...snStockLedgerEntries);
@@ -303,10 +304,15 @@ class StockManagerItem {
#getSerialNumberedStockLedgerEntries(
location: string,
isOutward: boolean,
serialNumbers: string[]
serialNumbers: string[],
quantity: number
): StockLedgerEntry[] {
let quantity = 1;
if (isOutward) {
if (quantity > 0) {
quantity = 1;
}
if (quantity < 0) {
quantity = 1;
} else if (isOutward) {
quantity = -1;
}
+4 -1
View File
@@ -981,7 +981,10 @@ export default defineComponent({
},
async validate() {
await validateSinv(this.sinvDoc as SalesInvoice, this.itemQtyMap);
await validateShipment(this.itemSerialNumbers);
if (!this.sinvDoc.isReturn) {
await validateShipment(this.itemSerialNumbers);
}
},
async applyPricingRule() {
if (this.ignorePricingRules()) {
+1 -1
View File
@@ -290,7 +290,7 @@ export function validateSerialNumberCount(
serialNumberCount = serialNumbers.split('\n').length;
}
if (quantity !== serialNumberCount) {
if (Math.abs(quantity) !== serialNumberCount) {
const errorMessage = t`Need ${quantity} Serial Numbers for Item ${item}. You have provided ${serialNumberCount}`;
showToast({