Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,29 @@ export class IndentRequestComponent implements OnInit, DoCheck {
this.indentRequestForm.reset({ requestDate: new Date() });
}
submitIndentRequest(indentRequestForm: FormGroup) {
// indentItemList rows carry no validators and the array can be empty, so
// guard manually: require the header fields and at least one real item
// (item selected + a positive required quantity). Prevents saving an empty
// request / an empty row.
const validItems = (indentRequestForm.value.indentItemList || []).filter(
(item: any) =>
!item.deleted &&
(item.itemID || `${item.itemName ?? ''}`.trim()) &&
Number(item.requiredQty) > 0,
);
if (
indentRequestForm.get('referenceNumber')?.invalid ||
indentRequestForm.get('indentReason')?.invalid ||
validItems.length === 0
) {
indentRequestForm.markAllAsTouched();
this.confirmationService.alert(
this.currentLanguageSet?.inventory?.pleaseFillMandatoryFields ||
'Please fill all mandatory fields.',
'error',
);
return;
}
const indentRequest = JSON.parse(
JSON.stringify(indentRequestForm.value.indentItemList),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ export class PhysicalStockEntryComponent implements OnInit, OnChanges, DoCheck {
}

savePhysicalStock() {
if (this.physicalStockEntryForm.invalid) {
this.physicalStockEntryForm.markAllAsTouched();
this.dialogService.alert(
this.currentLanguageSet?.inventory?.pleaseFillMandatoryFields ||
'Please fill all mandatory fields.',
'error',
);
return;
}
console.log('FORMSTOCK', this.physicalStockEntryForm);
const physicalStockEntry = JSON.parse(
JSON.stringify(this.physicalStockEntryForm.value),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ export class StoreSelfConsumptionComponent implements OnInit, DoCheck {
}

saveSelfConsumptionStock() {
if (this.storeSelfConsumptionForm.invalid) {
this.storeSelfConsumptionForm.markAllAsTouched();
this.alertService.alert(
this.currentLanguageSet?.inventory?.pleaseFillMandatoryFields ||
'Please fill all mandatory fields.',
'error',
);
return;
}
const temp = JSON.parse(
JSON.stringify(this.storeSelfConsumptionForm.value),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ export class StoreStockTransferComponent implements OnInit, DoCheck {
}

submitTransfers() {
if (this.stockTransferForm.invalid) {
this.stockTransferForm.markAllAsTouched();
this.confirmationService.alert(
this.currentLanguageSet?.inventory?.pleaseFillMandatoryFields ||
'Please fill all mandatory fields.',
'error',
);
return;
}
console.log(this.stockTransferForm.value);
this.inventoryService
.saveStockTransfer(this.serviceDataMapper(this.stockTransferForm.value))
Expand Down
Loading