Fix for creating manual entries
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user