Merged PR 1298: #3234 Bugfix Remission Artikel hinzufügen Menge falsch

#3234 Bugfix Remission Artikel hinzufügen Menge falsch

Related work items: #3234
This commit is contained in:
Andreas Schickinger
2022-06-28 08:14:39 +00:00
committed by Lorenz Hilpert
parent 59c9275cc4
commit 3d972fd740
2 changed files with 12 additions and 9 deletions

View File

@@ -201,7 +201,7 @@ export class DomainRemissionService {
);
}
getStockInformation(items: RemissionListItem[]) {
getStockInformation(items: RemissionListItem[], recalculate: boolean = false) {
return this.getCurrentStock().pipe(
switchMap((stock) =>
this._stockService
@@ -231,14 +231,17 @@ export class DomainRemissionService {
let { remainingQuantity, remissionQuantity } = item;
remissionQuantity = inStock - (remainingQuantity || 0);
if (remissionQuantity < 0) {
remissionQuantity = 0;
if (!remissionQuantity || recalculate) {
remissionQuantity = inStock - (remainingQuantity || 0);
if (remissionQuantity < 0) {
remissionQuantity = 0;
}
}
remainingQuantity = inStock - (remissionQuantity || 0);
if (remainingQuantity < 0) {
remainingQuantity = 0;
if (!remainingQuantity || recalculate) {
remainingQuantity = inStock - (remissionQuantity || 0);
if (remainingQuantity < 0) {
remainingQuantity = 0;
}
}
return { ...item, remainingQuantity, remissionQuantity, inStock };

View File

@@ -261,7 +261,7 @@ export class RemissionListItemComponent implements OnDestroy {
async updateStockInformation(items: RemissionListItem[]) {
try {
const res = await this._remissionService.getStockInformation(items).toPromise();
const res = await this._remissionService.getStockInformation(items, true).toPromise();
items.forEach((item) => {
const resForItem = res.find((r) => r.dto.id === item.dto.id);
item.remissionQuantity = resForItem?.remissionQuantity;