mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
add server to monorepo.
This commit is contained in:
35
packages/server/src/repositories/ExpenseRepository.ts
Normal file
35
packages/server/src/repositories/ExpenseRepository.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import TenantRepository from "./TenantRepository";
|
||||
import moment from "moment";
|
||||
import { Expense } from 'models';
|
||||
|
||||
export default class ExpenseRepository extends TenantRepository {
|
||||
/**
|
||||
* Gets the repository's model.
|
||||
*/
|
||||
get model() {
|
||||
return Expense.bindKnex(this.knex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish the given expense.
|
||||
* @param {number} expenseId
|
||||
*/
|
||||
publish(expenseId: number): Promise<void> {
|
||||
return super.update({
|
||||
id: expenseId,
|
||||
publishedAt: moment().toMySqlDateTime(),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes the given expenses in bulk.
|
||||
* @param {number[]} expensesIds
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async whereIdInPublish(expensesIds: number): Promise<void> {
|
||||
await this.model.query().whereIn('id', expensesIds).patch({
|
||||
publishedAt: moment().toMySqlDateTime(),
|
||||
});
|
||||
this.flushCache();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user