Skip to content

WEB-342: Advance Accounting rule can not be edited for classification type#2702

Merged
adamsaghy merged 1 commit intoopenMF:devfrom
alberto-art3ch:WEB-342/advance-accounting-rule-can-not-be-edited-for-classification-type
Oct 10, 2025
Merged

WEB-342: Advance Accounting rule can not be edited for classification type#2702
adamsaghy merged 1 commit intoopenMF:devfrom
alberto-art3ch:WEB-342/advance-accounting-rule-can-not-be-edited-for-classification-type

Conversation

@alberto-art3ch
Copy link
Copy Markdown
Collaborator

@alberto-art3ch alberto-art3ch commented Oct 7, 2025

Description

Advance Accounting rule can not be edited for classification type in the Buy Down Fee and Capitalized Income due the Edit button has not functionality linked

Related issues and discussion

WEB-342

Screenshots

Screen.Recording.2025-10-07.at.5.37.57.p.m.mov

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • If you have multiple commits please combine them into one commit by squashing them.

  • Read and understood the contribution guidelines at web-app/.github/CONTRIBUTING.md.

Summary by CodeRabbit

  • New Features

    • Edit now opens a form dialog, accepts the full item for editing, and updates the selected row immediately.
  • Bug Fixes

    • Edit dialog preselects classification and account fields correctly.
    • Editing updates only the intended row without mutating others.
    • More reliable launch of edits from the actions menu.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 7, 2025

Walkthrough

Edits template to pass both item and index to edit(). Adds edit(record, index) and updateTableData(updatedData, index) to open a form dialog, map dialog responses to AccountingMappingDTO for specific form types, immutably replace a table row, and emit updated table data. Adjusts select value mappings and guards GL account access.

Changes

Cohort / File(s) Summary of changes
Template change
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html
Renamed cell variable to item and changed edit handler to edit(item, i) instead of edit(i); delete action unchanged.
Component logic
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts
Added edit(record: AccountingMappingDTO, index: number) and updateTableData(updatedData: AccountingMappingDTO, index: number); edit opens form dialog, maps dialog responses to AccountingMappingDTO for certain form types, calls updateTableData (immutable row replace), and emits updated table data; adjusted form field value mappings to use value.id / glAccount.id; guarded getGlAccountData against missing glAccountData.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Component as AdvancedAccountingMappingRuleComponent
  participant Dialog as FormDialog
  participant Table as TableData
  participant Parent as ParentEmitter

  User->>Component: Click Edit(item, index)
  Component->>Dialog: Open dialog with record
  Dialog-->>Component: Return response
  alt response requires mapping
    Component->>Component: Map response → AccountingMappingDTO
  else no mapping needed
    Component->>Component: Use dialog response as-is
  end
  Component->>Table: updateTableData(updatedRow, index) (immutable replace)
  Component->>Parent: Emit updated table data
  Dialog-->>Component: Close
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • gkbishnoi07

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly references the primary change by identifying the issue of not being able to edit the Advance Accounting rule for classification type and aligns with the JIRA key. It is concise, specific, and free of extraneous details, allowing teammates to understand the main purpose of the pull request at a glance.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (1)

291-315: Fix default value access pattern for edit mode.

The default values at lines 299 and 307 use incorrect property access. When editing, the values parameter is an AccountingMappingDTO object with nested value and glAccount properties, but the code accesses flat properties that don't exist on this structure. This inconsistency will cause the edit dialog to show incorrect pre-filled values.

Apply this diff to align with the AccountingMappingDTO structure:

       new SelectBase({
         controlName: 'chargeOffReasonCodeValueId',
         label: 'Charge-off reason',
-        value: values ? values.chargeOffReasonCodeValueId : reasonOptions[0].id,
+        value: values ? values.value.id : reasonOptions[0].id,
         options: { label: 'name', value: 'id', data: reasonOptions },
         required: true,
         order: 1
       }),
       new SelectBase({
         controlName: 'expenseAccountId',
         label: 'Expense Account',
-        value: values ? values.expenseAccountId : this.expenseAccountData[0].id,
+        value: values ? values.glAccount.id : this.expenseAccountData[0].id,
         options: { label: 'name', value: 'id', data: this.expenseAccountData },
         required: true,
         order: 2
       })
🧹 Nitpick comments (3)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (1)

156-156: Strengthen type safety on method signature.

The record parameter is typed as any, which bypasses TypeScript's type checking benefits.

Apply this diff to improve type safety:

