Skip to content

Conversation

JaySoni1
Copy link
Contributor

@JaySoni1 JaySoni1 commented Sep 17, 2025

Changes Made :-

-Added validation for savings account ownership and GSIM membership in GLIM loan.
-Enforced correct date format for loan submission.
-Enhanced error handling for invalid loan application scenarios.

WEB-113

Summary by CodeRabbit

  • New Features

    • Client-side validation on GLIM account creation: requires at least one member, verifies each member’s linked savings-account ownership and GSIM membership, and blocks invalid submissions with translated, contextual notices.
    • Notifications now present contextual messages (e.g., member IDs or batch sizes) instead of raw data.
  • Localization

    • Added new localized error messages across many locales, supporting parameterized IDs for clearer error text.

@JaySoni1
Copy link
Contributor Author

@steinwinde Please Review .

Copy link
Collaborator

@alberto-art3ch alberto-art3ch left a comment

Choose a reason for hiding this comment

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

Please review my comments

})
export class CreateGlimAccountComponent {
/** Date format for interestChargedFromDate and other dates */
_dateFormat: string = 'dd-MM-yy';
Copy link
Collaborator

Choose a reason for hiding this comment

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

why we need to use a fixed format? why we can not take this directly from the settings?

}

// Enforce date format for interestChargedFromDate
const dateFormat = 'dd-MM-yy';
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

@JaySoni1 JaySoni1 force-pushed the WEB-113-glim-application-fails-to-submit branch from 0e31f16 to e988834 Compare September 17, 2025 11:33
@JaySoni1
Copy link
Contributor Author

@alberto-art3ch Thank you for pointing that out! I was initially thinking of enforcing a fixed format for consistency, but your suggestion to use the format from settings makes more sense for localization and flexibility. I have updated the code accordingly.
Please Review .

Copy link
Collaborator

@steinwinde steinwinde left a comment

Choose a reason for hiding this comment

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

Sorry, but please don't use literal, untranslated English text in source code. Could you please add the text to the translation files? (These days, Copilot translates them automatically with sufficient (although not satisfactory) precision.)

@JaySoni1 JaySoni1 force-pushed the WEB-113-glim-application-fails-to-submit branch from e988834 to d2cbc59 Compare September 22, 2025 13:56
@JaySoni1
Copy link
Contributor Author

@steinwinde I have updated the PR please review.

@JaySoni1 JaySoni1 requested a review from steinwinde September 22, 2025 14:03
Copy link
Collaborator

@gkbishnoi07 gkbishnoi07 left a comment

Choose a reason for hiding this comment

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

Hey @JaySoni1, you’ve only added translations for the US locale. Could you also add the required translations for the other locales

@JaySoni1 JaySoni1 force-pushed the WEB-113-glim-application-fails-to-submit branch from d2cbc59 to adddf1a Compare September 29, 2025 13:39
Copy link

coderabbitai bot commented Sep 29, 2025

Walkthrough

Adds client-side member-selection and per-member validations to CreateGlimAccountComponent.submit(), injects I18nService into that component, extends I18nService.translate to accept params, changes notify() to accept optional context, and adds new localized error keys across multiple locale JSON files.

Changes

Cohort / File(s) Summary
GLIM account submit validation
src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts
Injected I18nService; used optional chaining/defaults for member selections and totals; added submit() validations to require selected members, verify each member’s linked savings-account ownership and GSIM membership, translate & notify on validation errors (passing context), abort on failure, and adjust notify calls in success/failure paths.
I18n service API
src/app/core/i18n/i18n.service.ts
Updated translate(key: string)translate(key: string, params?: object) and forwarded params to TranslateService.get.
Translations: new error keys (many locales)
src/assets/translations/{cs-CS,de-DE,en-US,es-CL,es-MX,fr-FR,it-IT,ko-KO,lt-LT,lv-LV,ne-NE,pt-PT,sw-SW}.json
Added linkedSavingsAccountOwnership and clientNotInGSIM under the errors / error objects in the listed locale files (messages include {{id}} where applicable); no other translation changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant C as CreateGlimAccountComponent
  participant V as ValidationLogic
  participant I as I18nService
  participant N as Notify

  U->>C: Click Submit
  C->>V: Resolve selectedMembers (safe access/default)
  alt no members
    C->>N: notify(body, { batchSize: 0 }) and return
  else members present
    loop per member
      C->>V: check linked savings account owner
      alt owner mismatch
        C->>I: translate('error.linkedSavingsAccountOwnership')
        I-->>C: localized message
        C->>N: notify(message, { memberId: member.id }) and abort
      else owner OK
        C->>V: check GSIM membership by id
        alt not in GSIM
          C->>I: translate('error.clientNotInGSIM', { id: member.id })
          I-->>C: localized message
          C->>N: notify(message, { memberId: member.id }) and abort
        else member OK
          C->>C: continue
        end
      end
    end
    alt all members valid
      C->>V: build request & create GLIM
      V-->>C: response (may include glimId)
      C->>N: notify(successBody, { batchSize: N }) or notify(errorBody)
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my nose at checks so neat,
I hop through members, one by one;
If savings stray or GSIM's bare,
I fetch the phrase and sound the gun.
A rabbit's tap — validation done. 🐇✨

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 references the GLIM application failing to submit, which aligns with the changeset’s focus on fixing that issue through added client-side validations, and it is concise and clear.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dca7364 and 95ad78c.

