I wanna count ItemTotal = quantity * UnitPrice and Total Price Of Invoice. Please suggest me to write the right Method to Count Total and Item Total.
medicinePurchaseForm: FormGroup;
ngOnInit(): void {
this.initForm();
}
private initForm() {
this.medicinePurchaseForm = new FormGroup({
prescriptionId: new FormControl(),
subtotal: new FormControl(),
purchaseMedicineList: new FormArray([
])
});
}
get medicineArray() {
return this.medicinePurchaseForm.controls.purchaseMedicineList as FormArray;
}
addMedicinetoLine(){
const purchasemedicine = new FormGroup({
medicineId: new FormControl(this.medicineID.value, Validators.required),
medicineName: new FormControl(this.brandName.value, Validators.required),
unitPrice: new FormControl(this.price.value),
quantity: new FormControl(this.quantity.value, Validators.required),
itemTotal: new FormControl(),
});
this.medicineArray.push(purchasemedicine);
}