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