Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/app/core/i18n/i18n.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Observable } from 'rxjs';
export class I18nService {
constructor(private translateService: TranslateService) {}

public translate(key: string): Observable<string> {
return this.translateService.get(key);
public translate(key: string, params?: object): Observable<string> {
return this.translateService.get(key, params);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** Angular Imports */
import { Component, QueryList, ViewChild, ViewChildren } from '@angular/core';
import { I18nService } from 'app/core/i18n/i18n.service';
import { ActivatedRoute, Router } from '@angular/router';

/** Custom Services */
Expand Down Expand Up @@ -84,7 +85,8 @@ export class CreateGlimAccountComponent {
private loansService: LoansService,
private settingsService: SettingsService,
private clientService: ClientsService,
private dateUtils: Dates
private dateUtils: Dates,
private i18nService: I18nService
) {
this.route.data.subscribe((data: { loansAccountTemplate: any; groupsData: any }) => {
this.loansAccountTemplate = data.loansAccountTemplate;
Expand Down Expand Up @@ -212,7 +214,7 @@ export class CreateGlimAccountComponent {
/** Request Body Data */
buildRequestData(): any[] {
const requestData = [];
const memberSelected = this.selectedMembers.selectedMembers;
const memberSelected = this.selectedMembers?.selectedMembers ?? [];
const totalLoan = this.totalLoanAmount();
for (let index = 0; index < memberSelected.length; index++) {
requestData.push({
Expand All @@ -227,7 +229,7 @@ export class CreateGlimAccountComponent {

totalLoanAmount(): number {
let total = 0;
const memberSelected = this.selectedMembers.selectedMembers;
const memberSelected = this.selectedMembers?.selectedMembers ?? [];
for (let index = 0; index < memberSelected.length; index++) {
total += memberSelected[index].principal;
}
Expand All @@ -238,6 +240,30 @@ export class CreateGlimAccountComponent {
* Creates a new GLIM account.
*/
submit() {
this.selectedMembers = this.loansActiveClientMembers?.selectedClientMembers;
const memberSelected = this.loansActiveClientMembers?.selectedClientMembers?.selectedMembers ?? [];
if (!memberSelected.length) return;
const gsimMemberIds = new Set(this.dataSource.map((m: any) => Number(m.id)));
for (const member of memberSelected) {
const memberId = Number(member.id);
// Validate savings account ownership
const ownerId = Number(member.linkAccountOwnerId);
if (member.linkAccountId && member.linkAccountOwnerId && ownerId !== memberId) {
this.i18nService.translate('errors.linkedSavingsAccountOwnership').subscribe((msg: string) => {
this.notify({ defaultUserMessage: msg, errors: [] }, { memberId });
});
return;
}
// Validate GSIM membership
if (!gsimMemberIds.has(memberId)) {
this.i18nService.translate('errors.clientNotInGSIM', { id: memberId }).subscribe((msg: string) => {
this.notify({ defaultUserMessage: msg, errors: [] }, { memberId });
});
return;
}
}

// 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.

const data = this.buildRequestData();
this.loansService.createGlimAccount(data).subscribe((response: any) => {
const body = JSON.parse(response[0].body);
Expand All @@ -250,15 +276,17 @@ export class CreateGlimAccountComponent {
{ relativeTo: this.route }
);
} else {
this.notify(body, data);
this.notify(body, { batchSize: data.length });
}
});
}

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, context?: { [k: string]: unknown }) {
const parts: string[] = [String(body?.defaultUserMessage ?? '')];
if (Array.isArray(body?.errors)) {
for (const e of body.errors) parts.push(String(e?.developerMessage ?? ''));
}
if (context) parts.push(`Context: ${JSON.stringify(context)}`);
console.error(parts.join(' ').trim());
}
}
2 changes: 2 additions & 0 deletions src/assets/translations/cs-CS.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "Přihlášen jako",
"Remember me": "Zapamatuj si mě",
"errors": {
"linkedSavingsAccountOwnership": "Propojený spořicí účet nepatří vybranému klientovi.",
"clientNotInGSIM": "Klient s ID {{id}} není přítomen v GSIM.",
"Capitalized Income amount adjusted already adjusted": "Výše kapitalizovaného příjmu již upravená",
"Capitalized Income Adjustment amount must be lower or equal to": "Částka úpravy kapitalizovaného příjmu musí být nižší nebo rovna",
"Buy Down Fee amount already adjusted": "Výše poplatku za odkup již byla upravena",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "Angemeldet als",
"Remember me": "Erinnere dich an mich",
"errors": {
"linkedSavingsAccountOwnership": "Verknüpftes Sparkonto gehört nicht zum ausgewählten Kunden.",
"clientNotInGSIM": "Kunde mit der ID {{id}} ist nicht in GSIM vorhanden.",
"Capitalized Income amount adjusted already adjusted": "Kapitalisiertes Einkommen Betrag angepasst bereits angepasst",
"Capitalized Income Adjustment amount must be lower or equal to": "Der Betrag der kapitalisierten Einkommensanpassung muss kleiner oder gleich sein",
"Buy Down Fee amount already adjusted": "Kapitalisierte Erträge Betrag angepasst bereits angepasst",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "Logged in as",
"Remember me": "Remember me",
"errors": {
"linkedSavingsAccountOwnership": "Linked savings account does not belong to the selected client.",
"clientNotInGSIM": "Client with ID {{id}} is not present in GSIM.",
"Capitalized Income amount adjusted already adjusted": "Capitalized Income amount already adjusted",
"Capitalized Income Adjustment amount must be lower or equal to": "Capitalized Income Adjustment amount must be lower or equal to",
"Buy Down Fee amount already adjusted": "Buy Down Fee amount already adjusted",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/es-CL.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "Conectado como",
"Remember me": "Recordar me",
"errors": {
"linkedSavingsAccountOwnership": "La cuenta de ahorro vinculada no pertenece al cliente seleccionado.",
"clientNotInGSIM": "El cliente con ID {{id}} no está presente en GSIM.",
"Capitalized Income amount adjusted already adjusted": "Monto de Ingreso Capitalizado ajustado ya ajustado",
"Capitalized Income Adjustment amount must be lower or equal to": "El monto del Ajuste de Ingreso Capitalizado debe ser menor o igual a",
"Buy Down Fee amount already adjusted": "Importe de la comisión de recompra ya ajustado",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/es-MX.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "Conectado como",
"Remember me": "Recordar me",
"errors": {
"linkedSavingsAccountOwnership": "La cuenta de ahorro vinculada no pertenece al cliente seleccionado.",
"clientNotInGSIM": "El cliente con ID {{id}} no está presente en GSIM.",
"Capitalized Income amount adjusted already adjusted": "Monto de Ingreso Capitalizado ajustado ya ajustado",
"Capitalized Income Adjustment amount must be lower or equal to": "El monto del Ajuste de Ingreso Capitalizado debe ser menor o igual a",
"Buy Down Fee amount already adjusted": "Importe de la comisión de recompra ya ajustado",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "connecté en tant que",
"Remember me": "Souviens-toi de moi",
"errors": {
"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.",
"Capitalized Income amount adjusted already adjusted": "Montant du revenu capitalisé ajusté déjà ajusté",
"Capitalized Income Adjustment amount must be lower or equal to": "Le montant de l'ajustement du revenu capitalisé doit être inférieur ou égal à",
"Buy Down Fee amount already adjusted": "Montant de la commission de rachat déjà ajusté",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "Collegato come",
"Remember me": "Ricordati di me",
"errors": {
"linkedSavingsAccountOwnership": "Il conto di risparmio collegato non appartiene al cliente selezionato.",
"clientNotInGSIM": "Il cliente con ID {{id}} non è presente in GSIM.",
"Capitalized Income amount adjusted already adjusted": "Importo del reddito capitalizzato rettificato già rettificato",
"Capitalized Income Adjustment amount must be lower or equal to": "L'importo dell'adeguamento del reddito capitalizzato deve essere inferiore o uguale a",
"Buy Down Fee amount already adjusted": "Importo della Buy Down Fee già adeguato",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/ko-KO.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "다음 계정으로 로그인됨",
"Remember me": "날 기억해",
"errors": {
"linkedSavingsAccountOwnership": "연결된 저축 계좌가 선택한 클라이언트에 속하지 않습니다.",
"clientNotInGSIM": "ID가 {{id}}인 클라이언트가 GSIM에 없습니다.",
"Capitalized Income amount adjusted already adjusted": "자본화된 소득 금액은 이미 조정되었습니다.",
"Capitalized Income Adjustment amount must be lower or equal to": "자본화된 소득 조정 금액은 다음보다 낮거나 같아야 합니다.",
"Buy Down Fee amount already adjusted": "이미 조정된 바이 다운 수수료 금액",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/lt-LT.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "prisijungęs kaip",
"Remember me": "Prisimink mane",
"errors": {
"linkedSavingsAccountOwnership": "Susieta taupomoji sąskaita nepriklauso pasirinktam klientui.",
"clientNotInGSIM": "Klientas su ID {{id}} nėra GSIM sistemoje.",
"Capitalized Income amount adjusted already adjusted": "Kapitalizuotų pajamų suma pakoreguota jau pakoreguota",
"Capitalized Income Adjustment amount must be lower or equal to": "Kapitalizuotų pajamų koregavimo suma turi būti mažesnė arba lygi",
"Buy Down Fee amount already adjusted": "Jau pakoreguota išpirkimo mokesčio suma",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/lv-LV.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "ielogojies Kā",
"Remember me": "Atceries mani",
"errors": {
"linkedSavingsAccountOwnership": "Saistītais krājkonts nepieder izvēlētajam klientam.",
"clientNotInGSIM": "Klients ar ID {{id}} nav GSIM sistēmā.",
"Capitalized Income amount adjusted already adjusted": "Kapitalizēto ienākumu summa jau koriģēta",
"Capitalized Income Adjustment amount must be lower or equal to": "Kapitalizēto ienākumu korekcijas summai ir jābūt mazākai vai vienādai ar",
"Buy Down Fee amount already adjusted": "Jau koriģētā atpirkšanas maksas summa",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/ne-NE.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "को रूपमा लग इन गरियो",
"Remember me": "मलाई सम्झनुहोस्",
"errors": {
"linkedSavingsAccountOwnership": "लिंक गरिएको बचत खाता चयनित ग्राहकको होइन।",
"clientNotInGSIM": "आईडी {{id}} भएको ग्राहक GSIM मा उपस्थित छैन।",
"Capitalized Income amount adjusted already adjusted": "क्यापिटलाइज्ड आय रकम पहिले नै समायोजन गरिएको छ",
"Capitalized Income Adjustment amount must be lower or equal to": "पूंजीकृत आय समायोजन रकम कम वा बराबर हुनुपर्छ",
"Buy Down Fee amount already adjusted": "बाइ डाउन शुल्क रकम पहिले नै समायोजन गरिएको छ।",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "logado como",
"Remember me": "Lembre de mim",
"errors": {
"linkedSavingsAccountOwnership": "A conta poupança vinculada não pertence ao cliente selecionado.",
"clientNotInGSIM": "O cliente com ID {{id}} não está presente no GSIM.",
"Capitalized Income amount adjusted already adjusted": "Valor da Renda Capitalizada ajustado já ajustado",
"Capitalized Income Adjustment amount must be lower or equal to": "O valor do ajuste de renda capitalizada deve ser menor ou igual a",
"Buy Down Fee amount already adjusted": "Montante da comissão de compra já ajustado",
Expand Down
2 changes: 2 additions & 0 deletions src/assets/translations/sw-SW.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Logged in as": "Imeingia kama",
"Remember me": "Nikumbuke",
"errors": {
"linkedSavingsAccountOwnership": "Akaunti ya akiba iliyounganishwa haimilikiwi na mteja aliyechaguliwa.",
"clientNotInGSIM": "Mteja mwenye kitambulisho {{id}} hayupo kwenye GSIM.",
"Capitalized Income amount adjusted already adjusted": "Kiasi cha Mapato ya Mtaji kilichorekebishwa tayari kimerekebishwa",
"Capitalized Income Adjustment amount must be lower or equal to": "Kiasi cha Marekebisho ya Mapato ya Mtaji lazima kiwe chini au sawa na",
"Buy Down Fee amount already adjusted": "Kiasi cha Ada ya Kununua Chini tayari kimerekebishwa",
Expand Down