Fix: Discount and payment received were not working

This commit is contained in:
2024-12-16 21:15:01 +05:30
parent a5efcc9061
commit 659fed549a
6 changed files with 64 additions and 66 deletions

View File

@ -26,7 +26,7 @@ import {
MatRow,
} from '@angular/material/table';
import { round } from 'mathjs';
import { Observable } from 'rxjs';
import { BehaviorSubject, Observable } from 'rxjs';
import { DiscountDataSource } from './discount-datasource';
import { DiscountItem } from './discount-item';
@ -71,7 +71,8 @@ export class DiscountComponent {
>;
}>;
dataSource: DiscountDataSource = new DiscountDataSource([]);
public listObservable = new BehaviorSubject<DiscountItem[]>([]);
dataSource: DiscountDataSource = new DiscountDataSource(this.listObservable);
displayedColumns = ['name', 'discount'];
@ -91,6 +92,7 @@ export class DiscountComponent {
this.data.subscribe((list: DiscountItem[]) => {
this.list = list;
console.log(list);
this.form.controls.discounts.clear();
this.list.forEach((x) => {
@ -104,7 +106,7 @@ export class DiscountComponent {
}),
);
});
this.dataSource = new DiscountDataSource(this.list);
this.listObservable.next(this.list);
});
}