Feature: Allow math expressions on all journal inputs and also round them properly.

Chore:
  Prettied index.html, main.ts and styles.css
  Updated Dependencies
This commit is contained in:
2020-10-07 18:42:22 +05:30
parent cefb3ebdcc
commit cfeef1795d
20 changed files with 202 additions and 120 deletions
@@ -1,11 +1,12 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
import { Account } from '../core/account';
import { AccountService } from '../core/account.service';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Observable, of as observableOf } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
import { MathService } from '../shared/math.service';
import { Account } from '../core/account';
import { AccountService } from '../core/account.service';
@Component({
selector: 'app-journal-dialog',
@@ -22,6 +23,7 @@ export class JournalDialogComponent implements OnInit {
public dialogRef: MatDialogRef<JournalDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
private fb: FormBuilder,
private math: MathService,
private accountSer: AccountService,
) {
this.createForm();
@@ -70,11 +72,10 @@ export class JournalDialogComponent implements OnInit {
accept(): void {
const formValue = this.form.value;
const debit = +formValue.debit;
const amount = +formValue.amount;
this.data.journal.debit = debit;
const amount = this.math.journalAmount(formValue.amount, +formValue.debit);
this.data.journal.debit = amount.debit;
this.data.journal.account = this.account;
this.data.journal.amount = amount;
this.data.journal.amount = amount.amount;
this.dialogRef.close(this.data.journal);
}
}