📒 Files selected for processing (15)
  • src/app/core/i18n/i18n.service.ts (1 hunks)
  • src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (6 hunks)
  • src/assets/translations/cs-CS.json (1 hunks)
  • src/assets/translations/de-DE.json (1 hunks)
  • src/assets/translations/en-US.json (1 hunks)
  • src/assets/translations/es-CL.json (1 hunks)
  • src/assets/translations/es-MX.json (1 hunks)
  • src/assets/translations/fr-FR.json (1 hunks)
  • src/assets/translations/it-IT.json (1 hunks)
  • src/assets/translations/ko-KO.json (1 hunks)
  • src/assets/translations/lt-LT.json (1 hunks)
  • src/assets/translations/lv-LV.json (1 hunks)
  • src/assets/translations/ne-NE.json (1 hunks)
  • src/assets/translations/pt-PT.json (1 hunks)
  • src/assets/translations/sw-SW.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (13)
  • src/assets/translations/fr-FR.json
  • src/assets/translations/de-DE.json
  • src/assets/translations/ko-KO.json
  • src/assets/translations/it-IT.json
  • src/assets/translations/lt-LT.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/es-MX.json
  • src/app/core/i18n/i18n.service.ts
  • src/assets/translations/ne-NE.json
  • src/assets/translations/cs-CS.json
  • src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts
  • src/assets/translations/sw-SW.json
  • src/assets/translations/es-CL.json
⏰ 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/assets/translations/pt-PT.json (1)

6-7: Translations look good

Both messages read naturally in Portuguese and preserve the required {{id}} placeholder.

src/assets/translations/en-US.json (1)

6-7: New error messages look solid

Both strings read clearly and the {{id}} placeholder aligns with the new parameterized translate() usage.


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

Copy link

@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: 7

🧹 Nitpick comments (7)
src/assets/translations/es-MX.json (1)

5-6: Ensure i18n key path matches usage (nested vs flat).

If the code calls translate('error.linkedSavingsAccountOwnership') / translate('error.clientNotInGSIM'), these should be nested under an "error" object; currently they’re flat keys with dots. Recommend nesting to avoid lookup misses.

Please confirm how I18nService is invoked in create-glim-account.component.ts. If it expects nested keys, apply:

-  "error.linkedSavingsAccountOwnership": "La cuenta de ahorro vinculada no pertenece al cliente seleccionado.",
-  "error.clientNotInGSIM": "El cliente con id {{id}} no está presente en GSIM.",
+  "error": {
+    "linkedSavingsAccountOwnership": "La cuenta de ahorro vinculada no pertenece al cliente seleccionado.",
+    "clientNotInGSIM": "El cliente con ID {{id}} no está presente en GSIM."
+  },
src/assets/translations/en-US.json (2)

5-6: Consider scoping under the existing errors namespace for consistency.

Most error strings live under the "errors" object; adding top‑level "error.*" keys diverges from that pattern. If the code expects keys under "errors", move them there; otherwise, keep as‑is but be consistent across locales.

Example adjustment inside the "errors" block (and remove the top‑level duplicates):

-  "error.linkedSavingsAccountOwnership": "Linked savings account does not belong to the selected client.",
-  "error.clientNotInGSIM": "Client with id {{id}} is not present in GSIM.",
+  "error.linkedSavingsAccountOwnership": "Linked savings account does not belong to the selected client.",
+  "error.clientNotInGSIM": "Client with ID {{id}} is not present in GSIM."

6-6: Tiny copyedit for clarity/case.

Prefer “ID” over “id”; optional: “not a member of GSIM.”

-  "error.clientNotInGSIM": "Client with id {{id}} is not present in GSIM.",
+  "error.clientNotInGSIM": "Client with ID {{id}} is not present in GSIM."

Alternative:

  • "Client with ID {{id}} is not a member of GSIM."
src/assets/translations/cs-CS.json (1)

5-6: i18n keys and usage verified

  • error.linkedSavingsAccountOwnership and error.clientNotInGSIM present in all locales and referenced in create-glim-account.component.ts.
  • {id} placeholder is substituted via msg.replace('{{id}}', member.id).
  • Optional Czech phrasing: consider “není v GSIMu” or “není členem GSIM” for a more natural tone.
