Fixed error to function to create purchase order

This commit is contained in:
2026-05-27 12:20:25 +01:00
parent 56d3d1bea7
commit a7ef707388
10 changed files with 118 additions and 75 deletions
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, input} from '@angular/core';
import {
FormArray,
FormBuilder,
@@ -34,6 +34,8 @@ import {GetProductDto} from "../../services/api";
styleUrl: './create-quotation-form.css',
})
export class CreateQuotationForm {
products = input.required<GetProductDto[]>();
createQuotationForm: FormGroup = new FormGroup({
message: new FormControl<string>(null, Validators.required),
purchaseConditions: new FormControl<string>(null, Validators.required),
@@ -44,13 +46,13 @@ export class CreateQuotationForm {
return this.createQuotationForm.get('lines') as FormArray;
}
addProductToForm(selectedProducts: GetProductDto[]) {
addProductToForm() {
this.lines.clear();
selectedProducts.forEach(p => {
this.products().forEach(x => {
this.lines.push(
new FormGroup({
productId: new FormControl(p.id),
name: new FormControl(p.name),
productId: new FormControl(x.id),
name: new FormControl(x.name),
quantity: new FormControl(0, [Validators.required, Validators.min(0)])
})
);