You've already forked openaccounting-web
mirror of
https://github.com/openaccounting/oa-web.git
synced 2025-12-09 09:01:24 +13:00
separate out date functions
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
AbstractControl
|
||||
} from '@angular/forms';
|
||||
import { Util } from '../shared/util';
|
||||
import { DateUtil } from '../shared/dateutil';
|
||||
import { OrgService } from '../core/org.service';
|
||||
import { TransactionService } from '../core/transaction.service';
|
||||
|
||||
@@ -50,7 +51,7 @@ export class AdvancedEdit {
|
||||
|
||||
this.org = this.orgService.getCurrentOrg();
|
||||
|
||||
let dateString = Util.getLocalDateString(item.tx.date, this.org.timezone);
|
||||
let dateString = DateUtil.getLocalDateString(item.tx.date, this.org.timezone);
|
||||
|
||||
this.form = new FormGroup({
|
||||
date: new FormControl(dateString),
|
||||
@@ -110,9 +111,9 @@ export class AdvancedEdit {
|
||||
this.error = null;
|
||||
|
||||
let date = this.item.tx.id ? this.item.tx.date : new Date();
|
||||
let formDate = Util.getDateFromLocalDateString(this.form.value.date, this.org.timezone);
|
||||
let formDate = DateUtil.getDateFromLocalDateString(this.form.value.date, this.org.timezone);
|
||||
|
||||
date = Util.computeTransactionDate(formDate, date, this.org.timezone);
|
||||
date = DateUtil.computeTransactionDate(formDate, date, this.org.timezone);
|
||||
|
||||
let tx = new Transaction({
|
||||
id: this.item.tx.id,
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
} from '@angular/forms';
|
||||
import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Util } from '../shared/util';
|
||||
import { DateUtil } from '../shared/dateutil';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/operator/mergeMap';
|
||||
import { AdvancedEdit } from './advancededit';
|
||||
@@ -76,8 +77,6 @@ export class TxListPage implements OnInit, AfterViewChecked {
|
||||
this.accountId = this.route.snapshot.paramMap.get('id'); //+this.route.snapshot.paramMap.get('id');
|
||||
this.org = this.orgService.getCurrentOrg();
|
||||
|
||||
console.log(this.org);
|
||||
|
||||
this.accountService.getAccountTree().subscribe(tree => {
|
||||
this.account = tree.accountMap[this.accountId];
|
||||
this.selectAccounts = tree.getFlattenedAccounts().filter(account => {
|
||||
@@ -95,7 +94,7 @@ export class TxListPage implements OnInit, AfterViewChecked {
|
||||
splits: []
|
||||
});
|
||||
|
||||
Util.setEndOfDay(newTx.date, this.org.timezone);
|
||||
DateUtil.setEndOfDay(newTx.date, this.org.timezone);
|
||||
|
||||
newTx.splits.push(new Split({
|
||||
accountId: this.account.id
|
||||
@@ -410,7 +409,7 @@ export class TxListPage implements OnInit, AfterViewChecked {
|
||||
|
||||
item.editing = true;
|
||||
|
||||
let dateString = Util.getLocalDateString(item.tx.date, this.org.timezone);
|
||||
let dateString = DateUtil.getLocalDateString(item.tx.date, this.org.timezone);
|
||||
|
||||
this.log.debug(item);
|
||||
let debit = this.getDebit(item);
|
||||
@@ -629,9 +628,9 @@ export class TxListPage implements OnInit, AfterViewChecked {
|
||||
}
|
||||
|
||||
let date = item.tx.id ? item.tx.date : new Date();
|
||||
let formDate = Util.getDateFromLocalDateString(item.form.value.date, this.org.timezone);
|
||||
let formDate = DateUtil.getDateFromLocalDateString(item.form.value.date, this.org.timezone);
|
||||
|
||||
date = Util.computeTransactionDate(formDate, date, this.org.timezone);
|
||||
date = DateUtil.computeTransactionDate(formDate, date, this.org.timezone);
|
||||
|
||||
let tx = new Transaction({
|
||||
id: item.tx.id,
|
||||
@@ -714,7 +713,7 @@ export class TxListPage implements OnInit, AfterViewChecked {
|
||||
splits: []
|
||||
});
|
||||
|
||||
Util.setEndOfDay(newTx.date, this.org.timezone);
|
||||
DateUtil.setEndOfDay(newTx.date, this.org.timezone);
|
||||
|
||||
newTx.splits.push(new Split({
|
||||
accountId: this.account.id
|
||||
@@ -832,11 +831,11 @@ export class TxListPage implements OnInit, AfterViewChecked {
|
||||
autocomplete(item: TxItem, tx: Transaction) {
|
||||
this.log.debug('chose tx', tx);
|
||||
|
||||
let formDate = Util.getDateFromLocalDateString(item.form.value.date, this.org.timezone);
|
||||
let formDate = DateUtil.getDateFromLocalDateString(item.form.value.date, this.org.timezone);
|
||||
item.tx = new Transaction(
|
||||
{
|
||||
id: item.tx.id,
|
||||
date: Util.computeTransactionDate(formDate, new Date(), this.org.timezone),
|
||||
date: DateUtil.computeTransactionDate(formDate, new Date(), this.org.timezone),
|
||||
description: tx.description,
|
||||
splits: tx.splits
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { TransactionService } from '../core/transaction.service';
|
||||
import { OrgService } from '../core/org.service';
|
||||
import { Account, AccountApi, AccountTree } from '../shared/account';
|
||||
import { Util } from '../shared/util';
|
||||
import { DateUtil } from '../shared/dateutil';
|
||||
import { AppError } from '../shared/error';
|
||||
import { Transaction, Split } from '../shared/transaction';
|
||||
import { Logger } from '../core/logger';
|
||||
@@ -62,7 +63,7 @@ export class NewTransactionPage {
|
||||
this.numAccountsShown = 3;
|
||||
this.org = this.orgService.getCurrentOrg();
|
||||
|
||||
let dateString = Util.getLocalDateString(new Date(), this.org.timezone);
|
||||
let dateString = DateUtil.getLocalDateString(new Date(), this.org.timezone);
|
||||
this.form = this.fb.group({
|
||||
type: ['', Validators.required],
|
||||
firstAccountPrimary: [null, Validators.required],
|
||||
@@ -226,9 +227,9 @@ export class NewTransactionPage {
|
||||
this.error = null;
|
||||
|
||||
let date = new Date();
|
||||
let formDate = Util.getDateFromLocalDateString(this.form.value.date, this.org.timezone);
|
||||
let formDate = DateUtil.getDateFromLocalDateString(this.form.value.date, this.org.timezone);
|
||||
|
||||
date = Util.computeTransactionDate(formDate, date, this.org.timezone);
|
||||
date = DateUtil.computeTransactionDate(formDate, date, this.org.timezone);
|
||||
|
||||
let tx = new Transaction({
|
||||
id: Util.newGuid(),
|
||||
|
||||
Reference in New Issue
Block a user