mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
feat(server): order tax rates by name
This commit is contained in:
@@ -22,7 +22,7 @@ export default class TaxRate extends mixin(TenantModel, [ModelSearchable]) {
|
|||||||
* Timestamps columns.
|
* Timestamps columns.
|
||||||
*/
|
*/
|
||||||
get timestamps() {
|
get timestamps() {
|
||||||
return ['created_at', 'updated_at'];
|
return ['createdAt', 'updatedAt'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Knex } from 'knex';
|
import { Knex } from 'knex';
|
||||||
import { Inject, Service } from 'typedi';
|
import { Inject, Service } from 'typedi';
|
||||||
|
import { omit } from 'lodash';
|
||||||
import {
|
import {
|
||||||
IEditTaxRateDTO,
|
IEditTaxRateDTO,
|
||||||
ITaxRate,
|
ITaxRate,
|
||||||
@@ -54,7 +55,7 @@ export class EditTaxRateService {
|
|||||||
private async editTaxRateOrCreate(
|
private async editTaxRateOrCreate(
|
||||||
tenantId: number,
|
tenantId: number,
|
||||||
oldTaxRate: ITaxRate,
|
oldTaxRate: ITaxRate,
|
||||||
editTaxRateDTO: any,
|
editTaxRateDTO: IEditTaxRateDTO,
|
||||||
trx?: Knex.Transaction
|
trx?: Knex.Transaction
|
||||||
) {
|
) {
|
||||||
const { TaxRate } = this.tenancy.models(tenantId);
|
const { TaxRate } = this.tenancy.models(tenantId);
|
||||||
@@ -68,6 +69,7 @@ export class EditTaxRateService {
|
|||||||
|
|
||||||
// Create a new tax rate with new edited data.
|
// Create a new tax rate with new edited data.
|
||||||
return TaxRate.query(trx).insertAndFetch({
|
return TaxRate.query(trx).insertAndFetch({
|
||||||
|
...omit(oldTaxRate, ['id']),
|
||||||
...editTaxRateDTO,
|
...editTaxRateDTO,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ export class GetTaxRatesService {
|
|||||||
public async getTaxRates(tenantId: number) {
|
public async getTaxRates(tenantId: number) {
|
||||||
const { TaxRate } = this.tenancy.models(tenantId);
|
const { TaxRate } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
const taxRates = await TaxRate.query();
|
// Retrieves the tax rates.
|
||||||
|
const taxRates = await TaxRate.query().orderBy('name', 'ASC');
|
||||||
|
|
||||||
// Transforms the tax rates.
|
// Transforms the tax rates.
|
||||||
return this.transformer.transform(
|
return this.transformer.transform(
|
||||||
|
|||||||
Reference in New Issue
Block a user