src/assets/translations/ko-KO.json (1)

6-6: Optional: align terminology (“클라이언트” vs “고객”)

This locale mixes both terms. If you prefer “고객” (used widely elsewhere in this file), consider:

-  "error.clientNotInGSIM": "ID가 {{id}}인 클라이언트가 GSIM에 없습니다.",
+  "error.clientNotInGSIM": "ID가 {{id}}인 고객이 GSIM에 없습니다.",
src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (2)

247-253: Consider treating missing linkAccountOwnerId as invalid when linkAccountId is set

Current check only fails when both IDs exist and mismatch. If linkAccountId is chosen but owner is absent, you may want to block submission.


263-263: Resolve TODO or remove it

Either implement interestChargedFromDate formatting using settingsService.dateFormat, or drop the comment to avoid drift.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f763365 and adddf1a.

📒 Files selected for processing (14)
  • src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (3 hunks)
  • src/assets/translations/cs-CS.json (1 hunks)
  • src/assets/translations/de-DE.json (1 hunks)
  • src/assets/translations/en-US.json (1 hunks)
  • src/assets/translations/es-CL.json (1 hunks)
  • src/assets/translations/es-MX.json (1 hunks)
  • src/assets/translations/fr-FR.json (1 hunks)
  • src/assets/translations/it-IT.json (1 hunks)
  • src/assets/translations/ko-KO.json (1 hunks)
  • src/assets/translations/lt-LT.json (1 hunks)
  • src/assets/translations/lv-LV.json (1 hunks)
  • src/assets/translations/ne-NE.json (1 hunks)
  • src/assets/translations/pt-PT.json (1 hunks)
  • src/assets/translations/sw-SW.json (1 hunks)
⏰ 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/assets/translations/sw-SW.json (1)

5-6: Verify translation key usage and placeholder alignment

  • No occurrences of error.linkedSavingsAccountOwnership or error.clientNotInGSIM found in i18n calls; confirm these keys are actually used.
  • Ensure any calls to error.clientNotInGSIM supply { id } to match the {{id}} placeholder.
  • (Optional) for a more idiomatic Swahili passive, update the phrasing:
-  "error.linkedSavingsAccountOwnership": "Akaunti ya akiba iliyounganishwa haimilikiwi na mteja aliyechaguliwa.",
+  "error.linkedSavingsAccountOwnership": "Akaunti ya akiba iliyounganishwa haimilikiwa na mteja aliyechaguliwa.",
src/assets/translations/de-DE.json (1)

5-6: Confirm key usage – I found no TS/JS or HTML references for error.linkedSavingsAccountOwnership and error.clientNotInGSIM; remove them if unused or hook them into code to avoid dead translations.

src/assets/translations/it-IT.json (1)

5-6: LGTM! Translation keys properly added for GLIM loan validation.

The Italian translations for the new error messages look appropriate:

  • error.linkedSavingsAccountOwnership: Clear message about linked savings account ownership
  • error.clientNotInGSIM: Proper use of placeholder {{id}} for client ID interpolation

The translations are grammatically correct and follow the existing error message patterns in the file.

src/assets/translations/en-US.json (1)

5-6: Verify translation usage & interpolation

  • Presence of both keys confirmed across all locale files.
  • I didn’t find any code references to error.clientNotInGSIM; ensure it’s invoked with an { id } value (e.g. <FormattedMessage id="error.clientNotInGSIM" values={{ id }} /> or t('error.clientNotInGSIM', { id })).
  • Likewise, verify error.linkedSavingsAccountOwnership is used correctly with any required parameters.
src/assets/translations/fr-FR.json (1)

5-6: Retain top-level error. namespace*
Keys are present in every locale and components correctly reference them as top-level error.*; no namespace refactor needed.

src/assets/translations/ne-NE.json (1)

5-6: Root placement of these error keys is correct
They’re consistently defined at the root in every locale and directly referenced via i18nService.translate('error.linkedSavingsAccountOwnership') and translate('error.clientNotInGSIM'). No relocation needed.

Likely an incorrect or invalid review comment.

src/assets/translations/lt-LT.json (2)

5-6: Translation content LGTM.

Lithuanian phrasing and {{id}} placeholder look correct. No typos.

Please ensure the same phrasing and placeholder are present in en-US and other added locales for parity.


5-6: Keep flat dotted keys for error translations at root.
The error.clientNotInGSIM and error.linkedSavingsAccountOwnership entries follow the established pattern across all locales—error messages are defined as top-level keys with dotted prefixes. Introducing an error object here (and especially a singular instead of the existing errors grouping) would diverge from the convention and risk breaking lookups.

Likely an incorrect or invalid review comment.

src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (2)

3-3: LGTM: i18n import added to support localized errors


88-90: LGTM: injected Dates and I18nService
Constructor wiring is consistent with later usage.

src/assets/translations/pt-PT.json (1)

