Fully working with the rule no explicit any
This commit is contained in:
@ -4,7 +4,8 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
name: 'clear',
|
||||
})
|
||||
export class ClearPipe implements PipeTransform {
|
||||
transform(value: any): any {
|
||||
transform(value: string | null): string {
|
||||
if (value === null) return '';
|
||||
return value === '₹ 0.00' || value === '0.00' ? '' : value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,6 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
export class ConfirmDialogComponent {
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
@Inject(MAT_DIALOG_DATA) public data: { title: string; content: string },
|
||||
) {}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
export class ImageDialogComponent {
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<ImageDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
@Inject(MAT_DIALOG_DATA) public data: string,
|
||||
) {}
|
||||
|
||||
close(): void {
|
||||
|
||||
@ -5,16 +5,6 @@ import { evaluate, round } from 'mathjs';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MathService {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
journalAmount(amount: string = '', debit: number): any {
|
||||
const val = this.parseAmount(amount, 2);
|
||||
let newDebit = debit;
|
||||
if (val < 0) {
|
||||
newDebit *= -1;
|
||||
}
|
||||
return { debit: newDebit, amount: Math.abs(val) };
|
||||
}
|
||||
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
parseAmount(amount: string = '', rounding: number = 2): number {
|
||||
const cleaned = `${amount}`.replace(new RegExp('(₹[s]*)|(,)|(s)', 'g'), '');
|
||||
|
||||
3
bookie/src/app/shared/to-csv-type.ts
Normal file
3
bookie/src/app/shared/to-csv-type.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface ToCsvType {
|
||||
[column: string]: string | number | boolean | null;
|
||||
}
|
||||
@ -1,15 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { ToCsvType } from './to-csv-type';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ToCsvService {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
toCsv(headers: any, data: any[]): string {
|
||||
toCsv(headers: { [display: string]: string }, data: unknown[]): string {
|
||||
const header = Object.keys(headers);
|
||||
const replacer = (key: string, value: string | number | null) => (value === null ? '' : value);
|
||||
const csv = data.map((row) =>
|
||||
header.map((fieldName) => JSON.stringify(row[headers[fieldName]], replacer)).join(','),
|
||||
header
|
||||
.map((fieldName) => JSON.stringify((row as ToCsvType)[headers[fieldName]], replacer))
|
||||
.join(','),
|
||||
);
|
||||
csv.unshift(header.join(','));
|
||||
return csv.join('\r\n');
|
||||
|
||||
Reference in New Issue
Block a user