mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
refactor(nestjs): hook up the client with new endpoints
This commit is contained in:
@@ -1,11 +1,3 @@
|
||||
import { Model, mixin } from 'objection';
|
||||
// import TenantModel from 'models/TenantModel';
|
||||
// import ModelSetting from './ModelSetting';
|
||||
// import BillPaymentSettings from './BillPayment.Settings';
|
||||
// import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
// import { DEFAULT_VIEWS } from '@/services/Sales/PaymentReceived/constants';
|
||||
// import ModelSearchable from './ModelSearchable';
|
||||
import { BaseModel } from '@/models/Model';
|
||||
import { BillPaymentEntry } from './BillPaymentEntry';
|
||||
import { Vendor } from '@/modules/Vendors/models/Vendor';
|
||||
import { Document } from '@/modules/ChromiumlyTenancy/models/Document';
|
||||
@@ -13,11 +5,12 @@ import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { BillPaymentMeta } from './BillPayment.meta';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
|
||||
@ImportableModel()
|
||||
@ExportableModel()
|
||||
@InjectModelMeta(BillPaymentMeta)
|
||||
export class BillPayment extends BaseModel {
|
||||
export class BillPayment extends TenantBaseModel {
|
||||
vendorId: number;
|
||||
amount: number;
|
||||
currencyCode: string;
|
||||
|
||||
@@ -35,10 +35,17 @@ export class GetCreditNotesService {
|
||||
* @param {ICreditNotesQueryDTO} creditNotesQuery -
|
||||
*/
|
||||
public async getCreditNotesList(
|
||||
creditNotesQuery: ICreditNotesQueryDTO,
|
||||
filterDto: ICreditNotesQueryDTO,
|
||||
): Promise<GetCreditNotesResponse> {
|
||||
const _filterDto = {
|
||||
sortOrder: 'desc',
|
||||
columnSortBy: 'created_at',
|
||||
page: 1,
|
||||
pageSize: 12,
|
||||
...filterDto,
|
||||
};
|
||||
// Parses stringified filter roles.
|
||||
const filter = this.parseListFilterDTO(creditNotesQuery);
|
||||
const filter = this.parseListFilterDTO(_filterDto);
|
||||
|
||||
// Dynamic list service.
|
||||
const dynamicFilter = await this.dynamicListService.dynamicList(
|
||||
@@ -52,7 +59,7 @@ export class GetCreditNotesService {
|
||||
builder.withGraphFetched('customer');
|
||||
|
||||
dynamicFilter.buildQuery()(builder);
|
||||
creditNotesQuery?.filterQuery?.(builder as any);
|
||||
_filterDto?.filterQuery?.(builder as any);
|
||||
})
|
||||
.pagination(filter.page - 1, filter.pageSize);
|
||||
|
||||
|
||||
@@ -58,10 +58,7 @@ export class InventoryAdjustmentsController {
|
||||
})
|
||||
public async getInventoryAdjustments(
|
||||
@Query() filterDTO: IInventoryAdjustmentsFilter,
|
||||
): Promise<{
|
||||
inventoryAdjustments: InventoryAdjustment[];
|
||||
pagination: IPaginationMeta;
|
||||
}> {
|
||||
) {
|
||||
return this.inventoryAdjustmentsApplicationService.getInventoryAdjustments(
|
||||
filterDTO,
|
||||
);
|
||||
|
||||
@@ -75,12 +75,7 @@ export class InventoryAdjustmentsApplicationService {
|
||||
* Retrieves the inventory adjustments paginated list.
|
||||
* @param {IInventoryAdjustmentsFilter} adjustmentsFilter - Inventory adjustments filter.
|
||||
*/
|
||||
public async getInventoryAdjustments(
|
||||
filterDTO: IInventoryAdjustmentsFilter,
|
||||
): Promise<{
|
||||
inventoryAdjustments: InventoryAdjustment[];
|
||||
pagination: IPaginationMeta;
|
||||
}> {
|
||||
public async getInventoryAdjustments(filterDTO: IInventoryAdjustmentsFilter) {
|
||||
return this.getInventoryAdjustmentsService.getInventoryAdjustments(
|
||||
filterDTO,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
export const InventoryAdjustmentMeta = {
|
||||
defaultFilterField: 'date',
|
||||
defaultSort: {
|
||||
sortOrder: 'DESC',
|
||||
sortField: 'date',
|
||||
},
|
||||
columns: {
|
||||
date: {
|
||||
name: 'inventory_adjustment.field.date',
|
||||
column: 'date',
|
||||
fieldType: 'date',
|
||||
exportable: true,
|
||||
},
|
||||
type: {
|
||||
name: 'inventory_adjustment.field.type',
|
||||
column: 'type',
|
||||
fieldType: 'enumeration',
|
||||
options: [
|
||||
{ key: 'increment', name: 'inventory_adjustment.field.type.increment' },
|
||||
{ key: 'decrement', name: 'inventory_adjustment.field.type.decrement' },
|
||||
],
|
||||
exportable: true,
|
||||
},
|
||||
adjustmentAccount: {
|
||||
name: 'inventory_adjustment.field.adjustment_account',
|
||||
type: 'adjustment_account_id',
|
||||
exportable: true,
|
||||
},
|
||||
reason: {
|
||||
name: 'inventory_adjustment.field.reason',
|
||||
type: 'text',
|
||||
exportable: true,
|
||||
},
|
||||
referenceNo: {
|
||||
name: 'inventory_adjustment.field.reference_no',
|
||||
type: 'text',
|
||||
exportable: true,
|
||||
},
|
||||
description: {
|
||||
name: 'inventory_adjustment.field.description',
|
||||
type: 'text',
|
||||
exportable: true,
|
||||
},
|
||||
publishedAt: {
|
||||
name: 'inventory_adjustment.field.published_at',
|
||||
type: 'date',
|
||||
exportable: true,
|
||||
},
|
||||
createdAt: {
|
||||
name: 'inventory_adjustment.field.created_at',
|
||||
type: 'date',
|
||||
exportable: true,
|
||||
},
|
||||
},
|
||||
fields: {
|
||||
date: {
|
||||
name: 'inventory_adjustment.field.date',
|
||||
column: 'date',
|
||||
fieldType: 'date',
|
||||
},
|
||||
type: {
|
||||
name: 'inventory_adjustment.field.type',
|
||||
column: 'type',
|
||||
fieldType: 'enumeration',
|
||||
options: [
|
||||
{ key: 'increment', name: 'inventory_adjustment.field.type.increment' },
|
||||
{ key: 'decrement', name: 'inventory_adjustment.field.type.decrement' },
|
||||
],
|
||||
},
|
||||
adjustment_account: {
|
||||
name: 'inventory_adjustment.field.adjustment_account',
|
||||
column: 'adjustment_account_id',
|
||||
fieldType: 'relation',
|
||||
|
||||
relationType: 'enumeration',
|
||||
relationKey: 'adjustmentAccount',
|
||||
|
||||
relationEntityLabel: 'name',
|
||||
relationEntityKey: 'slug',
|
||||
},
|
||||
reason: {
|
||||
name: 'inventory_adjustment.field.reason',
|
||||
column: 'reason',
|
||||
fieldType: 'text',
|
||||
},
|
||||
reference_no: {
|
||||
name: 'inventory_adjustment.field.reference_no',
|
||||
column: 'reference_no',
|
||||
fieldType: 'text',
|
||||
},
|
||||
description: {
|
||||
name: 'inventory_adjustment.field.description',
|
||||
column: 'description',
|
||||
fieldType: 'text',
|
||||
},
|
||||
published_at: {
|
||||
name: 'inventory_adjustment.field.published_at',
|
||||
column: 'published_at',
|
||||
fieldType: 'date',
|
||||
},
|
||||
created_at: {
|
||||
name: 'inventory_adjustment.field.created_at',
|
||||
column: 'created_at',
|
||||
fieldType: 'date',
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Model } from 'objection';
|
||||
import { InventoryAdjustmentEntry } from './InventoryAdjustmentEntry';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { InventoryAdjustmentMeta } from './InventoryAdjustment.meta';
|
||||
|
||||
@InjectModelMeta(InventoryAdjustmentMeta)
|
||||
export class InventoryAdjustment extends TenantBaseModel {
|
||||
public readonly date!: string;
|
||||
public readonly type!: string;
|
||||
@@ -16,7 +19,6 @@ export class InventoryAdjustment extends TenantBaseModel {
|
||||
public readonly warehouseId!: number;
|
||||
|
||||
public readonly createdAt!: Date | string;
|
||||
|
||||
public readonly entries: InventoryAdjustmentEntry[];
|
||||
|
||||
/**
|
||||
@@ -116,11 +118,4 @@ export class InventoryAdjustment extends TenantBaseModel {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Model settings.
|
||||
*/
|
||||
// static get meta() {
|
||||
// return InventoryAdjustmentSettings;
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { IInventoryAdjustmentsFilter } from '../types/InventoryAdjustments.types
|
||||
import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service';
|
||||
import { DynamicListService } from '@/modules/DynamicListing/DynamicList.service';
|
||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||
import { ISortOrder } from '@/modules/DynamicListing/DynamicFilter/DynamicFilter.types';
|
||||
|
||||
@Injectable()
|
||||
export class GetInventoryAdjustmentsService {
|
||||
@@ -27,17 +28,25 @@ export class GetInventoryAdjustmentsService {
|
||||
public async getInventoryAdjustments(
|
||||
filterDTO: IInventoryAdjustmentsFilter,
|
||||
): Promise<{
|
||||
inventoryAdjustments: InventoryAdjustment[];
|
||||
data: InventoryAdjustment[];
|
||||
pagination: IPaginationMeta;
|
||||
}> {
|
||||
const parsedFilterDto = {
|
||||
sortOrder: ISortOrder.DESC,
|
||||
columnSortBy: 'created_at',
|
||||
page: 1,
|
||||
pageSize: 12,
|
||||
...filterDTO,
|
||||
};
|
||||
// Parses inventory adjustments list filter DTO.
|
||||
const filter = this.parseListFilterDTO(filterDTO);
|
||||
const filter = this.parseListFilterDTO(parsedFilterDto);
|
||||
|
||||
// Dynamic list service.
|
||||
const dynamicFilter = await this.dynamicListService.dynamicList(
|
||||
this.inventoryAdjustmentModel(),
|
||||
filter,
|
||||
);
|
||||
|
||||
const { results, pagination } = await this.inventoryAdjustmentModel()
|
||||
.query()
|
||||
.onBuild((query) => {
|
||||
@@ -49,12 +58,12 @@ export class GetInventoryAdjustmentsService {
|
||||
.pagination(filter.page - 1, filter.pageSize);
|
||||
|
||||
// Retrieves the transformed inventory adjustments.
|
||||
const inventoryAdjustments = await this.transformer.transform(
|
||||
const data = await this.transformer.transform(
|
||||
results,
|
||||
new InventoryAdjustmentTransformer(),
|
||||
);
|
||||
return {
|
||||
inventoryAdjustments,
|
||||
data,
|
||||
pagination,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,6 +24,6 @@ export class ItemCategoriesExportable extends Exportable {
|
||||
|
||||
return this.itemCategoryApp
|
||||
.getItemCategories(parsedQuery)
|
||||
.then((output) => output.itemCategories);
|
||||
.then((output) => output.data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,6 @@ export interface IItemCategoriesFilter extends IDynamicListFilter {
|
||||
}
|
||||
|
||||
export interface GetItemCategoriesResponse {
|
||||
itemCategories: ItemCategory[];
|
||||
data: ItemCategory[];
|
||||
// filterMeta: IFilterMeta;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ export class GetItemCategoriesService {
|
||||
filter,
|
||||
);
|
||||
// Items categories.
|
||||
const itemCategories = await this.itemCategoryModel()
|
||||
const data = await this.itemCategoryModel()
|
||||
.query()
|
||||
.onBuild((query) => {
|
||||
// Subquery to calculate sumation of associated items to the item category.
|
||||
@@ -61,7 +61,6 @@ export class GetItemCategoriesService {
|
||||
);
|
||||
dynamicList.buildQuery()(query);
|
||||
});
|
||||
|
||||
return { itemCategories };
|
||||
return { data };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ export class TransactionsLockingController {
|
||||
@Get('/')
|
||||
@ApiOperation({ summary: 'Get all transactions locking meta' })
|
||||
async getTransactionLockingMetaList() {
|
||||
return await this.queryTransactionsLocking.getTransactionsLockingAll();
|
||||
return await this.queryTransactionsLocking.getTransactionsLockingList();
|
||||
}
|
||||
|
||||
@Get(':module')
|
||||
|
||||
@@ -13,7 +13,7 @@ function InventoryAdjustmentsProvider({ query, ...props }) {
|
||||
const {
|
||||
isLoading: isAdjustmentsLoading,
|
||||
isFetching: isAdjustmentsFetching,
|
||||
data: { transactions: inventoryAdjustments, pagination },
|
||||
data: { inventoryAdjustments, pagination },
|
||||
} = useInventoryAdjustments(query, { keepPreviousData: true });
|
||||
|
||||
// Provider payload.
|
||||
|
||||
@@ -201,7 +201,7 @@ export function useBankRules(
|
||||
|
||||
return useQuery<BankRulesResponse, Error>(
|
||||
[BANK_QUERY_KEY.BANK_RULES],
|
||||
() => apiRequest.get('/banking/rules').then((res) => res.data.bank_rules),
|
||||
() => apiRequest.get('/banking/rules').then((res) => res.data),
|
||||
{ ...options },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export function useCreateBill(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((values) => apiRequest.post('purchases/bills', values), {
|
||||
return useMutation((values) => apiRequest.post('bills', values), {
|
||||
onSuccess: (res, values) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -69,7 +69,7 @@ export function useEditBill(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`purchases/bills/${id}`, values),
|
||||
([id, values]) => apiRequest.post(`bills/${id}`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidate queries.
|
||||
@@ -90,7 +90,7 @@ export function useOpenBill(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.post(`purchases/bills/${id}/open`), {
|
||||
return useMutation((id) => apiRequest.post(`bills/${id}/open`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -109,7 +109,7 @@ export function useDeleteBill(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.delete(`purchases/bills/${id}`), {
|
||||
return useMutation((id) => apiRequest.delete(`bills/${id}`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -135,7 +135,7 @@ export function useBills(query, props) {
|
||||
[t.BILLS, query],
|
||||
{
|
||||
method: 'get',
|
||||
url: 'purchases/bills',
|
||||
url: 'bills',
|
||||
params: query,
|
||||
},
|
||||
{
|
||||
@@ -161,7 +161,7 @@ export function useBills(query, props) {
|
||||
export function useBill(id, props) {
|
||||
return useRequestQuery(
|
||||
[t.BILL, id],
|
||||
{ method: 'get', url: `/purchases/bills/${id}` },
|
||||
{ method: 'get', url: `/bills/${id}` },
|
||||
{
|
||||
select: (res) => res.data.bill,
|
||||
defaultData: {},
|
||||
@@ -179,7 +179,7 @@ export function useDueBills(vendorId, props) {
|
||||
[t.BILLS, t.BILLS_DUE, vendorId],
|
||||
{
|
||||
method: 'get',
|
||||
url: 'purchases/bills/due',
|
||||
url: 'bills/due',
|
||||
params: { vendor_id: vendorId },
|
||||
},
|
||||
{
|
||||
@@ -205,7 +205,7 @@ export function useBillPaymentTransactions(id, props) {
|
||||
[t.BILLS_PAYMENT_TRANSACTIONS, id],
|
||||
{
|
||||
method: 'get',
|
||||
url: `purchases/bills/${id}/payment-transactions`,
|
||||
url: `bills/${id}/payment-transactions`,
|
||||
},
|
||||
{
|
||||
select: (res) => res.data.data,
|
||||
|
||||
@@ -37,7 +37,7 @@ const commonInvalidateQueries = (queryClient) => {
|
||||
export function useCashflowAccounts(query, props) {
|
||||
return useRequestQuery(
|
||||
[t.CASH_FLOW_ACCOUNTS, query],
|
||||
{ method: 'get', url: 'cashflow/accounts', params: query },
|
||||
{ method: 'get', url: 'banking/accounts', params: query },
|
||||
{
|
||||
select: (res) => res.data.cashflow_accounts,
|
||||
defaultData: [],
|
||||
|
||||
@@ -59,7 +59,7 @@ export function useCreateCreditNote(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(values) => apiRequest.post('sales/credit_notes', values),
|
||||
(values) => apiRequest.post('credit-notes', values),
|
||||
{
|
||||
onSuccess: (res, values) => {
|
||||
// Common invalidate queries.
|
||||
@@ -78,7 +78,7 @@ export function useEditCreditNote(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`sales/credit_notes/${id}`, values),
|
||||
([id, values]) => apiRequest.post(`credit-notes/${id}`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidate queries.
|
||||
@@ -99,7 +99,7 @@ export function useDeleteCreditNote(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.delete(`sales/credit_notes/${id}`), {
|
||||
return useMutation((id) => apiRequest.delete(`credit-notes/${id}`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -123,7 +123,7 @@ const transformCreditNotes = (res) => ({
|
||||
export function useCreditNotes(query, props) {
|
||||
return useRequestQuery(
|
||||
[t.CREDIT_NOTES, query],
|
||||
{ method: 'get', url: 'sales/credit_notes', params: query },
|
||||
{ method: 'get', url: 'credit-notes', params: query },
|
||||
{
|
||||
select: transformCreditNotes,
|
||||
defaultData: {
|
||||
@@ -148,7 +148,7 @@ export function useCreditNotes(query, props) {
|
||||
export function useCreditNote(id, props, requestProps) {
|
||||
return useRequestQuery(
|
||||
[t.CREDIT_NOTE, id],
|
||||
{ method: 'get', url: `sales/credit_notes/${id}`, ...requestProps },
|
||||
{ method: 'get', url: `credit-notes/${id}`, ...requestProps },
|
||||
{
|
||||
select: (res) => res.data.credit_note,
|
||||
defaultData: {},
|
||||
@@ -176,7 +176,7 @@ export function useCreateRefundCreditNote(props) {
|
||||
|
||||
return useMutation(
|
||||
([id, values]) =>
|
||||
apiRequest.post(`sales/credit_notes/${id}/refund`, values),
|
||||
apiRequest.post(`credit-notes/${id}/refund`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidate queries.
|
||||
@@ -198,7 +198,7 @@ export function useDeleteRefundCreditNote(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(id) => apiRequest.delete(`sales/credit_notes/refunds/${id}`),
|
||||
(id) => apiRequest.delete(`credit-notes/refunds/${id}`),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
@@ -220,7 +220,7 @@ export function useDeleteRefundCreditNote(props) {
|
||||
export function useRefundCreditNote(id, props, requestProps) {
|
||||
return useRequestQuery(
|
||||
[t.REFUND_CREDIT_NOTE, id],
|
||||
{ method: 'get', url: `sales/credit_notes/${id}/refund`, ...requestProps },
|
||||
{ method: 'get', url: `credit-notes/${id}/refund`, ...requestProps },
|
||||
{
|
||||
select: (res) => res.data.data,
|
||||
defaultData: {},
|
||||
@@ -236,7 +236,7 @@ export function useOpenCreditNote(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.post(`sales/credit_notes/${id}/open`), {
|
||||
return useMutation((id) => apiRequest.post(`credit-notes/${id}/open`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -258,7 +258,7 @@ export function useReconcileCreditNote(id, props, requestProps) {
|
||||
[t.RECONCILE_CREDIT_NOTE, id],
|
||||
{
|
||||
method: 'get',
|
||||
url: `sales/credit_notes/${id}/apply-to-invoices`,
|
||||
url: `credit-notes/${id}/apply-to-invoices`,
|
||||
...requestProps,
|
||||
},
|
||||
{
|
||||
@@ -278,7 +278,7 @@ export function useCreateReconcileCreditNote(props) {
|
||||
|
||||
return useMutation(
|
||||
([id, values]) =>
|
||||
apiRequest.post(`sales/credit_notes/${id}/apply-to-invoices`, values),
|
||||
apiRequest.post(`credit-notes/${id}/apply-to-invoices`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidate queries.
|
||||
@@ -300,7 +300,7 @@ export function useReconcileCreditNotes(id, props, requestProps) {
|
||||
[t.RECONCILE_CREDIT_NOTES, id],
|
||||
{
|
||||
method: 'get',
|
||||
url: `sales/credit_notes/${id}/applied-invoices`,
|
||||
url: `credit-notes/${id}/applied-invoices`,
|
||||
...requestProps,
|
||||
},
|
||||
{
|
||||
@@ -319,7 +319,7 @@ export function useDeleteReconcileCredit(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(id) => apiRequest.delete(`sales/credit_notes/applied-to-invoices/${id}`),
|
||||
(id) => apiRequest.delete(`credit-notes/applied-to-invoices/${id}`),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
@@ -341,7 +341,7 @@ export function useDeleteReconcileCredit(props) {
|
||||
export function useRefundCreditTransaction(id, props, requestProps) {
|
||||
return useRequestQuery(
|
||||
[t.REFUND_CREDIT_NOTE_TRANSACTION, id],
|
||||
{ method: 'get', url: `sales/credit_notes/refunds/${id}`, ...requestProps },
|
||||
{ method: 'get', url: `credit-notes/refunds/${id}`, ...requestProps },
|
||||
{
|
||||
select: (res) => res.data.refund_credit,
|
||||
defaultData: {},
|
||||
@@ -354,7 +354,7 @@ export function useRefundCreditTransaction(id, props, requestProps) {
|
||||
* Retrieve the credit note pdf document data,
|
||||
*/
|
||||
export function usePdfCreditNote(creditNoteId) {
|
||||
return useRequestPdf({ url: `sales/credit_notes/${creditNoteId}` });
|
||||
return useRequestPdf({ url: `credit-notes/${creditNoteId}` });
|
||||
}
|
||||
|
||||
export interface CreditNoteStateResponse {
|
||||
@@ -369,7 +369,7 @@ export function useGetCreditNoteState(
|
||||
['CREDIT_NOTE_STATE'],
|
||||
() =>
|
||||
apiRequest
|
||||
.get('/sales/credit_notes/state')
|
||||
.get('/credit-notes/state')
|
||||
.then((res) => transformToCamelCase(res.data?.data)),
|
||||
{ ...options },
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ export function useCreateEstimate(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((values) => apiRequest.post('sales/estimates', values), {
|
||||
return useMutation((values) => apiRequest.post('sale-estimates', values), {
|
||||
onSuccess: () => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -47,7 +47,7 @@ export function useEditEstimate(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`sales/estimates/${id}`, values),
|
||||
([id, values]) => apiRequest.post(`sale-estimates/${id}`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidate queries.
|
||||
@@ -67,7 +67,7 @@ export function useEditEstimate(props) {
|
||||
export function useEstimate(id, props) {
|
||||
return useRequestQuery(
|
||||
[t.SALE_ESTIMATE, id],
|
||||
{ method: 'get', url: `sales/estimates/${id}` },
|
||||
{ method: 'get', url: `sale-estimates/${id}` },
|
||||
{
|
||||
select: (res) => res.data.estimate,
|
||||
defaultData: {},
|
||||
@@ -88,7 +88,7 @@ const transformEstimates = (res) => ({
|
||||
export function useEstimates(query, props) {
|
||||
return useRequestQuery(
|
||||
[t.SALE_ESTIMATES, query],
|
||||
{ method: 'get', url: 'sales/estimates', params: query },
|
||||
{ method: 'get', url: 'sale-estimates', params: query },
|
||||
{
|
||||
select: transformEstimates,
|
||||
defaultData: {
|
||||
@@ -112,7 +112,7 @@ export function useDeleteEstimate(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.delete(`sales/estimates/${id}`), {
|
||||
return useMutation((id) => apiRequest.delete(`sale-estimates/${id}`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -131,7 +131,7 @@ export function useDeliverEstimate(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.post(`sales/estimates/${id}/deliver`), {
|
||||
return useMutation((id) => apiRequest.post(`sale-estimates/${id}/deliver`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -150,7 +150,7 @@ export function useApproveEstimate(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.post(`sales/estimates/${id}/approve`), {
|
||||
return useMutation((id) => apiRequest.post(`sale-estimates/${id}/approve`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -169,7 +169,7 @@ export function useRejectEstimate(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.post(`sales/estimates/${id}/reject`), {
|
||||
return useMutation((id) => apiRequest.post(`sale-estimates/${id}/reject`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -187,7 +187,7 @@ export function useRejectEstimate(props) {
|
||||
|
||||
export function usePdfEstimate(estimateId) {
|
||||
return useRequestPdf({
|
||||
url: `sales/estimates/${estimateId}`,
|
||||
url: `sale-estimates/${estimateId}`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ export function useCreateNotifyEstimateBySMS(props) {
|
||||
|
||||
return useMutation(
|
||||
([id, values]) =>
|
||||
apiRequest.post(`sales/estimates/${id}/notify-by-sms`, values),
|
||||
apiRequest.post(`sale-estimates/${id}/notify-by-sms`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Invalidate
|
||||
@@ -236,7 +236,7 @@ export function useEstimateSMSDetail(estimateId, props, requestProps) {
|
||||
[t.SALE_ESTIMATE_SMS_DETAIL, estimateId],
|
||||
{
|
||||
method: 'get',
|
||||
url: `sales/estimates/${estimateId}/sms-details`,
|
||||
url: `sale-estimates/${estimateId}/sms-details`,
|
||||
...requestProps,
|
||||
},
|
||||
{
|
||||
@@ -252,7 +252,7 @@ export function useSendSaleEstimateMail(props = {}) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`sales/estimates/${id}/mail`, values),
|
||||
([id, values]) => apiRequest.post(`sale-estimates/${id}/mail`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidate queries.
|
||||
@@ -320,7 +320,7 @@ export function useSaleEstimateMailState(
|
||||
const apiRequest = useApiRequest();
|
||||
return useQuery([t.SALE_ESTIMATE_MAIL_OPTIONS, estimateId], () =>
|
||||
apiRequest
|
||||
.get(`sales/estimates/${estimateId}/mail/state`)
|
||||
.get(`sale-estimates/${estimateId}/mail/state`)
|
||||
.then((res) => transformToCamelCase(res.data.data)),
|
||||
);
|
||||
}
|
||||
@@ -338,7 +338,7 @@ export function useGetSaleEstimatesState(
|
||||
['SALE_ESTIMATE_STATE'],
|
||||
() =>
|
||||
apiRequest
|
||||
.get('/sales/estimates/state')
|
||||
.get('/sale-estimates/state')
|
||||
.then((res) => transformToCamelCase(res.data?.data)),
|
||||
{ ...options },
|
||||
);
|
||||
@@ -363,7 +363,7 @@ export const useGetSaleEstimateHtml = (
|
||||
['SALE_ESTIMATE_HTML', estimateId],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`sales/estimates/${estimateId}`, {
|
||||
.get(`sale-estimates/${estimateId}`, {
|
||||
headers: {
|
||||
Accept: 'application/json+html',
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@ import t from './types';
|
||||
|
||||
const commonInvalidateQueries = (queryClient) => {
|
||||
// Invalidate inventory adjustments.
|
||||
queryClient.invalidateQueries(t.INVENTORY_ADJUSTMENTS);
|
||||
queryClient.invalidateQueries(t.inventory-adjustments);
|
||||
queryClient.invalidateQueries(t.INVENTORY_ADJUSTMENT);
|
||||
|
||||
// Invalidate items.
|
||||
@@ -33,7 +33,7 @@ export function useCreateInventoryAdjustment(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(values) => apiRequest.post('inventory_adjustments/quick', values),
|
||||
(values) => apiRequest.post('inventory-adjustments/quick', values),
|
||||
{
|
||||
onSuccess: () => {
|
||||
// Common invalidate queries.
|
||||
@@ -51,7 +51,7 @@ export function useDeleteInventoryAdjustment(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.delete(`inventory_adjustments/${id}`), {
|
||||
return useMutation((id) => apiRequest.delete(`inventory-adjustments/${id}`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -62,7 +62,7 @@ export function useDeleteInventoryAdjustment(props) {
|
||||
|
||||
const inventoryAdjustmentsTransformer = (response) => {
|
||||
return {
|
||||
transactions: response.data.inventoy_adjustments,
|
||||
inventoryAdjustments: response.data.data,
|
||||
pagination: transformPagination(response.data.pagination),
|
||||
};
|
||||
};
|
||||
@@ -72,8 +72,8 @@ const inventoryAdjustmentsTransformer = (response) => {
|
||||
*/
|
||||
export function useInventoryAdjustments(query, props) {
|
||||
return useRequestQuery(
|
||||
['INVENTORY_ADJUSTMENTS', query],
|
||||
{ url: 'inventory_adjustments', params: query },
|
||||
['inventory-adjustments', query],
|
||||
{ url: 'inventory-adjustments', params: query },
|
||||
{
|
||||
select: inventoryAdjustmentsTransformer,
|
||||
defaultData: {
|
||||
@@ -98,7 +98,7 @@ export function usePublishInventoryAdjustment(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(id) => apiRequest.post(`inventory_adjustments/${id}/publish`),
|
||||
(id) => apiRequest.post(`inventory-adjustments/${id}/publish`),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
// Invalidate specific inventory adjustment.
|
||||
@@ -118,7 +118,7 @@ export function usePublishInventoryAdjustment(props) {
|
||||
export function useInventoryAdjustment(id, props, requestProps) {
|
||||
return useRequestQuery(
|
||||
[t.INVENTORY_ADJUSTMENT, id],
|
||||
{ method: 'get', url: `inventory_adjustments/${id}`, ...requestProps },
|
||||
{ method: 'get', url: `inventory-adjustments/${id}`, ...requestProps },
|
||||
{
|
||||
select: (res) => res.data.data,
|
||||
defaultData: {},
|
||||
|
||||
@@ -61,7 +61,7 @@ export function useCreateInvoice(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((values) => apiRequest.post('sales/invoices', values), {
|
||||
return useMutation((values) => apiRequest.post('sale-invoices', values), {
|
||||
onSuccess: (res, values) => {
|
||||
// Invalidate invoice customer.
|
||||
queryClient.invalidateQueries([t.CUSTOMER, values.customer_id]);
|
||||
@@ -85,7 +85,7 @@ export function useEditInvoice(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`sales/invoices/${id}`, values),
|
||||
([id, values]) => apiRequest.post(`sale-invoices/${id}`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Invalidate specific sale invoice.
|
||||
@@ -109,7 +109,7 @@ export function useDeleteInvoice(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.delete(`sales/invoices/${id}`), {
|
||||
return useMutation((id) => apiRequest.delete(`sale-invoices/${id}`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Invalidate specific invoice.
|
||||
queryClient.invalidateQueries([t.SALE_INVOICE, id]);
|
||||
@@ -137,7 +137,7 @@ const transformInvoices = (res) => ({
|
||||
export function useInvoices(query, props) {
|
||||
return useRequestQuery(
|
||||
[t.SALE_INVOICES, query],
|
||||
{ method: 'get', url: 'sales/invoices', params: query },
|
||||
{ method: 'get', url: 'sale-invoices', params: query },
|
||||
{
|
||||
select: transformInvoices,
|
||||
defaultData: {
|
||||
@@ -162,7 +162,7 @@ export function useDeliverInvoice(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(invoiceId) => apiRequest.post(`sales/invoices/${invoiceId}/deliver`),
|
||||
(invoiceId) => apiRequest.post(`sale-invoices/${invoiceId}/deliver`),
|
||||
{
|
||||
onSuccess: (res, invoiceId) => {
|
||||
// Invalidate specific invoice.
|
||||
@@ -183,7 +183,7 @@ export function useDeliverInvoice(props) {
|
||||
export function useInvoice(invoiceId, props, requestProps) {
|
||||
return useRequestQuery(
|
||||
[t.SALE_INVOICE, invoiceId],
|
||||
{ method: 'get', url: `sales/invoices/${invoiceId}`, ...requestProps },
|
||||
{ method: 'get', url: `sale-invoices/${invoiceId}`, ...requestProps },
|
||||
{
|
||||
select: (res) => res.data.sale_invoice,
|
||||
defaultData: {},
|
||||
@@ -197,7 +197,7 @@ export function useInvoice(invoiceId, props, requestProps) {
|
||||
*/
|
||||
export function usePdfInvoice(invoiceId) {
|
||||
return useRequestPdf({
|
||||
url: `sales/invoices/${invoiceId}`,
|
||||
url: `sale-invoices/${invoiceId}`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ export const useInvoiceHtml = (
|
||||
['SALE_INVOICE_HTML', invoiceId],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`sales/invoices/${invoiceId}`, {
|
||||
.get(`sale-invoices/${invoiceId}`, {
|
||||
headers: {
|
||||
Accept: 'application/json+html',
|
||||
},
|
||||
@@ -238,7 +238,7 @@ export function useDueInvoices(customerId, props) {
|
||||
[t.SALE_INVOICES, t.SALE_INVOICES_DUE, customerId],
|
||||
{
|
||||
method: 'get',
|
||||
url: `sales/invoices/payable`,
|
||||
url: `sale-invoices/payable`,
|
||||
params: { customer_id: customerId },
|
||||
},
|
||||
{
|
||||
@@ -264,7 +264,7 @@ export function useCreateBadDebt(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`sales/invoices/${id}/writeoff`, values),
|
||||
([id, values]) => apiRequest.post(`sale-invoices/${id}/writeoff`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Invalidate
|
||||
@@ -283,7 +283,7 @@ export function useCancelBadDebt(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(id) => apiRequest.post(`sales/invoices/${id}/writeoff/cancel`),
|
||||
(id) => apiRequest.post(`sale-invoices/${id}/writeoff/cancel`),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
// Invalidate
|
||||
@@ -303,7 +303,7 @@ export function useCreateNotifyInvoiceBySMS(props) {
|
||||
|
||||
return useMutation(
|
||||
([id, values]) =>
|
||||
apiRequest.post(`sales/invoices/${id}/notify-by-sms`, values),
|
||||
apiRequest.post(`sale-invoices/${id}/notify-by-sms`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Invalidate
|
||||
@@ -322,7 +322,7 @@ export function useInvoiceSMSDetail(invoiceId, query, props) {
|
||||
[t.SALE_INVOICE_SMS_DETAIL, invoiceId, query],
|
||||
{
|
||||
method: 'get',
|
||||
url: `sales/invoices/${invoiceId}/sms-details`,
|
||||
url: `sale-invoices/${invoiceId}/sms-details`,
|
||||
params: query,
|
||||
},
|
||||
{
|
||||
@@ -338,7 +338,7 @@ export function useInvoicePaymentTransactions(invoiceId, props) {
|
||||
[t.SALE_INVOICE_PAYMENT_TRANSACTIONS, invoiceId],
|
||||
{
|
||||
method: 'get',
|
||||
url: `sales/invoices/${invoiceId}/payment-transactions`,
|
||||
url: `sale-invoices/${invoiceId}/payment-transactions`,
|
||||
},
|
||||
{
|
||||
select: (res) => res.data.data,
|
||||
@@ -386,7 +386,7 @@ export function useSendSaleInvoiceMail(
|
||||
Error,
|
||||
SendSaleInvoiceMailValues
|
||||
>(
|
||||
(value) => apiRequest.post(`sales/invoices/${value.id}/mail`, value.values),
|
||||
(value) => apiRequest.post(`sale-invoices/${value.id}/mail`, value.values),
|
||||
{
|
||||
onSuccess: (res) => {
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -460,7 +460,7 @@ export function useSaleInvoiceMailState(
|
||||
[t.SALE_INVOICE_DEFAULT_OPTIONS, invoiceId],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`/sales/invoices/${invoiceId}/mail/state`)
|
||||
.get(`/sale-invoices/${invoiceId}/mail/state`)
|
||||
.then((res) => transformToCamelCase(res.data?.data)),
|
||||
options,
|
||||
);
|
||||
@@ -481,7 +481,7 @@ export function useGetSaleInvoiceState(
|
||||
['SALE_INVOICE_STATE'],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`/sales/invoices/state`)
|
||||
.get(`/sale-invoices/state`)
|
||||
.then((res) => transformToCamelCase(res.data?.data)),
|
||||
{ ...options },
|
||||
);
|
||||
@@ -546,7 +546,7 @@ export function useGetSaleInvoiceBrandingTemplate(
|
||||
['SALE_INVOICE_BRANDING_TEMPLATE', invoiceId],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`/sales/invoices/${invoiceId}/template`)
|
||||
.get(`/sale-invoices/${invoiceId}/template`)
|
||||
.then((res) => transformToCamelCase(res.data?.data)),
|
||||
{ ...options },
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ export function useCreateItemCategory(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((values) => apiRequest.post('item_categories', values), {
|
||||
return useMutation((values) => apiRequest.post('item-categories', values), {
|
||||
onSuccess: () => {
|
||||
// Common invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -36,7 +36,7 @@ export function useEditItemCategory(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`item_categories/${id}`, values),
|
||||
([id, values]) => apiRequest.post(`item-categories/${id}`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Invalidate specific item category.
|
||||
@@ -57,7 +57,7 @@ export function useDeleteItemCategory(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.delete(`item_categories/${id}`), {
|
||||
return useMutation((id) => apiRequest.delete(`item-categories/${id}`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Invalidate specific item category.
|
||||
queryClient.invalidateQueries([t.ITEM_CATEGORY, id]);
|
||||
@@ -69,10 +69,9 @@ export function useDeleteItemCategory(props) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const transformCategories = (res) => ({
|
||||
itemsCategories: res.data.item_categories,
|
||||
pagination: res.data.pagination,
|
||||
itemsCategories: res.data.data,
|
||||
pagination: res.data.pagination,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -81,12 +80,12 @@ const transformCategories = (res) => ({
|
||||
export function useItemsCategories(query, props) {
|
||||
return useRequestQuery(
|
||||
[t.ITEMS_CATEGORIES, query],
|
||||
{ method: 'get', url: `item_categories`, params: query },
|
||||
{ method: 'get', url: `item-categories`, params: query },
|
||||
{
|
||||
select: transformCategories,
|
||||
defaultData: {
|
||||
itemsCategories: [],
|
||||
pagination: {}
|
||||
pagination: {},
|
||||
},
|
||||
...props,
|
||||
},
|
||||
@@ -100,7 +99,7 @@ export function useItemsCategories(query, props) {
|
||||
export function useItemCategory(id, props) {
|
||||
return useRequestQuery(
|
||||
[t.ITEM_CATEGORY, id],
|
||||
{ method: 'get', url: `item_categories/${id}` },
|
||||
{ method: 'get', url: `item-categories/${id}` },
|
||||
{
|
||||
select: (res) => res.data.category,
|
||||
defaultData: {},
|
||||
|
||||
@@ -42,7 +42,7 @@ const commonInvalidateQueries = (client) => {
|
||||
export function usePaymentMades(query, props) {
|
||||
return useRequestQuery(
|
||||
[t.PAYMENT_MADES, query],
|
||||
{ url: 'purchases/bill_payments', params: query },
|
||||
{ url: 'bill-payments', params: query },
|
||||
{
|
||||
select: (res) => ({
|
||||
paymentMades: res.data.bill_payments,
|
||||
@@ -67,7 +67,7 @@ export function useCreatePaymentMade(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(values) => apiRequest.post('purchases/bill_payments', values),
|
||||
(values) => apiRequest.post('bill-payments', values),
|
||||
{
|
||||
onSuccess: (res, values) => {
|
||||
// Common invalidation queries.
|
||||
@@ -86,7 +86,7 @@ export function useEditPaymentMade(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`purchases/bill_payments/${id}`, values),
|
||||
([id, values]) => apiRequest.post(`bill-payments/${id}`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidation queries.
|
||||
@@ -108,7 +108,7 @@ export function useDeletePaymentMade(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(id) => apiRequest.delete(`purchases/bill_payments/${id}`),
|
||||
(id) => apiRequest.delete(`bill-payments/${id}`),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidation queries.
|
||||
@@ -130,7 +130,7 @@ export function usePaymentMadeEditPage(id, props) {
|
||||
[t.PAYMENT_MADE_EDIT_PAGE, id],
|
||||
{
|
||||
method: 'get',
|
||||
url: `purchases/bill_payments/${id}/edit-page`,
|
||||
url: `bill-payments/${id}/edit-page`,
|
||||
},
|
||||
{
|
||||
select: (res) => ({
|
||||
@@ -155,7 +155,7 @@ export function usePaymentMadeNewPageEntries(vendorId, props) {
|
||||
[t.PAYMENT_MADE_NEW_ENTRIES, vendorId],
|
||||
{
|
||||
method: 'get',
|
||||
url: `purchases/bill_payments/new-page/entries`,
|
||||
url: `bill-payments/new-page/entries`,
|
||||
params: { vendor_id: vendorId },
|
||||
},
|
||||
{
|
||||
@@ -183,7 +183,7 @@ export function useRefreshPaymentMades() {
|
||||
export function usePaymentMade(id, props) {
|
||||
return useRequestQuery(
|
||||
[t.PAYMENT_MADE, id],
|
||||
{ method: 'get', url: `purchases/bill_payments/${id}` },
|
||||
{ method: 'get', url: `bill-payments/${id}` },
|
||||
{
|
||||
select: (res) => res.data.bill_payment,
|
||||
defaultData: {},
|
||||
|
||||
@@ -66,7 +66,7 @@ const transformPaymentReceives = (res) => ({
|
||||
export function usePaymentReceives(query, props) {
|
||||
return useRequestQuery(
|
||||
[t.PAYMENT_RECEIVES, query],
|
||||
{ method: 'get', url: 'sales/payment_receives', params: query },
|
||||
{ method: 'get', url: 'payments-received', params: query },
|
||||
{
|
||||
select: transformPaymentReceives,
|
||||
defaultData: {
|
||||
@@ -87,7 +87,7 @@ export function useCreatePaymentReceive(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(values) => apiRequest.post('sales/payment_receives', values),
|
||||
(values) => apiRequest.post('payments-received', values),
|
||||
{
|
||||
onSuccess: (data, values) => {
|
||||
// Invalidate specific payment receive.
|
||||
@@ -111,7 +111,7 @@ export function useEditPaymentReceive(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`sales/payment_receives/${id}`, values),
|
||||
([id, values]) => apiRequest.post(`payments-received/${id}`, values),
|
||||
{
|
||||
onSuccess: (data, [id, values]) => {
|
||||
// Invalidate specific payment receive.
|
||||
@@ -135,7 +135,7 @@ export function useDeletePaymentReceive(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(id) => apiRequest.delete(`sales/payment_receives/${id}`),
|
||||
(id) => apiRequest.delete(`payments-received/${id}`),
|
||||
{
|
||||
onSuccess: (data, id) => {
|
||||
// Invalidate specific payment receive.
|
||||
@@ -157,7 +157,7 @@ export function useDeletePaymentReceive(props) {
|
||||
export function usePaymentReceive(id, props) {
|
||||
return useRequestQuery(
|
||||
[t.PAYMENT_RECEIVE, id],
|
||||
{ method: 'get', url: `sales/payment_receives/${id}` },
|
||||
{ method: 'get', url: `payments-received/${id}` },
|
||||
{
|
||||
select: (res) => res.data.payment_receive,
|
||||
defaultData: {},
|
||||
@@ -173,7 +173,7 @@ export function usePaymentReceive(id, props) {
|
||||
export function usePaymentReceiveEditPage(id, props) {
|
||||
return useRequestQuery(
|
||||
[t.PAYMENT_RECEIVE_EDIT_PAGE, id],
|
||||
{ method: 'get', url: `sales/payment_receives/${id}/edit-page` },
|
||||
{ method: 'get', url: `payments-received/${id}/edit-page` },
|
||||
{
|
||||
select: (res) => ({
|
||||
paymentReceive: res.data.payment_receive,
|
||||
@@ -204,7 +204,7 @@ export function useCreateNotifyPaymentReceiveBySMS(props) {
|
||||
|
||||
return useMutation(
|
||||
([id, values]) =>
|
||||
apiRequest.post(`sales/payment_receives/${id}/notify-by-sms`, values),
|
||||
apiRequest.post(`payments-received/${id}/notify-by-sms`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Invalidate
|
||||
@@ -227,7 +227,7 @@ export function usePaymentReceiveSMSDetail(
|
||||
[t.PAYMENT_RECEIVE_SMS_DETAIL, paymentReceiveId],
|
||||
{
|
||||
method: 'get',
|
||||
url: `sales/payment_receives/${paymentReceiveId}/sms-details`,
|
||||
url: `payments-received/${paymentReceiveId}/sms-details`,
|
||||
...requestProps,
|
||||
},
|
||||
{
|
||||
@@ -243,7 +243,7 @@ export function usePaymentReceiveSMSDetail(
|
||||
* @param {number} paymentReceiveId - Payment receive id.
|
||||
*/
|
||||
export function usePdfPaymentReceive(paymentReceiveId) {
|
||||
return useRequestPdf({ url: `sales/payment_receives/${paymentReceiveId}` });
|
||||
return useRequestPdf({ url: `payments-received/${paymentReceiveId}` });
|
||||
}
|
||||
|
||||
interface SendPaymentReceiveMailValues {
|
||||
@@ -286,7 +286,7 @@ export function useSendPaymentReceiveMail(
|
||||
[number, SendPaymentReceiveMailValues]
|
||||
>(
|
||||
([id, values]) =>
|
||||
apiRequest.post(`sales/payment_receives/${id}/mail`, values),
|
||||
apiRequest.post(`payments-received/${id}/mail`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidate queries.
|
||||
@@ -335,7 +335,7 @@ export function usePaymentReceivedMailState(
|
||||
[t.PAYMENT_RECEIVE_MAIL_OPTIONS, paymentReceiveId],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`sales/payment_receives/${paymentReceiveId}/mail`)
|
||||
.get(`payments-received/${paymentReceiveId}/mail`)
|
||||
.then((res) => transformToCamelCase(res.data?.data)),
|
||||
);
|
||||
}
|
||||
@@ -359,7 +359,7 @@ export function usePaymentReceivedState(
|
||||
['PAYMENT_RECEIVED_STATE'],
|
||||
() =>
|
||||
apiRequest
|
||||
.get('/sales/payment_receives/state')
|
||||
.get('/payments-received/state')
|
||||
.then((res) => transformToCamelCase(res.data?.data)),
|
||||
{
|
||||
...options,
|
||||
@@ -387,7 +387,7 @@ export function useGetPaymentReceiveHtml(
|
||||
['PAYMENT_RECEIVED_HTML', paymentReceivedId],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`/sales/payment_receives/${paymentReceivedId}`, {
|
||||
.get(`/payments-received/${paymentReceivedId}`, {
|
||||
headers: {
|
||||
Accept: 'application/json+html',
|
||||
},
|
||||
|
||||
@@ -54,7 +54,7 @@ export function useCreateReceipt(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((values) => apiRequest.post('sales/receipts', values), {
|
||||
return useMutation((values) => apiRequest.post('sale-receipts', values), {
|
||||
onSuccess: () => {
|
||||
// Invalidate queries.
|
||||
commonInvalidateQueries(queryClient);
|
||||
@@ -71,7 +71,7 @@ export function useEditReceipt(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`sales/receipts/${id}`, values),
|
||||
([id, values]) => apiRequest.post(`sale-receipts/${id}`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Invalidate specific receipt.
|
||||
@@ -92,7 +92,7 @@ export function useDeleteReceipt(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.delete(`sales/receipts/${id}`), {
|
||||
return useMutation((id) => apiRequest.delete(`sale-receipts/${id}`), {
|
||||
onSuccess: (res, id) => {
|
||||
// Invalidate specific receipt.
|
||||
queryClient.invalidateQueries([t.SALE_RECEIPT, id]);
|
||||
@@ -111,7 +111,7 @@ export function useCloseReceipt(props) {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation((id) => apiRequest.post(`sales/receipts/${id}/close`), {
|
||||
return useMutation((id) => apiRequest.post(`sale-receipts/${id}/close`), {
|
||||
onSuccess: (res, id) => {
|
||||
queryClient.invalidateQueries([t.SALE_RECEIPT, id]);
|
||||
|
||||
@@ -134,7 +134,7 @@ const transformReceipts = (res) => ({
|
||||
export function useReceipts(query, props) {
|
||||
return useRequestQuery(
|
||||
['SALE_RECEIPTS', query],
|
||||
{ method: 'get', url: 'sales/receipts', params: query },
|
||||
{ method: 'get', url: 'sale-receipts', params: query },
|
||||
{
|
||||
select: transformReceipts,
|
||||
defaultData: {
|
||||
@@ -157,7 +157,7 @@ export function useReceipts(query, props) {
|
||||
export function useReceipt(id, props) {
|
||||
return useRequestQuery(
|
||||
['SALE_RECEIPT', id],
|
||||
{ method: 'get', url: `sales/receipts/${id}` },
|
||||
{ method: 'get', url: `sale-receipts/${id}` },
|
||||
{
|
||||
select: (res) => res.data.sale_receipt,
|
||||
defaultData: {},
|
||||
@@ -171,7 +171,7 @@ export function useReceipt(id, props) {
|
||||
* @param {number} receiptId -
|
||||
*/
|
||||
export function usePdfReceipt(receiptId: number) {
|
||||
return useRequestPdf({ url: `sales/receipts/${receiptId}` });
|
||||
return useRequestPdf({ url: `sale-receipts/${receiptId}` });
|
||||
}
|
||||
|
||||
export function useRefreshReceipts() {
|
||||
@@ -189,7 +189,7 @@ export function useCreateNotifyReceiptBySMS(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
return useMutation(
|
||||
([id, values]) =>
|
||||
apiRequest.post(`sales/receipts/${id}/notify-by-sms`, values),
|
||||
apiRequest.post(`sale-receipts/${id}/notify-by-sms`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
queryClient.invalidateQueries([t.NOTIFY_SALE_RECEIPT_BY_SMS, id]);
|
||||
@@ -207,7 +207,7 @@ export function useReceiptSMSDetail(receiptId, props, requestProps) {
|
||||
[t.SALE_RECEIPT_SMS_DETAIL, receiptId],
|
||||
{
|
||||
method: 'get',
|
||||
url: `sales/receipts/${receiptId}/sms-details`,
|
||||
url: `sale-receipts/${receiptId}/sms-details`,
|
||||
...requestProps,
|
||||
},
|
||||
{
|
||||
@@ -226,7 +226,7 @@ export function useSendSaleReceiptMail(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`sales/receipts/${id}/mail`, values),
|
||||
([id, values]) => apiRequest.post(`sale-receipts/${id}/mail`, values),
|
||||
{
|
||||
onSuccess: () => {
|
||||
// Invalidate queries.
|
||||
@@ -303,7 +303,7 @@ export function useSaleReceiptMailState(
|
||||
[t.SALE_RECEIPT_MAIL_OPTIONS, receiptId],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`sales/receipts/${receiptId}/mail`)
|
||||
.get(`sale-receipts/${receiptId}/mail`)
|
||||
.then((res) => transformToCamelCase(res.data.data)),
|
||||
);
|
||||
}
|
||||
@@ -321,7 +321,7 @@ export function useGetReceiptState(
|
||||
['SALE_RECEIPT_STATE'],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`/sales/receipts/state`)
|
||||
.get(`/sale-receipts/state`)
|
||||
.then((res) => transformToCamelCase(res.data?.data)),
|
||||
{ ...options },
|
||||
);
|
||||
@@ -347,7 +347,7 @@ export const useGetSaleReceiptHtml = (
|
||||
['SALE_RECEIPT_HTML', receiptId],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`sales/receipts/${receiptId}`, {
|
||||
.get(`sale-receipts/${receiptId}`, {
|
||||
headers: {
|
||||
Accept: 'application/json+html',
|
||||
},
|
||||
|
||||
@@ -94,7 +94,7 @@ export function useTransactionsLocking(query, props) {
|
||||
[t.TRANSACTIONS_LOCKING, query],
|
||||
{ method: 'get', url: 'transactions-locking', params: query },
|
||||
{
|
||||
select: (res) => res.data.data,
|
||||
select: (res) => res.data,
|
||||
defaultData: [],
|
||||
...props,
|
||||
},
|
||||
@@ -106,7 +106,7 @@ export function useEditTransactionsLocking(query, props) {
|
||||
[t.TRANSACTION_LOCKING, query],
|
||||
{ method: 'get', url: `transactions-locking/${query}` },
|
||||
{
|
||||
select: (res) => res.data.data,
|
||||
select: (res) => res.data,
|
||||
defaultData: [],
|
||||
...props,
|
||||
},
|
||||
|
||||
@@ -58,7 +58,7 @@ export function useCreateVendorCredit(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(values) => apiRequest.post('purchases/vendor-credit', values),
|
||||
(values) => apiRequest.post('vendor-credits', values),
|
||||
{
|
||||
onSuccess: (res, values) => {
|
||||
// Common invalidate queries.
|
||||
@@ -77,7 +77,7 @@ export function useEditVendorCredit(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
([id, values]) => apiRequest.post(`purchases/vendor-credit/${id}`, values),
|
||||
([id, values]) => apiRequest.post(`vendor-credits/${id}`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidate queries.
|
||||
@@ -99,7 +99,7 @@ export function useDeleteVendorCredit(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(id) => apiRequest.delete(`purchases/vendor-credit/${id}`),
|
||||
(id) => apiRequest.delete(`vendor-credits/${id}`),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
@@ -127,7 +127,7 @@ export function useVendorCredits(query, props) {
|
||||
[t.VENDOR_CREDITS, query],
|
||||
{
|
||||
method: 'get',
|
||||
url: 'purchases/vendor-credit',
|
||||
url: 'vendor-credits',
|
||||
params: query,
|
||||
},
|
||||
{
|
||||
@@ -154,7 +154,7 @@ export function useVendorCredits(query, props) {
|
||||
export function useVendorCredit(id, props, requestProps) {
|
||||
return useRequestQuery(
|
||||
[t.VENDOR_CREDIT, id],
|
||||
{ method: 'get', url: `purchases/vendor-credit/${id}`, ...requestProps },
|
||||
{ method: 'get', url: `vendor-credits/${id}`, ...requestProps },
|
||||
{
|
||||
select: (res) => res.data.data,
|
||||
defaultData: {},
|
||||
@@ -182,7 +182,7 @@ export function useCreateRefundVendorCredit(props) {
|
||||
|
||||
return useMutation(
|
||||
([id, values]) =>
|
||||
apiRequest.post(`purchases/vendor-credit/${id}/refund`, values),
|
||||
apiRequest.post(`vendor-credits/${id}/refund`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidate queries.
|
||||
@@ -204,7 +204,7 @@ export function useDeleteRefundVendorCredit(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(id) => apiRequest.delete(`purchases/vendor-credit/refunds/${id}`),
|
||||
(id) => apiRequest.delete(`vendor-credits/refunds/${id}`),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
@@ -228,7 +228,7 @@ export function useRefundVendorCredit(id, props, requestProps) {
|
||||
[t.REFUND_VENDOR_CREDIT, id],
|
||||
{
|
||||
method: 'get',
|
||||
url: `purchases/vendor-credit/${id}/refund`,
|
||||
url: `vendor-credits/${id}/refund`,
|
||||
...requestProps,
|
||||
},
|
||||
{
|
||||
@@ -247,7 +247,7 @@ export function useOpenVendorCredit(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(id) => apiRequest.post(`purchases/vendor-credit/${id}/open`),
|
||||
(id) => apiRequest.post(`vendor-credits/${id}/open`),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
@@ -270,7 +270,7 @@ export function useCreateReconcileVendorCredit(props) {
|
||||
|
||||
return useMutation(
|
||||
([id, values]) =>
|
||||
apiRequest.post(`purchases/vendor-credit/${id}/apply-to-bills`, values),
|
||||
apiRequest.post(`vendor-credits/${id}/apply-to-bills`, values),
|
||||
{
|
||||
onSuccess: (res, [id, values]) => {
|
||||
// Common invalidate queries.
|
||||
@@ -294,7 +294,7 @@ export function useReconcileVendorCredit(id, props, requestProps) {
|
||||
[t.RECONCILE_VENDOR_CREDIT, id],
|
||||
{
|
||||
method: 'get',
|
||||
url: `purchases/vendor-credit/${id}/apply-to-bills`,
|
||||
url: `vendor-credits/${id}/apply-to-bills`,
|
||||
...requestProps,
|
||||
},
|
||||
{
|
||||
@@ -313,7 +313,7 @@ export function useReconcileVendorCredits(id, props, requestProps) {
|
||||
[t.RECONCILE_VENDOR_CREDITS, id],
|
||||
{
|
||||
method: 'get',
|
||||
url: `purchases/vendor-credit/${id}/applied-bills`,
|
||||
url: `vendor-credits/${id}/applied-bills`,
|
||||
...requestProps,
|
||||
},
|
||||
{
|
||||
@@ -331,7 +331,7 @@ export function useDeleteReconcileVendorCredit(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation(
|
||||
(id) => apiRequest.delete(`purchases/vendor-credit/applied-to-bills/${id}`),
|
||||
(id) => apiRequest.delete(`vendor-credits/applied-to-bills/${id}`),
|
||||
{
|
||||
onSuccess: (res, id) => {
|
||||
// Common invalidate queries.
|
||||
@@ -355,7 +355,7 @@ export function useRefundVendorCreditTransaction(id, props, requestProps) {
|
||||
[t.REFUND_VENDOR_CREDIT_TRANSACTION, id],
|
||||
{
|
||||
method: 'get',
|
||||
url: `purchases/vendor-credit/refunds/${id}`,
|
||||
url: `vendor-credits/refunds/${id}`,
|
||||
...requestProps,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user