mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
fix: expense publish db column.
This commit is contained in:
@@ -8,7 +8,7 @@ exports.up = function(knex) {
|
||||
table.integer('payment_account_id').unsigned();
|
||||
table.integer('payee_id').unsigned();
|
||||
table.string('reference_no');
|
||||
table.boolean('published').defaultTo(false);
|
||||
table.date('published_at');
|
||||
table.integer('user_id').unsigned();
|
||||
table.date('payment_date');
|
||||
table.timestamps();
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface IExpense {
|
||||
paymentAccountId: number,
|
||||
peyeeId?: number,
|
||||
referenceNo?: string,
|
||||
published: boolean,
|
||||
publishedAt: Date|null,
|
||||
userId: number,
|
||||
paymentDate: Date,
|
||||
|
||||
@@ -29,7 +29,7 @@ export interface IExpenseDTO {
|
||||
paymentAccountId: number,
|
||||
peyeeId?: number,
|
||||
referenceNo?: string,
|
||||
published: boolean,
|
||||
publish: boolean,
|
||||
userId: number,
|
||||
paymentDate: Date,
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import TenantRepository from "./TenantRepository";
|
||||
import { IExpense } from 'interfaces';
|
||||
import moment from "moment";
|
||||
|
||||
export default class ExpenseRepository extends TenantRepository {
|
||||
models: any;
|
||||
@@ -31,7 +32,11 @@ export default class ExpenseRepository extends TenantRepository {
|
||||
}
|
||||
|
||||
publish(expenseId: number) {
|
||||
const { Expense } = this.models;
|
||||
|
||||
return Expense.query().findById(expenseId).patch({
|
||||
publishedAt: moment().toMySqlDateTime(),
|
||||
});
|
||||
}
|
||||
|
||||
delete(expenseId: number) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Service, Inject } from "typedi";
|
||||
import { difference, sumBy } from 'lodash';
|
||||
import { difference, sumBy, omit } from 'lodash';
|
||||
import moment from "moment";
|
||||
import { ServiceError } from "exceptions";
|
||||
import TenancyService from 'services/Tenancy/TenancyService';
|
||||
@@ -244,14 +244,16 @@ export default class ExpensesService implements IExpensesService {
|
||||
const totalAmount = sumBy(expenseDTO.categories, 'amount');
|
||||
|
||||
return {
|
||||
published: false,
|
||||
categories: [],
|
||||
...expenseDTO,
|
||||
...omit(expenseDTO, ['publish']),
|
||||
totalAmount,
|
||||
paymentDate: moment(expenseDTO.paymentDate).toMySqlDateTime(),
|
||||
...(user) ? {
|
||||
userId: user.id,
|
||||
} : {},
|
||||
...(expenseDTO.publish) ? {
|
||||
publishedAt: moment().toMySqlDateTime(),
|
||||
} : {},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user