5-6: Verify flat dotted-key support or nest under “error”
We’ve added "error.linkedSavingsAccountOwnership" and "error.clientNotInGSIM" as flat keys across all locale files, but the codebase search didn’t reveal how the translation loader resolves dotted paths. Confirm that your i18n setup supports flat dotted-key lookups (e.g. translate.instant('error.clientNotInGSIM')); if not, nest these keys under an "error" object in each JSON.

@JaySoni1 JaySoni1 force-pushed the WEB-113-glim-application-fails-to-submit branch from adddf1a to 8eb96db Compare September 29, 2025 14:02
Copy link

@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/loans/glim-account/create-glim-account/create-glim-account.component.ts (1)

266-279: Handle HTTP errors and avoid silent failures

subscribe lacks an error handler; network/backend errors will result in no user feedback.

-    this.loansService.createGlimAccount(data).subscribe((response: any) => {
-      const body = JSON.parse(response[0].body);
-      if (body.glimId) {
-        this.router.navigate(
-          [
-            '../',
-            body.glimId
-          ],
-          { relativeTo: this.route }
-        );
-      } else {
-        this.notify(body, data);
-      }
-    });
+    this.loansService.createGlimAccount(data).subscribe({
+      next: (response: any) => {
+        const parsed = typeof response?.[0]?.body === 'string' ? JSON.parse(response[0].body) : response?.[0]?.body;
+        const body = parsed ?? {};
+        if (body.glimId) {
+          this.router.navigate(['../', body.glimId], { relativeTo: this.route });
+        } else {
+          this.notify(body, data);
+        }
+      },
+      error: (err) => {
+        this.notify(err?.error ?? { defaultUserMessage: 'GLIM submission failed', errors: [] }, data);
+      }
+    });
🧹 Nitpick comments (4)
src/app/core/i18n/i18n.service.ts (1)

12-13: Tighten params typing for safety

Prefer Record<string, unknown> over bare object to avoid structural typing pitfalls and improve DX.

