feat(server): order tax rates by name

This commit is contained in:
Ahmed Bouhuolia
2023-09-18 18:57:54 +02:00
parent df823c0bfe
commit 1b4b656419
3 changed files with 6 additions and 3 deletions

View File

@@ -22,7 +22,7 @@ export default class TaxRate extends mixin(TenantModel, [ModelSearchable]) {
* Timestamps columns.
*/
get timestamps() {
return ['created_at', 'updated_at'];
return ['createdAt', 'updatedAt'];
}
/**

View File

@@ -1,5 +1,6 @@
import { Knex } from 'knex';
import { Inject, Service } from 'typedi';
import { omit } from 'lodash';
import {
IEditTaxRateDTO,
ITaxRate,
@@ -54,7 +55,7 @@ export class EditTaxRateService {
private async editTaxRateOrCreate(
tenantId: number,
oldTaxRate: ITaxRate,
editTaxRateDTO: any,
editTaxRateDTO: IEditTaxRateDTO,
trx?: Knex.Transaction
) {
const { TaxRate } = this.tenancy.models(tenantId);
@@ -68,6 +69,7 @@ export class EditTaxRateService {
// Create a new tax rate with new edited data.
return TaxRate.query(trx).insertAndFetch({
...omit(oldTaxRate, ['id']),
...editTaxRateDTO,
});
} else {

View File

@@ -19,7 +19,8 @@ export class GetTaxRatesService {
public async getTaxRates(tenantId: number) {
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.
return this.transformer.transform(