fix: edit charge - tax group is mandatory by backend, but cannot be set on UI

now no empty tax-group request is sent to backend from edit charge and when empty tax-group charge is filled with some tax-group ,it is sending back the request to backend

Fixes: #1722
This commit is contained in:
Pushpendra Kumar
2023-03-30 12:30:52 +02:00
committed by Adam Saghy
parent f6f72c25e2
commit 452a1adc17
@@ -123,9 +123,9 @@ export class EditChargeComponent implements OnInit {
}
}
if (this.chargeData.taxGroup) {
this.chargeForm.addControl('taxGroupId', this.formBuilder.control({ value: this.chargeData.taxGroup.id }, Validators.required));
this.chargeForm.addControl('taxGroupId', this.formBuilder.control({ value: this.chargeData.taxGroup.id, disabled: true }));
} else {
delete this.chargeData.taxGroupId;
this.chargeForm.addControl('taxGroupId', this.formBuilder.control({ value: '' }));
}
}
@@ -150,6 +150,9 @@ export class EditChargeComponent implements OnInit {
const charges = this.chargeForm.getRawValue();
charges.locale = this.settingsService.language.code;
charges.chargePaymentMode = this.chargeData.chargePaymentMode.id;
if(charges.taxGroupId.value===''){
delete charges.taxGroupId;
}
this.productsService.updateCharge(this.chargeData.id.toString(), charges)
.subscribe((response: any) => {
this.router.navigate(['../'], { relativeTo: this.route });