feat(investment): FD TDS fields, GOI interest to the paisa, compact home reminders, deal no in holdings and settle guard
This commit is contained in:
@@ -139,7 +139,7 @@ export class FdInvestmentComponent implements OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.investmentService.getParties().subscribe({
|
||||
next: (ps) => (this.fdParties = ps.filter((p) => p.bondType === 'FD' && p.active)),
|
||||
next: (ps) => (this.fdParties = ps.filter((p) => p.bondType === 'FD' && p.active && !!p.interestGlAccountId)),
|
||||
error: (err) => this.toast(`Could not load FD banks: ${apiErrorMessage(err)}`)
|
||||
});
|
||||
this.investmentService.getAssetGlAccounts().subscribe({
|
||||
@@ -162,9 +162,19 @@ export class FdInvestmentComponent implements OnInit {
|
||||
this.activeTab = tab;
|
||||
if (tab === 'purchase') {
|
||||
this.refreshQuote();
|
||||
} else if (tab === 'closure' && this.closure.fdId) {
|
||||
// Interest may have been posted on the other tab meanwhile: work the closure out again.
|
||||
this.refreshClosureQuote();
|
||||
} else if (tab === 'interest' && this.interestFdId) {
|
||||
this.loadSchedule();
|
||||
}
|
||||
}
|
||||
|
||||
/** A complete DD-MM-YYYY date: half-typed dates are not sent to the server. */
|
||||
private static fullDate(d: string | null | undefined): boolean {
|
||||
return !!d && /^\d{2}-\d{2}-\d{4}$/.test(d);
|
||||
}
|
||||
|
||||
private loadFds(): void {
|
||||
this.investmentService.getFds().subscribe({
|
||||
next: (list) => (this.fds = list),
|
||||
@@ -196,7 +206,7 @@ export class FdInvestmentComponent implements OnInit {
|
||||
/** Period (years / months / days) sets the maturity date; the maturity date can also be typed directly. */
|
||||
onPeriodChange(): void {
|
||||
const f = this.form;
|
||||
if (f.dealDate && (f.periodYears || f.periodMonths || f.periodDays)) {
|
||||
if (FdInvestmentComponent.fullDate(f.dealDate) && (f.periodYears || f.periodMonths || f.periodDays)) {
|
||||
f.maturityDate = addPeriod(f.dealDate, f.periodYears ?? 0, f.periodMonths ?? 0, f.periodDays ?? 0);
|
||||
}
|
||||
this.refreshQuote();
|
||||
@@ -206,6 +216,9 @@ export class FdInvestmentComponent implements OnInit {
|
||||
refreshQuote(): void {
|
||||
const f = this.form;
|
||||
this.quoteError = '';
|
||||
if (f.dealDate && !FdInvestmentComponent.fullDate(f.dealDate)) {
|
||||
return;
|
||||
}
|
||||
const params: Record<string, string | number> = {
|
||||
dealDate: f.dealDate || todayDDMMYYYY(),
|
||||
payout: f.payout,
|
||||
@@ -220,7 +233,7 @@ export class FdInvestmentComponent implements OnInit {
|
||||
if (f.intRate) {
|
||||
params['intRate'] = f.intRate;
|
||||
}
|
||||
if (f.maturityDate) {
|
||||
if (FdInvestmentComponent.fullDate(f.maturityDate)) {
|
||||
params['maturityDate'] = f.maturityDate;
|
||||
}
|
||||
this.investmentService.quoteFd(params).subscribe({
|
||||
@@ -315,6 +328,7 @@ export class FdInvestmentComponent implements OnInit {
|
||||
}
|
||||
|
||||
resetPurchase(): void {
|
||||
this.quoteError = '';
|
||||
this.form = this.blankForm();
|
||||
this.refreshQuote();
|
||||
}
|
||||
@@ -362,7 +376,8 @@ export class FdInvestmentComponent implements OnInit {
|
||||
if (this.payoutReceived) {
|
||||
body['receivedAmount'] = this.payoutReceived;
|
||||
}
|
||||
if (this.payoutTds) {
|
||||
// Blank TDS: the system works it out at the bank's rate; an entered figure (even 0) is used as it is.
|
||||
if (entered(this.payoutTds)) {
|
||||
body['tds'] = this.payoutTds;
|
||||
}
|
||||
if (this.payoutBankGlAccountId) {
|
||||
@@ -434,14 +449,29 @@ export class FdInvestmentComponent implements OnInit {
|
||||
this.closureQuote = null;
|
||||
return;
|
||||
}
|
||||
if (c.type === 'PREMATURE' && c.closeDate && !FdInvestmentComponent.fullDate(c.closeDate)) {
|
||||
return;
|
||||
}
|
||||
const params: Record<string, string | number> = { type: c.type };
|
||||
if (c.type === 'PREMATURE' && c.closeDate) {
|
||||
params['closeDate'] = c.closeDate;
|
||||
}
|
||||
if (c.type === 'RENEWAL') {
|
||||
if (c.diffBankGlAccountId) {
|
||||
params['diffBankGlAccountId'] = c.diffBankGlAccountId;
|
||||
}
|
||||
} else {
|
||||
if (c.principalBankGlAccountId) {
|
||||
params['principalBankGlAccountId'] = c.principalBankGlAccountId;
|
||||
}
|
||||
if (c.interestBankGlAccountId) {
|
||||
params['interestBankGlAccountId'] = c.interestBankGlAccountId;
|
||||
}
|
||||
}
|
||||
if (c.receivedAmount) {
|
||||
params['receivedAmount'] = c.receivedAmount;
|
||||
}
|
||||
if (c.tds) {
|
||||
if (entered(c.tds)) {
|
||||
params['tds'] = c.tds;
|
||||
}
|
||||
if (c.type === 'RENEWAL' && c.renewalAmount) {
|
||||
@@ -464,7 +494,7 @@ export class FdInvestmentComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
const base = { locale: 'en', dateFormat: 'dd-MM-yyyy', ...(c.remarks.trim() ? { remarks: c.remarks.trim() } : {}) };
|
||||
const tds = c.tds ? { tds: c.tds } : {};
|
||||
const tds = entered(c.tds) ? { tds: c.tds } : {};
|
||||
let body: object;
|
||||
if (c.type === 'RENEWAL') {
|
||||
if (!c.newCertNo.trim() || !c.newIntRate || !c.newMaturityDate) {
|
||||
@@ -587,3 +617,8 @@ export class FdInvestmentComponent implements OnInit {
|
||||
this.toastTimer = setTimeout(() => (this.toastVisible = false), 4000);
|
||||
}
|
||||
}
|
||||
|
||||
/** A number box the user filled in (0 counts; blank does not). */
|
||||
function entered(v: number | null | undefined | string): boolean {
|
||||
return v !== null && v !== undefined && v !== '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user