mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
Merge pull request #949 from bigcapitalhq/fix-tax-rates
fix: tax rates API and UI improvements
This commit is contained in:
@@ -62,10 +62,11 @@ export class TaxRatesApplication {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the tax rates list.
|
* Retrieves the tax rates list.
|
||||||
* @returns {Promise<ITaxRate[]>}
|
* @returns {Promise<{ data: ITaxRate[] }>}
|
||||||
*/
|
*/
|
||||||
public getTaxRates() {
|
public async getTaxRates() {
|
||||||
return this.getTaxRatesService.getTaxRates();
|
const taxRates = await this.getTaxRatesService.getTaxRates();
|
||||||
|
return { data: taxRates };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,9 +85,14 @@ export class TaxRatesController {
|
|||||||
status: 200,
|
status: 200,
|
||||||
description: 'The tax rates have been successfully retrieved.',
|
description: 'The tax rates have been successfully retrieved.',
|
||||||
schema: {
|
schema: {
|
||||||
type: 'array',
|
type: 'object',
|
||||||
items: {
|
properties: {
|
||||||
$ref: getSchemaPath(TaxRateResponseDto),
|
data: {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
$ref: getSchemaPath(TaxRateResponseDto),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ToNumber } from '@/common/decorators/Validators';
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { Transform } from 'class-transformer';
|
import { Transform } from 'class-transformer';
|
||||||
import {
|
import {
|
||||||
@@ -30,6 +31,7 @@ export class CommandTaxRateDto {
|
|||||||
*/
|
*/
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
|
@ToNumber()
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
description: 'The rate of the tax rate.',
|
description: 'The rate of the tax rate.',
|
||||||
example: 10,
|
example: 10,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Intent, Tag } from '@blueprintjs/core';
|
import { Intent, Tag, Classes } from '@blueprintjs/core';
|
||||||
import { Align } from '@/constants';
|
import { Align } from '@/constants';
|
||||||
import styled from 'styled-components';
|
import clsx from 'classnames';
|
||||||
|
|
||||||
const codeAccessor = (taxRate) => {
|
const codeAccessor = (taxRate) => {
|
||||||
return (
|
return (
|
||||||
@@ -28,13 +28,17 @@ const nameAccessor = (taxRate) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span>{taxRate.name}</span>
|
<span>{taxRate.name}</span>
|
||||||
{!!taxRate.is_compound && <CompoundText>(Compound tax)</CompoundText>}
|
{!!taxRate.is_compound && (
|
||||||
|
<span className={clsx(Classes.TEXT_MUTED)}>(Compound tax)</span>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const DescriptionAccessor = (taxRate) => {
|
const DescriptionAccessor = (taxRate) => {
|
||||||
return <DescriptionText>{taxRate.description}</DescriptionText>;
|
return (
|
||||||
|
<span className={clsx(Classes.TEXT_MUTED)}>{taxRate.description}</span>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,11 +76,3 @@ export const useTaxRatesTableColumns = () => {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
const CompoundText = styled('span')`
|
|
||||||
color: #738091;
|
|
||||||
margin-left: 5px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const DescriptionText = styled('span')`
|
|
||||||
color: #5f6b7c;
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -74,9 +74,13 @@ const TaxRateHeader = styled(`div`)`
|
|||||||
const TaxRateAmount = styled('div')`
|
const TaxRateAmount = styled('div')`
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
color: #565b71;
|
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
color: var(--x-color-amount-text, #565b71);
|
||||||
|
|
||||||
|
.bp4-dark & {
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const TaxRateActiveTag = styled(Tag)`
|
const TaxRateActiveTag = styled(Tag)`
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ export function useTaxRate(taxRateId: string, props) {
|
|||||||
[QUERY_TYPES.TAX_RATES, taxRateId],
|
[QUERY_TYPES.TAX_RATES, taxRateId],
|
||||||
{
|
{
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `tax-rates/${taxRateId}}`,
|
url: `tax-rates/${taxRateId}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
select: (res) => res.data.data,
|
select: (res) => res.data,
|
||||||
...props,
|
...props,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -106,7 +106,7 @@ export function useActivateTaxRate(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation((id) => apiRequest.post(`tax-rates/${id}/active`), {
|
return useMutation((id) => apiRequest.put(`tax-rates/${id}/activate`), {
|
||||||
onSuccess: (res, id) => {
|
onSuccess: (res, id) => {
|
||||||
commonInvalidateQueries(queryClient);
|
commonInvalidateQueries(queryClient);
|
||||||
queryClient.invalidateQueries([QUERY_TYPES.TAX_RATES, id]);
|
queryClient.invalidateQueries([QUERY_TYPES.TAX_RATES, id]);
|
||||||
@@ -122,7 +122,7 @@ export function useInactivateTaxRate(props) {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation((id) => apiRequest.post(`tax-rates/${id}/inactive`), {
|
return useMutation((id) => apiRequest.put(`tax-rates/${id}/inactivate`), {
|
||||||
onSuccess: (res, id) => {
|
onSuccess: (res, id) => {
|
||||||
commonInvalidateQueries(queryClient);
|
commonInvalidateQueries(queryClient);
|
||||||
queryClient.invalidateQueries([QUERY_TYPES.TAX_RATES, id]);
|
queryClient.invalidateQueries([QUERY_TYPES.TAX_RATES, id]);
|
||||||
|
|||||||
Reference in New Issue
Block a user