Skip to content
Open
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
7 changes: 0 additions & 7 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 || '',
Expand Down Expand Up @@ -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
Comment thread
SatyamPandey-07 marked this conversation as resolved.
? (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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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();
Expand Down
Loading