fix(products): restore default minDepositTerm on FD product create

Removing the forced default on this hidden, backend-mandatory field fixed
a false "changed" diff on product edit, but also broke plain product
create -- there's no saved value yet for a brand-new product, so it went
in blank and the backend rejected it as missing. Now only skips the
default when editing an existing product (which always has its own saved
value); create still defaults to 1, same as before that diff-dialog fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 12:41:07 +05:30
co-authored by Claude Sonnet 5
parent 5ee0a3fc53
commit 90f26d32b7
@@ -74,6 +74,7 @@ export class FixedDepositProductTermsStepComponent implements OnInit, OnChanges
this.periodFrequencyData = this.fixedDepositProductsTemplate.periodFrequencyTypeOptions || []; this.periodFrequencyData = this.fixedDepositProductsTemplate.periodFrequencyTypeOptions || [];
const isEditing = !!this.fixedDepositProductsTemplate.id; const isEditing = !!this.fixedDepositProductsTemplate.id;
const defaultPeriodTypeId = this.periodFrequencyData[0]?.id ?? null;
const defaultAveragePeriod = this.averagePeriodData[0]?.value || 'Monthly'; const defaultAveragePeriod = this.averagePeriodData[0]?.value || 'Monthly';
const savedEnumTypeId = const savedEnumTypeId =
this.fixedDepositProductsTemplate.interestCalculationType?.id || this.interestCalculationTypeData?.[0]?.id || 1; this.fixedDepositProductsTemplate.interestCalculationType?.id || this.interestCalculationTypeData?.[0]?.id || 1;
@@ -84,12 +85,16 @@ export class FixedDepositProductTermsStepComponent implements OnInit, OnChanges
: (this.interestCalculationTypeOptionData?.[0]?.id ?? null); : (this.interestCalculationTypeOptionData?.[0]?.id ?? null);
this.fixedDepositProductTermsForm.patchValue({ this.fixedDepositProductTermsForm.patchValue({
// Hidden, unedited-by-anyone fields -- left blank (like their max-/in-multiples-of- siblings // Hidden, unedited-by-anyone fields. On EDIT, left as the product's own saved value with no
// already correctly are) rather than forced to a real default, or every single product edit // forced fallback (like their max-/in-multiples-of- siblings already correctly are), or a
// submitted a "real" value against a product that had none, and a checker's "Proposed changes" // checker's "Proposed changes" review showed these as changed on every unrelated edit, never
// review showed these two as "changed" on every unrelated edit, never anything a maker touched. // anything a maker touched. On CREATE there is no saved value yet, and the backend requires
minDepositTerm: this.fixedDepositProductsTemplate.minDepositTerm ?? '', // minDepositTerm -- default it (and its unit) here same as before, since the field is hidden
minDepositTermTypeId: this.fixedDepositProductsTemplate.minDepositTermType?.id ?? '', // and no one gets a chance to fill it in themselves.
minDepositTerm: isEditing ? (this.fixedDepositProductsTemplate.minDepositTerm ?? '') : 1,
minDepositTermTypeId: isEditing
? (this.fixedDepositProductsTemplate.minDepositTermType?.id ?? '')
: defaultPeriodTypeId,
maxDepositTerm: this.fixedDepositProductsTemplate.maxDepositTerm ?? '', maxDepositTerm: this.fixedDepositProductsTemplate.maxDepositTerm ?? '',
maxDepositTermTypeId: this.fixedDepositProductsTemplate.maxDepositTermType?.id ?? '', maxDepositTermTypeId: this.fixedDepositProductsTemplate.maxDepositTermType?.id ?? '',
inMultiplesOfDepositTerm: this.fixedDepositProductsTemplate.inMultiplesOfDepositTerm ?? '', inMultiplesOfDepositTerm: this.fixedDepositProductsTemplate.inMultiplesOfDepositTerm ?? '',