-  public translate(key: string, params?: object): Observable<string> {
+  public translate(key: string, params?: Record<string, unknown>): Observable<string> {
     return this.translateService.get(key, params);
   }
src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (3)

246-257: Normalize ID types to avoid false negatives in includes

If any IDs are strings, includes can fail due to type mismatch.

-    const gsimMembers = this.dataSource.map((m: any) => m.id);
+    const gsimMembers = this.dataSource.map((m: any) => Number(m.id));
@@
-      if (!gsimMembers.includes(member.id)) {
+      if (!gsimMembers.includes(Number(member.id))) {

282-287: Reduce PII in logs

notify logs raw backend errors and full data payloads (member details, principals). Consider logging only minimal context in production.

Example:

-    message += 'Data: ' + JSON.stringify(data);
-    console.error(message);
+    const redacted = Array.isArray(data) ? `[${data.length} requests]` : `{ id: ${data?.id ?? 'n/a'} }`;
+    console.error(`${message} Context: ${redacted}`);

250-253: Add placeholders to linkedSavingsAccountOwnership translations before interpolation
The linkedSavingsAccountOwnership key currently has no {{id}} or {{accountId}} placeholders in any locale. Add these placeholders to the JSON entries if you intend to pass member.id and member.linkAccountId; otherwise, keep the static message.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between adddf1a and 8eb96db.

📒 Files selected for processing (15)
  • src/app/core/i18n/i18n.service.ts (1 hunks)
  • src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (3 hunks)
  • src/assets/translations/cs-CS.json (1 hunks)
  • src/assets/translations/de-DE.json (1 hunks)
  • src/assets/translations/en-US.json (1 hunks)
  • src/assets/translations/es-CL.json (1 hunks)
  • src/assets/translations/es-MX.json (1 hunks)
  • src/assets/translations/fr-FR.json (1 hunks)
  • src/assets/translations/it-IT.json (1 hunks)
  • src/assets/translations/ko-KO.json (1 hunks)
  • src/assets/translations/lt-LT.json (1 hunks)
  • src/assets/translations/lv-LV.json (1 hunks)
  • src/assets/translations/ne-NE.json (1 hunks)
  • src/assets/translations/pt-PT.json (1 hunks)
  • src/assets/translations/sw-SW.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (13)
  • src/assets/translations/it-IT.json
  • src/assets/translations/de-DE.json
  • src/assets/translations/ko-KO.json
  • src/assets/translations/fr-FR.json
  • src/assets/translations/en-US.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/cs-CS.json
  • src/assets/translations/lt-LT.json
  • src/assets/translations/ne-NE.json
  • src/assets/translations/es-MX.json
  • src/assets/translations/pt-PT.json
  • src/assets/translations/sw-SW.json
  • src/assets/translations/es-CL.json
⏰ 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/loans/glim-account/create-glim-account/create-glim-account.component.ts (2)

3-3: LGTM: i18n service import

Import aligns with new localized error handling in submit().


88-90: LGTM: constructor DI

Injecting Dates and I18nService is appropriate for date formatting and localized messages.

@JaySoni1 JaySoni1 force-pushed the WEB-113-glim-application-fails-to-submit branch from 8eb96db to e3e6a4e Compare September 29, 2025 14:18
Copy link

@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

🧹 Nitpick comments (2)
src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (2)

197-202: Follow-through: format interestChargedFromDate when present

The comment notes using settings’ date format; include it in the payload if the field is set.

       expectedDisbursementDate: this.dateUtils.formatDate(this.loansAccount.expectedDisbursementDate, dateFormat),
       submittedOnDate: this.dateUtils.formatDate(this.loansAccount.submittedOnDate, dateFormat),
+      ...(this.loansAccount.interestChargedFromDate
+        ? { interestChargedFromDate: this.dateUtils.formatDate(this.loansAccount.interestChargedFromDate, dateFormat) }
+        : {}),
       dateFormat,

282-287: Avoid logging full payloads; redact or surface via UI

notify() currently console.error’s the entire payload (can expose PII). Prefer user-visible toast/snackbar and minimal context in logs.

-  notify(body: any, data: any) {
-    let message = body.defaultUserMessage + ' ';
-    while (body.errors?.length > 0) message += body.errors.pop().developerMessage + ' ';
-    message += 'Data: ' + JSON.stringify(data);
-    console.error(message);
-  }
+  notify(body: any, data?: any) {
+    const parts = [body.defaultUserMessage];
+    if (Array.isArray(body.errors)) {
+      for (const e of body.errors) parts.push(e.developerMessage);
+    }
+    // Log minimal context to reduce PII exposure
+    const ctx = data?.id ? ` (context id: ${data.id})` : '';
+    console.warn(parts.join(' ') + ctx);
+    // TODO: optionally surface to UI via a Snackbar/NotificationService
+  }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8eb96db and e3e6a4e.

📒 Files selected for processing (15)
  • src/app/core/i18n/i18n.service.ts (1 hunks)
  • src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (5 hunks)
  • src/assets/translations/cs-CS.json (1 hunks)
  • src/assets/translations/de-DE.json (1 hunks)
  • src/assets/translations/en-US.json (1 hunks)
  • src/assets/translations/es-CL.json (1 hunks)
  • src/assets/translations/es-MX.json (1 hunks)
  • src/assets/translations/fr-FR.json (1 hunks)
  • src/assets/translations/it-IT.json (1 hunks)
  • src/assets/translations/ko-KO.json (1 hunks)
  • src/assets/translations/lt-LT.json (1 hunks)
  • src/assets/translations/lv-LV.json (1 hunks)
  • src/assets/translations/ne-NE.json (1 hunks)
  • src/assets/translations/pt-PT.json (1 hunks)
  • src/assets/translations/sw-SW.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/assets/translations/es-CL.json
  • src/assets/translations/es-MX.json
  • src/assets/translations/it-IT.json
  • src/assets/translations/ko-KO.json
  • src/assets/translations/cs-CS.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/pt-PT.json
  • src/app/core/i18n/i18n.service.ts
  • src/assets/translations/lt-LT.json
  • src/assets/translations/de-DE.json
⏰ 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 (8)
src/assets/translations/en-US.json (1)

5-8: Error strings wired for GSIM validation.

Thanks for adding localized messaging with the {{id}} placeholder; this will slot straight into the parameterized translate() updates so users see the right member context.

src/assets/translations/fr-FR.json (1)

5-8: Translations added correctly; keys exist in all locale files. No occurrences of error.linkedSavingsAccountOwnership or error.clientNotInGSIM were found in the codebase—please add or verify the corresponding i18nService.translate('error.linkedSavingsAccountOwnership') and i18nService.translate('error.clientNotInGSIM', { id }) calls.

src/assets/translations/sw-SW.json (1)

5-8: Translations look solid.

The new Swahili strings read naturally and keep the {{id}} placeholder intact, so they’ll render correctly in the UI.

src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (4)

3-3: LGTM: I18nService import added where needed.


88-90: LGTM: DI additions

Injecting Dates and I18nService here is appropriate for formatting and localized errors.


217-218: Good hardening of selectedMembers access

Optional chaining + default empty array prevents runtime errors flagged earlier.


232-233: Good: total calculation guarded

Prevents undefined access when computing totals.

src/assets/translations/ne-NE.json (1)

5-8: New error messages coverage confirmed across all locales

Both linkedSavingsAccountOwnership and clientNotInGSIM keys are present in every file under src/assets/translations.

@JaySoni1 JaySoni1 force-pushed the WEB-113-glim-application-fails-to-submit branch from e3e6a4e to 6a9f570 Compare September 29, 2025 14:30
Copy link

@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

🧹 Nitpick comments (3)
src/app/core/i18n/i18n.service.ts (1)

12-13: Tighten param typing for better DX

Prefer Record<string, unknown> (or a lib type) over bare object for params.

-  public translate(key: string, params?: object): Observable<string> {
+  public translate(key: string, params?: Record<string, unknown>): Observable<string> {
     return this.translateService.get(key, params);
   }
src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (2)

246-246: Name nit: clarify set semantics

gsimMemberIds is a Set; consider gsimMemberIdSet for readability.


265-265: Finish the date-format TODO (interestChargedFromDate)

If interestChargedFromDate can be set in loansAccount, format it with settings dateFormat before submit.

-    // Use date format from settingsService for interestChargedFromDate
+    // Use date format from settingsService for interestChargedFromDate
+    if (this.loansAccount?.interestChargedFromDate) {
+      const df = this.settingsService.dateFormat;
+      this.loansAccount.interestChargedFromDate =
+        this.dateUtils.formatDate(this.loansAccount.interestChargedFromDate, df);
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3e6a4e and 6a9f570.

📒 Files selected for processing (15)
  • src/app/core/i18n/i18n.service.ts (1 hunks)
  • src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (5 hunks)
  • src/assets/translations/cs-CS.json (1 hunks)
  • src/assets/translations/de-DE.json (1 hunks)
  • src/assets/translations/en-US.json (1 hunks)
  • src/assets/translations/es-CL.json (1 hunks)
  • src/assets/translations/es-MX.json (1 hunks)
  • src/assets/translations/fr-FR.json (1 hunks)
  • src/assets/translations/it-IT.json (1 hunks)
  • src/assets/translations/ko-KO.json (1 hunks)
  • src/assets/translations/lt-LT.json (1 hunks)
  • src/assets/translations/lv-LV.json (1 hunks)
  • src/assets/translations/ne-NE.json (1 hunks)
  • src/assets/translations/pt-PT.json (1 hunks)
  • src/assets/translations/sw-SW.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (12)
  • src/assets/translations/it-IT.json
  • src/assets/translations/sw-SW.json
  • src/assets/translations/es-CL.json
  • src/assets/translations/es-MX.json
  • src/assets/translations/en-US.json
  • src/assets/translations/cs-CS.json
  • src/assets/translations/de-DE.json
  • src/assets/translations/ne-NE.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/ko-KO.json
  • src/assets/translations/fr-FR.json
  • src/assets/translations/pt-PT.json
⏰ 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/loans/glim-account/create-glim-account/create-glim-account.component.ts (1)

217-217: Null-safe access for selectedMembers

Good defensive defaults to empty arrays; prevents runtime errors.

Also applies to: 232-232

src/assets/translations/lt-LT.json (1)

5-8: All locales include the new error keys
Verified presence of linkedSavingsAccountOwnership and clientNotInGSIM across all translation files.

@JaySoni1 JaySoni1 force-pushed the WEB-113-glim-application-fails-to-submit branch from 6a9f570 to dca7364 Compare September 29, 2025 14:40
Copy link

@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

🧹 Nitpick comments (4)
src/app/core/i18n/i18n.service.ts (1)

12-14: Tighten params typing for better DX and safety

Current params?: object works, but is loose. Prefer a constrained map type for interpolation params.

Apply:

@@
-import { TranslateService } from '@ngx-translate/core';
+import { TranslateService } from '@ngx-translate/core';
 import { Observable } from 'rxjs';
 
 @Injectable()
 export class I18nService {
   constructor(private translateService: TranslateService) {}
 
-  public translate(key: string, params?: object): Observable<string> {
+  public translate(key: string, params?: TranslateParams): Observable<string> {
     return this.translateService.get(key, params);
   }
 }

Add this type alias near the imports:

export type TranslateParams = Record<string, string | number | boolean>;

Optional: if you foresee translating multiple keys at once later, consider an overload or a dedicated translateMany(keys: string[], params?: TranslateParams): Observable<Record<string, string>>.

src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (3)

243-265: Harden ID normalization to avoid NaN edge cases

Casting with Number(...) can yield NaN for unexpected inputs, breaking Set membership and equality checks. Normalize with a single helper that falls back to string when non‑numeric.

-    const gsimMemberIds = new Set(this.dataSource.map((m: any) => Number(m.id)));
-    for (const member of memberSelected) {
-      const memberId = Number(member.id);
+    const normalizeId = (v: unknown) => {
+      const n = Number(v);
+      return Number.isFinite(n) ? n : String(v);
+    };
+    const gsimMemberIds = new Set(this.dataSource.map((m: any) => normalizeId(m.id)));
+    for (const member of memberSelected) {
+      const memberId = normalizeId(member.id);
       // Validate savings account ownership
-      const ownerId = Number(member.linkAccountOwnerId);
+      const ownerId = normalizeId(member.linkAccountOwnerId);
       if (member.linkAccountId && member.linkAccountOwnerId && ownerId !== memberId) {
         this.i18nService.translate('error.linkedSavingsAccountOwnership').subscribe((msg: string) => {
           this.notify({ defaultUserMessage: msg, errors: [] }, { memberId });
         });
         return;
       }
       // Validate GSIM membership
-      if (!gsimMemberIds.has(memberId)) {
+      if (!gsimMemberIds.has(memberId)) {
         this.i18nService.translate('error.clientNotInGSIM', { id: memberId }).subscribe((msg: string) => {
           this.notify({ defaultUserMessage: msg, errors: [] }, { memberId });
         });
         return;
       }
     }

268-281: Add error handler for createGlimAccount subscribe

Surface backend failures via notify for better UX and diagnostics.

-    this.loansService.createGlimAccount(data).subscribe((response: any) => {
+    this.loansService.createGlimAccount(data).subscribe({
+      next: (response: any) => {
         const body = JSON.parse(response[0].body);
         if (body.glimId) {
           this.router.navigate(
             [
               '../',
               body.glimId
             ],
             { relativeTo: this.route }
           );
         } else {
           this.notify(body, { batchSize: data.length });
         }
-      });
+      },
+      error: (err: any) => {
+        const body = err?.error ?? { defaultUserMessage: 'GLIM application creation failed' };
+        this.notify(body, { status: err?.status });
+      }
+    });

284-291: Sanitized logging looks good; cap context if needed

Console output avoids dumping payloads. Consider truncating or allow‑listing context fields to prevent accidental large logs in the future.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a9f570 and dca7364.

📒 Files selected for processing (15)
  • src/app/core/i18n/i18n.service.ts (1 hunks)
  • src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (6 hunks)
  • src/assets/translations/cs-CS.json (1 hunks)
  • src/assets/translations/de-DE.json (1 hunks)
  • src/assets/translations/en-US.json (1 hunks)
  • src/assets/translations/es-CL.json (1 hunks)
  • src/assets/translations/es-MX.json (1 hunks)
  • src/assets/translations/fr-FR.json (1 hunks)
  • src/assets/translations/it-IT.json (1 hunks)
  • src/assets/translations/ko-KO.json (1 hunks)
  • src/assets/translations/lt-LT.json (1 hunks)
  • src/assets/translations/lv-LV.json (1 hunks)
  • src/assets/translations/ne-NE.json (1 hunks)
  • src/assets/translations/pt-PT.json (1 hunks)
  • src/assets/translations/sw-SW.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
  • src/assets/translations/es-CL.json
  • src/assets/translations/pt-PT.json
  • src/assets/translations/ko-KO.json
  • src/assets/translations/lv-LV.json
  • src/assets/translations/es-MX.json
  • src/assets/translations/de-DE.json
  • src/assets/translations/it-IT.json
  • src/assets/translations/ne-NE.json
  • src/assets/translations/lt-LT.json
  • src/assets/translations/cs-CS.json
  • src/assets/translations/en-US.json
⏰ 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/assets/translations/sw-SW.json (1)

5-8: No issues found: error.* namespace and parameters are correct

  • Code consistently uses error.linkedSavingsAccountOwnership and error.clientNotInGSIM, matching the new keys.
  • The {{id}} placeholder is supplied via { id: memberId } in the .translate call.
  • Both keys exist in all locale JSONs, preventing fallback-to-key errors.
  • (Optional) you may consolidate error.* and errors.* namespaces for uniformity.
src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts (2)

88-90: Good addition: i18n and date utils injection

Matches PR intent to use settings-driven formats and localized messages.


217-218: Safe guards for optional selectedMembers

Using optional chaining with sane defaults prevents runtime errors in aggregate/build paths. LGTM.

Also applies to: 232-233

}
}

// Use date format from settingsService for interestChargedFromDate
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Complete TODO: format interestChargedFromDate using settings dateFormat

This is part of the PR objective; format it alongside submitted/disbursement dates to avoid server parse errors.

       expectedDisbursementDate: this.dateUtils.formatDate(this.loansAccount.expectedDisbursementDate, dateFormat),
       submittedOnDate: this.dateUtils.formatDate(this.loansAccount.submittedOnDate, dateFormat),
+      ...(this.loansAccount.interestChargedFromDate && {
+        interestChargedFromDate: this.dateUtils.formatDate(this.loansAccount.interestChargedFromDate, dateFormat)
+      }),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Use date format from settingsService for interestChargedFromDate
expectedDisbursementDate: this.dateUtils.formatDate(this.loansAccount.expectedDisbursementDate, dateFormat),
submittedOnDate: this.dateUtils.formatDate(this.loansAccount.submittedOnDate, dateFormat),
...(this.loansAccount.interestChargedFromDate && {
interestChargedFromDate: this.dateUtils.formatDate(this.loansAccount.interestChargedFromDate, dateFormat)
}),
🤖 Prompt for AI Agents
In
src/app/loans/glim-account/create-glim-account/create-glim-account.component.ts
around line 266, interestChargedFromDate is not being formatted with the
application's date format; format interestChargedFromDate the same way
submittedDate and disbursementDate are formatted using the settingsService date
format (e.g., settingsService.dateFormat or settingsService.getDateFormat()),
convert the date to a string in that format before assigning/sending it, and
include null/undefined checks so you only format when a date exists.

Comment on lines 5 to 8
"error": {
"linkedSavingsAccountOwnership": "Le compte d'épargne lié n'appartient pas au client sélectionné.",
"clientNotInGSIM": "Le client avec l'ID {{id}} n'est pas membre du GSIM."
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

LGTM: New error translations added; ensure locale coverage

Strings look good and match usage in code. Please verify these keys exist in all locale files referenced by the app.

Run to confirm coverage:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
missing=0
while IFS= read -r -d '' f; do
  for k in linkedSavingsAccountOwnership clientNotInGSIM; do
    if ! jq -e --arg k "$k" 'has("error") and .error | has($k)' "$f" >/dev/null; then
      echo "Missing .error.\"$k\" in $f"
      missing=1
    fi
  done
done < <(fd -a src/assets/translations -e json -0)
exit $missing

Length of output: 455


🏁 Script executed:

#!/bin/bash
set -euo pipefail
missing=0
while IFS= read -r -d '' f; do
  for k in linkedSavingsAccountOwnership clientNotInGSIM; do
    if ! jq -e --arg k "$k" 'has("error") and .error | has($k)' "$f" >/dev/null; then
      echo "Missing .error.\"$k\" in $f"
      missing=1
    fi
  done
done < <(find src/assets/translations -type f -name '*.json' -print0)
exit $missing

Length of output: 57


🏁 Script executed:

#!/bin/bash
set -euo pipefail
files=$(find src/assets/translations -type f -name '*.json')
for f in $files; do
  for k in linkedSavingsAccountOwnership clientNotInGSIM; do
    if ! jq -e --arg k "$k" 'has("error") and .error | has($k)' "$f" >/dev/null; then
      echo "Missing .error.\"$k\" in $f"
      exit 1
    fi
  done
done

Length of output: 1039


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail
for f in $(find src/assets/translations -type f -name '*.json'); do
  for k in linkedSavingsAccountOwnership clientNotInGSIM; do
    jq -e --arg k "$k" 'has("error") and .error | has($k)' "$f" >/dev/null || { echo "Missing .error.\"$k\" in $f"; exit 1; }
  done
done

Length of output: 186


Fix Czech translations and add missing error keys
The src/assets/translations/cs-CS.json file defines "error" as a non-object (boolean), so it’s missing both linkedSavingsAccountOwnership and clientNotInGSIM. Update that file (and any others) so that under "error" you have:

"error": {
  "linkedSavingsAccountOwnership": "...",
  "clientNotInGSIM": "..."
}

Ensure all locale JSON files include these two keys under "error".

🤖 Prompt for AI Agents
In src/assets/translations/fr-FR.json around lines 5 to 8: the review notes that
cs-CS.json (and potentially other locale files) define "error" as a non-object
(boolean) and are missing the keys linkedSavingsAccountOwnership and
clientNotInGSIM; update cs-CS.json (and audit other locale JSONs) to ensure
"error" is an object, add the two keys "linkedSavingsAccountOwnership" and
"clientNotInGSIM" with appropriate translations, and validate the JSON so every
locale has an "error" object containing those keys (preserve existing
translations and nesting).

@JaySoni1
Copy link
Contributor Author

JaySoni1 commented Sep 29, 2025

@steinwinde , @gkbishnoi07 I have updated the PR please review .

Copy link
Collaborator

@steinwinde steinwinde left a comment

Choose a reason for hiding this comment

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

Hi @JaySoni1 , you have added the translation to the translation file under a new top level "error" (when there is already an "errors" top level category). May I ask, why do you think your addition deserves to a new top level category? If you look at the translation files, the only other translations on top level are the app name, "login as", and "Remember me". And below there are already lots of categories and sub-categories. Can't you find an existing one for your case?

@JaySoni1
Copy link
Contributor Author

JaySoni1 commented Oct 2, 2025

@steinwinde Thank you for your review . I will update the PR .

@JaySoni1 JaySoni1 force-pushed the WEB-113-glim-application-fails-to-submit branch from dca7364 to 95ad78c Compare October 2, 2025 21:50
@JaySoni1
Copy link
Contributor Author

JaySoni1 commented Oct 2, 2025

@steinwinde I have updated the PR . Please review

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.

4 participants