mirror of
https://github.com/frappe/books.git
synced 2026-08-24 02:24:17 -05:00
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:
@@ -735,6 +735,7 @@ export abstract class Invoice extends Transactional {
|
||||
serialNumber,
|
||||
name: undefined,
|
||||
quantity: quantity,
|
||||
transferQuantity: quantity,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user