-  edit(record: any, index: number) {
+  edit(record: AccountingMappingDTO, index: number) {
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html (2)

38-38: Add trackBy function for performance optimization.

The *ngFor directive should include a trackBy function to optimize change detection, especially when the table data changes frequently.

As per coding guidelines.

Add a trackBy function to the component:

trackByIndex(index: number, item: any): number {
  return index;
}

Then update the template:

-    <tr mat-row *matRowDef="let row; columns: tableDisplayedColumns"></tr>
+    <tr mat-row *matRowDef="let row; columns: tableDisplayedColumns; trackBy: trackByIndex"></tr>

38-38: Add trackBy function for better performance.

The table row iteration at line 38 (*matRowDef="let row; columns: tableDisplayedColumns") doesn't use a trackBy function. This can cause unnecessary re-renders when the table data changes.

As per coding guidelines: verify trackBy on *ngFor for Angular code.

Add a trackBy function in the component:

trackByIndex(index: number, item: any): number {
  return index;
}

Then update the template:

-    <tr mat-row *matRowDef="let row; columns: tableDisplayedColumns"></tr>
+    <tr mat-row *matRowDef="let row; columns: tableDisplayedColumns; trackBy: trackByIndex"></tr>

Alternatively, if items have unique identifiers, consider tracking by a stable property:

trackByValueId(index: number, item: AccountingMappingDTO): number {
  return item.value.id;
}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d742ad9 and 2d152df.

📒 Files selected for processing (2)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html (1 hunks)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (3 hunks)
👮 Files not reviewed due to content moderation or server errors (2)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html
🧬 Code graph analysis (1)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (2)
src/app/products/loan-products/models/loan-product.model.ts (1)
  • AccountingMappingDTO (209-212)
src/app/shared/form-dialog/formfield/model/select-base.ts (1)
  • SelectBase (19-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Lint, Build and Deploy
🔇 Additional comments (11)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (8)

136-142: LGTM! Clean immutable update pattern.

The method correctly implements an immutable row update using array spread and slice operations, which is important for Angular's change detection.


317-341: LGTM! Correct property access for AccountingMappingDTO.

The updated default values correctly access the nested value.id and glAccount.id properties from the AccountingMappingDTO structure, ensuring proper pre-population of form fields during edit operations.


136-142: LGTM! Clean immutable update pattern.

The method correctly implements an immutable array update by creating a new array without mutating the existing state, which is excellent for Angular change detection.


136-142: LGTM! Immutable update pattern is correct.

The method correctly implements an immutable update by creating a new array with slicing, which is good for Angular change detection.


160-174: Consider handling additional form types in the edit method.

The edit method only handles BuydownFeeClassificationToIncome and CapitalizedIncomeClassificationToIncome, while the add method (lines 100-118) also handles ChargeOffReasonExpense and WriteOffReasonToExpense. Should edit functionality be available for these form types as well?

If these form types should also be editable, consider applying a similar pattern:

if ([
    'ChargeOffReasonExpense',
    'WriteOffReasonToExpense'
  ].includes(this.formType)) {
  const updateData: AccountingMappingDTO = {
    value: this.getValueData(response.data.value.chargeOffReasonCodeValueId),
    glAccount: this.getGlAccountData(response.data.value.expenseAccountId)
  };
  this.updateTableData(updateData, index);
}

Note: If the PR scope is intentionally limited to classification types only, this is acceptable.


333-333: Verify the glAccount property access is consistent.

Similar to line 325, this change correctly uses the nested glAccount.id property from the AccountingMappingDTO structure.


291-315: Potential inconsistency in getChargeOffReasonExpenseFormfields.

Line 299 uses values.chargeOffReasonCodeValueId when values is provided. However, based on the pattern in getClassificationIncomeFormfields (line 325) where nested properties are accessed (values.value.id), this might need similar treatment if the edit flow is extended to handle ChargeOffReasonExpense form type.

Verify whether ChargeOffReasonExpense records follow the same AccountingMappingDTO structure. If they do, line 299 should be:

value: values ? values.value.id : reasonOptions[0].id,

And line 307 should be:

value: values ? values.glAccount.id : this.expenseAccountData[0].id,

Note: This is only relevant if the edit functionality is extended to support this form type.


325-325: Approve nested property access
The nested access values.value.id aligns with AccountingMappingDTO.value: CodeValue and edit(record,…) passes the correct DTO.

src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html (3)

27-28: LGTM! Correct parameter passing for edit functionality.

The updated edit button correctly passes both the item object and its index to the edit method, enabling proper pre-population of form fields with existing data.


27-28: LGTM! Edit button now correctly passes item data.

The changes properly pass both the item object and its index to the edit() method, enabling the edit functionality.


27-28: LGTM! Template changes correctly support the edit flow.

The changes properly pass both the item object and its index to the edit method, enabling the edit functionality to access the record data.

@alberto-art3ch alberto-art3ch force-pushed the WEB-342/advance-accounting-rule-can-not-be-edited-for-classification-type branch from 2d152df to 10baa73 Compare October 7, 2025 23:14
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (1)

156-185: Add edit branches for remaining form types.

The edit() method still lacks support for PaymentFundSource, FeesIncome, and PenaltyIncome form types, which are supported in the add() method. Users can add these mapping rules but cannot edit them, creating an inconsistent user experience.

This issue was previously flagged in past review comments. Please implement the missing branches following the same pattern as the existing ones.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d152df and 10baa73.

📒 Files selected for processing (2)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html (1 hunks)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts
🧬 Code graph analysis (1)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (2)
src/app/products/loan-products/models/loan-product.model.ts (1)
  • AccountingMappingDTO (209-212)
src/app/shared/form-dialog/formfield/model/select-base.ts (1)
  • SelectBase (19-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Lint, Build and Deploy
🔇 Additional comments (3)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (3)

136-142: LGTM! Clean immutable update pattern.

The implementation correctly creates a new array without mutating the original, which is good practice for change detection.


335-335: LGTM! Correctly accesses nested DTO property.

The change from flat property access to values.value.id correctly aligns with the AccountingMappingDTO structure used in tableData.

However, note that getChargeOffReasonExpenseFormfields (Lines 307, 317) still uses flat properties (chargeOffReasonCodeValueId, expenseAccountId) instead of nested properties (values.value.id, values.glAccount.id). This inconsistency was flagged in previous review comments. Please ensure that all form field builders follow the same pattern for consistency.


343-343: LGTM! Correctly accesses nested DTO property.

The change from flat property access to values.glAccount.id correctly aligns with the AccountingMappingDTO structure used in tableData.

@alberto-art3ch alberto-art3ch force-pushed the WEB-342/advance-accounting-rule-can-not-be-edited-for-classification-type branch from 10baa73 to 186f86b Compare October 7, 2025 23:22
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (1)

88-94: Data structure inconsistency in add() method.

Line 90 accesses item.chargeOffReasonCodeValueId, which assumes a flat structure. However, after the changes in this PR, tableData should contain AccountingMappingDTO objects with nested structure (item.value.id).

Apply this diff to maintain consistency:

       this.allowAddAccountingMapping = true;
-      this.tableData.forEach((item: any) => this.currentFormValues.push(item.chargeOffReasonCodeValueId));
+      this.tableData.forEach((item: AccountingMappingDTO) => this.currentFormValues.push(item.value.id));
       if (this.accountingMappingOptions.length == this.currentFormValues.length) {
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10baa73 and 186f86b.

📒 Files selected for processing (2)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html (1 hunks)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts
🧬 Code graph analysis (1)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (2)
src/app/products/loan-products/models/loan-product.model.ts (1)
  • AccountingMappingDTO (209-212)
src/app/shared/form-dialog/formfield/model/select-base.ts (1)
  • SelectBase (19-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Lint, Build and Deploy
🔇 Additional comments (2)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (2)

136-142: LGTM! Clean immutable update pattern.

The method correctly creates a new array without mutating the original, following Angular best practices for change detection.


334-334: LGTM! Correct alignment with AccountingMappingDTO structure.

The value mappings now correctly access nested properties (values.value.id and values.glAccount.id), which aligns with the AccountingMappingDTO interface structure.

Based on coding guidelines

Also applies to: 342-342

@alberto-art3ch alberto-art3ch force-pushed the WEB-342/advance-accounting-rule-can-not-be-edited-for-classification-type branch from 186f86b to e744abe Compare October 8, 2025 00:12
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 186f86b and e744abe.

📒 Files selected for processing (2)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html (1 hunks)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.html
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts
🧬 Code graph analysis (1)
src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (3)
src/app/products/loan-products/models/loan-product.model.ts (1)
  • AccountingMappingDTO (209-212)
src/app/shared/form-dialog/formfield/model/select-base.ts (1)
  • SelectBase (19-27)
src/app/shared/models/general.model.ts (1)
  • GLAccount (13-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Lint, Build and Deploy

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 8, 2025

✅ Actions performed

Comments resolved.

1 similar comment
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 8, 2025

✅ Actions performed

Comments resolved.

Copy link
Copy Markdown
Collaborator

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adamsaghy adamsaghy merged commit 0a46b58 into openMF:dev Oct 10, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants