Fix for creating manual entries

This commit is contained in:
Jose Alberto Hernandez
2022-05-25 20:22:10 -05:00
parent 01abdde8ab
commit d48c223cba
9 changed files with 54 additions and 90 deletions
@@ -6,6 +6,7 @@ import { Router, ActivatedRoute } from '@angular/router';
/** Custom Services */
import { AccountingService } from '../accounting.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
/**
* Create Journal Entry component.
*/
@@ -42,6 +43,7 @@ export class CreateJournalEntryComponent implements OnInit {
constructor(private formBuilder: FormBuilder,
private accountingService: AccountingService,
private settingsService: SettingsService,
private dateUtils: Dates,
private route: ActivatedRoute,
private router: Router) {
this.route.data.subscribe((data: {
@@ -138,17 +140,8 @@ export class CreateJournalEntryComponent implements OnInit {
// TODO: Update once language and date settings are setup
journalEntry.locale = this.settingsService.language.code;
journalEntry.dateFormat = this.settingsService.dateFormat;
if (journalEntry.transactionDate instanceof Date) {
let day = journalEntry.transactionDate.getDate();
let month = journalEntry.transactionDate.getMonth() + 1;
const year = journalEntry.transactionDate.getFullYear();
if (day < 10) {
day = `0${day}`;
}
if (month < 10) {
month = `0${month}`;
}
journalEntry.transactionDate = `${year}-${month}-${day}`;
if (journalEntry.transactionDate) {
journalEntry.transactionDate = this.dateUtils.getDate(journalEntry.transactionDate);
}
this.accountingService.createJournalEntry(journalEntry).subscribe(response => {
this.router.navigate(['../transactions/view', response.transactionId], { relativeTo: this.route });