diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 1758a682c4..de941cc581 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -30,13 +30,6 @@ jobs: run: npm ci - name: Run Jest unit tests - # Non-blocking for now: 1 of 100 suites (2 tests) fails on dev, - # unrelated to CI/CD tooling. Both live in clients.component.spec.ts: - # one queries an `input[matInput]` the redesigned markup no longer - # renders, the other asserts takeUntilDestroyed teardown by calling - # ngOnDestroy() directly, which never triggers it. Tracked - # separately; drop continue-on-error once green so this gate blocks. - continue-on-error: true run: npm run test:ci - name: Upload coverage report diff --git a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.spec.ts b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.spec.ts index 5d5542c12c..ec7b721511 100644 --- a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.spec.ts +++ b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.spec.ts @@ -149,4 +149,16 @@ describe('LoansAccountTermsStepComponent — Working Capital edit mode', () => { expect(terms().periodPaymentRate).toBe(18); expect(terms().totalPaymentVolume).toBe(360); }); + + it('preserves an explicit 0 discount fee on edit', () => { + const accountWithZeroDiscount = { ...WC_LOAN_DETAILS, proposedDiscountFee: 0 }; + component.loansAccountProductTemplate = WC_LOAN_DETAILS; + component.loansAccountTemplate = accountWithZeroDiscount; + component.ngOnChanges({ + loansAccountProductTemplate: new SimpleChange(undefined, WC_LOAN_DETAILS, true) + }); + component.ngOnInit(); + + expect(terms().discount).toBe(0); + }); }); diff --git a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts index c05f5d3086..f0ed5e7b85 100644 --- a/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts +++ b/src/app/loans/loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component.ts @@ -366,9 +366,9 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp this.loansAccountTermsData = this.loansAccountTemplate; this.loansAccountTermsForm.patchValue({ discount: - this.loansAccountTermsData.proposedDiscountFee || - this.loansAccountTermsData.approvedDiscountFee || - this.loansAccountTermsData.discountFee || + this.loansAccountTermsData.proposedDiscountFee ?? + this.loansAccountTermsData.approvedDiscountFee ?? + this.loansAccountTermsData.discountFee ?? '', principalAmount: this.loansAccountTermsData.proposedPrincipal, periodPaymentRate: this.loansAccountTermsData.paymentRate, @@ -385,7 +385,7 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp // New Loan — solo inicializar si el producto realmente cambió } else if (productChanged) { this.loansAccountTermsForm.patchValue({ - discount: this.loansAccountTermsData.product.discount || '', + discount: this.loansAccountTermsData.product.discount ?? '', principalAmount: this.loansAccountTermsData.product.principal, delinquencyGraceDays: this.loansAccountTermsData.product.delinquencyGraceDays || '', delinquencyStartType: this.loansAccountTermsData.product.delinquencyStartType?.code || '', @@ -541,10 +541,19 @@ export class LoansAccountTermsStepComponent extends LoanProductBaseComponent imp if (this.loansAccountTermsData) { // Creating a new account: fall back to the product default for anything not yet set. this.loansAccountTermsForm.patchValue({ + discount: isEditingAccount + ? (this.loansAccountTermsData.proposedDiscountFee ?? + this.loansAccountTermsData.approvedDiscountFee ?? + this.loansAccountTermsData.discountFee ?? + '') + : (this.loansAccountTermsData.product?.discount ?? ''), principalAmount: isEditingAccount - ? this.loansAccountTermsData.principal + ? (this.loansAccountTermsData.proposedPrincipal ?? this.loansAccountTermsData.principal) : this.loansAccountTermsData.principal || this.loansAccountTermsData.product?.principal, - periodPaymentRate: this.loansAccountTermsData.periodPaymentRate, + periodPaymentRate: isEditingAccount + ? (this.loansAccountTermsData.paymentRate ?? this.loansAccountTermsData.periodPaymentRate) + : this.loansAccountTermsData.periodPaymentRate, + totalPaymentVolume: this.loansAccountTermsData.totalPaymentVolume, repaymentEvery: this.loansAccountTermsData.repaymentEvery, repaymentFrequencyType: this.loansAccountTermsData.repaymentFrequencyType?.id, delinquencyGraceDays: isEditingAccount diff --git a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.scss b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.scss index d6f53e7a7f..b501a59886 100644 --- a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.scss +++ b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.scss @@ -28,6 +28,7 @@ gap: 24px; padding: 16px 0; grid-template-columns: repeat(auto-fill, minmax(256px, 1fr)); /* stylelint-disable-line unit-allowed-list */ + align-items: stretch; } .data-item { diff --git a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.spec.ts b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.spec.ts index ca0d73c04d..a849670b13 100644 --- a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.spec.ts +++ b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.spec.ts @@ -25,6 +25,7 @@ import { SystemService } from 'app/system/system.service'; import { DateFormatPipe } from 'app/pipes/date-format.pipe'; import { DatetimeFormatPipe } from 'app/pipes/datetime-format.pipe'; import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component'; +import { UsersService } from 'app/users/users.service'; import { DatatableSingleRowComponent } from './datatable-single-row.component'; describe('DatatableSingleRowComponent', () => { @@ -125,6 +126,7 @@ describe('DatatableSingleRowComponent', () => { datetimeFormat: 'dd MMMM yyyy HH:mm' } }, + { provide: UsersService, useValue: { getUser: jest.fn(() => of({ firstname: 'Test', lastname: 'User' })) } }, { provide: TranslateService, useValue: translateService } ] }).compileComponents();