feat: income

This commit is contained in:
2024-12-12 20:23:38 +04:00
parent d5598a10b8
commit 38597b8f16
48 changed files with 627 additions and 438 deletions

View File

@@ -23,9 +23,9 @@ export type { BarcodeTemplateUpdateRequest } from './models/BarcodeTemplateUpdat
export type { BarcodeTemplateUpdateResponse } from './models/BarcodeTemplateUpdateResponse';
export type { BaseEnumListSchema } from './models/BaseEnumListSchema';
export type { BaseEnumSchema } from './models/BaseEnumSchema';
export type { BaseExpenseTagSchema } from './models/BaseExpenseTagSchema';
export type { BaseMarketplaceSchema } from './models/BaseMarketplaceSchema';
export type { BaseShippingWarehouseSchema } from './models/BaseShippingWarehouseSchema';
export type { BaseTransactionTagSchema } from './models/BaseTransactionTagSchema';
export type { BillPaymentStatus } from './models/BillPaymentStatus';
export type { BillStatusUpdateRequest } from './models/BillStatusUpdateRequest';
export type { Body_upload_passport_image } from './models/Body_upload_passport_image';
@@ -50,7 +50,6 @@ export type { CreateBoxInDealSchema } from './models/CreateBoxInDealSchema';
export type { CreateBoxInPalletSchema } from './models/CreateBoxInPalletSchema';
export type { CreateDealBillRequest } from './models/CreateDealBillRequest';
export type { CreateDealBillResponse } from './models/CreateDealBillResponse';
export type { CreateExpenseTagRequest } from './models/CreateExpenseTagRequest';
export type { CreateMarketplaceRequest } from './models/CreateMarketplaceRequest';
export type { CreateMarketplaceResponse } from './models/CreateMarketplaceResponse';
export type { CreatePalletResponse } from './models/CreatePalletResponse';
@@ -69,6 +68,7 @@ export type { CreateShippingProductSchema } from './models/CreateShippingProduct
export type { CreateShippingWarehouseRequest } from './models/CreateShippingWarehouseRequest';
export type { CreateShippingWarehouseResponse } from './models/CreateShippingWarehouseResponse';
export type { CreateTaskResponse } from './models/CreateTaskResponse';
export type { CreateTransactionTagRequest } from './models/CreateTransactionTagRequest';
export type { CreateUserRequest } from './models/CreateUserRequest';
export type { CreateUserResponse } from './models/CreateUserResponse';
export type { DealAddKitRequest } from './models/DealAddKitRequest';
@@ -139,8 +139,6 @@ export type { DealUpdateServiceQuantityResponse } from './models/DealUpdateServi
export type { DealUpdateServiceRequest } from './models/DealUpdateServiceRequest';
export type { DealUpdateServiceResponse } from './models/DealUpdateServiceResponse';
export type { DeleteBoxResponse } from './models/DeleteBoxResponse';
export type { DeleteExpenseResponse } from './models/DeleteExpenseResponse';
export type { DeleteExpenseTagResponse } from './models/DeleteExpenseTagResponse';
export type { DeleteMarketplaceRequest } from './models/DeleteMarketplaceRequest';
export type { DeleteMarketplaceResponse } from './models/DeleteMarketplaceResponse';
export type { DeletePalletResponse } from './models/DeletePalletResponse';
@@ -156,8 +154,8 @@ export type { DeleteShiftResponse } from './models/DeleteShiftResponse';
export type { DeleteShippingProductResponse } from './models/DeleteShippingProductResponse';
export type { DeleteShippingWarehouseRequest } from './models/DeleteShippingWarehouseRequest';
export type { DeleteShippingWarehouseResponse } from './models/DeleteShippingWarehouseResponse';
export type { ExpenseSchemaBase } from './models/ExpenseSchemaBase';
export type { ExpenseTagSchema } from './models/ExpenseTagSchema';
export type { DeleteTransactionResponse } from './models/DeleteTransactionResponse';
export type { DeleteTransactionTagResponse } from './models/DeleteTransactionTagResponse';
export type { FinishPauseByShiftIdResponse } from './models/FinishPauseByShiftIdResponse';
export type { FinishPauseByUserIdResponse } from './models/FinishPauseByUserIdResponse';
export type { FinishShiftByIdResponse } from './models/FinishShiftByIdResponse';
@@ -166,8 +164,6 @@ export type { GetAllBarcodeTemplateAttributesResponse } from './models/GetAllBar
export type { GetAllBarcodeTemplateSizesResponse } from './models/GetAllBarcodeTemplateSizesResponse';
export type { GetAllBarcodeTemplatesResponse } from './models/GetAllBarcodeTemplatesResponse';
export type { GetAllBaseMarketplacesResponse } from './models/GetAllBaseMarketplacesResponse';
export type { GetAllExpensesResponse } from './models/GetAllExpensesResponse';
export type { GetAllExpenseTagsResponse } from './models/GetAllExpenseTagsResponse';
export type { GetAllPayRatesResponse } from './models/GetAllPayRatesResponse';
export type { GetAllPayrollSchemeResponse } from './models/GetAllPayrollSchemeResponse';
export type { GetAllPositionsResponse } from './models/GetAllPositionsResponse';
@@ -175,6 +171,9 @@ export type { GetAllPriceCategoriesResponse } from './models/GetAllPriceCategori
export type { GetAllRolesResponse } from './models/GetAllRolesResponse';
export type { GetAllServicesKitsResponse } from './models/GetAllServicesKitsResponse';
export type { GetAllShippingWarehousesResponse } from './models/GetAllShippingWarehousesResponse';
export type { GetAllTransactionsRequest } from './models/GetAllTransactionsRequest';
export type { GetAllTransactionsResponse } from './models/GetAllTransactionsResponse';
export type { GetAllTransactionTagsResponse } from './models/GetAllTransactionTagsResponse';
export type { GetAllUsersResponse } from './models/GetAllUsersResponse';
export type { GetBarcodeTemplateByIdRequest } from './models/GetBarcodeTemplateByIdRequest';
export type { GetBarcodeTemplateByIdResponse } from './models/GetBarcodeTemplateByIdResponse';
@@ -196,6 +195,7 @@ export type { GetProfitTableDataResponse } from './models/GetProfitTableDataResp
export type { GetServiceKitSchema } from './models/GetServiceKitSchema';
export type { GetTimeTrackingRecordsRequest } from './models/GetTimeTrackingRecordsRequest';
export type { GetTimeTrackingRecordsResponse } from './models/GetTimeTrackingRecordsResponse';
export type { GetTransactionTagsResponse } from './models/GetTransactionTagsResponse';
export type { GetWorkShiftsResponse } from './models/GetWorkShiftsResponse';
export type { GroupBillRequestSchema } from './models/GroupBillRequestSchema';
export type { HTTPValidationError } from './models/HTTPValidationError';
@@ -266,14 +266,11 @@ export type { SynchronizeMarketplaceRequest } from './models/SynchronizeMarketpl
export type { TaskInfoResponse } from './models/TaskInfoResponse';
export type { TimeTrackingData } from './models/TimeTrackingData';
export type { TimeTrackingRecord } from './models/TimeTrackingRecord';
export type { TransactionSchemaBase } from './models/TransactionSchemaBase';
export type { TransactionTagSchema } from './models/TransactionTagSchema';
export type { UpdateBoxRequest } from './models/UpdateBoxRequest';
export type { UpdateBoxResponse } from './models/UpdateBoxResponse';
export type { UpdateBoxSchema } from './models/UpdateBoxSchema';
export type { UpdateExpenseRequest } from './models/UpdateExpenseRequest';
export type { UpdateExpenseResponse } from './models/UpdateExpenseResponse';
export type { UpdateExpenseSchema } from './models/UpdateExpenseSchema';
export type { UpdateExpenseTagRequest } from './models/UpdateExpenseTagRequest';
export type { UpdateExpenseTagResponse } from './models/UpdateExpenseTagResponse';
export type { UpdateMarketplaceRequest } from './models/UpdateMarketplaceRequest';
export type { UpdateMarketplaceResponse } from './models/UpdateMarketplaceResponse';
export type { UpdatePayRateRequest } from './models/UpdatePayRateRequest';
@@ -290,6 +287,11 @@ export type { UpdateShippingWarehouseRequest } from './models/UpdateShippingWare
export type { UpdateShippingWarehouseResponse } from './models/UpdateShippingWarehouseResponse';
export type { UpdateTimeTrackingRecordRequest } from './models/UpdateTimeTrackingRecordRequest';
export type { UpdateTimeTrackingRecordResponse } from './models/UpdateTimeTrackingRecordResponse';
export type { UpdateTransactionRequest } from './models/UpdateTransactionRequest';
export type { UpdateTransactionResponse } from './models/UpdateTransactionResponse';
export type { UpdateTransactionSchema } from './models/UpdateTransactionSchema';
export type { UpdateTransactionTagRequest } from './models/UpdateTransactionTagRequest';
export type { UpdateTransactionTagResponse } from './models/UpdateTransactionTagResponse';
export type { UpdateUserRequest } from './models/UpdateUserRequest';
export type { UpdateUserResponse } from './models/UpdateUserResponse';
export type { UploadPassportImageResponse } from './models/UploadPassportImageResponse';
@@ -305,7 +307,6 @@ export { BarcodeService } from './services/BarcodeService';
export { BillingService } from './services/BillingService';
export { ClientService } from './services/ClientService';
export { DealService } from './services/DealService';
export { ExpenseService } from './services/ExpenseService';
export { MarketplaceService } from './services/MarketplaceService';
export { PayrollService } from './services/PayrollService';
export { PositionService } from './services/PositionService';
@@ -317,5 +318,6 @@ export { ShippingWarehouseService } from './services/ShippingWarehouseService';
export { StatisticsService } from './services/StatisticsService';
export { TaskService } from './services/TaskService';
export { TimeTrackingService } from './services/TimeTrackingService';
export { TransactionService } from './services/TransactionService';
export { UserService } from './services/UserService';
export { WorkShiftsService } from './services/WorkShiftsService';

View File

@@ -2,7 +2,8 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type BaseExpenseTagSchema = {
export type BaseTransactionTagSchema = {
name: string;
isIncome: boolean;
};

View File

@@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { BaseTransactionTagSchema } from './BaseTransactionTagSchema';
export type CreateTransactionTagRequest = {
tag: BaseTransactionTagSchema;
};

View File

@@ -2,7 +2,7 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type UpdateExpenseResponse = {
export type DeleteTransactionResponse = {
ok: boolean;
message: string;
};

View File

@@ -2,7 +2,7 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type DeleteExpenseResponse = {
export type DeleteTransactionTagResponse = {
ok: boolean;
message: string;
};

View File

@@ -1,9 +0,0 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ExpenseTagSchema } from './ExpenseTagSchema';
export type GetAllExpenseTagsResponse = {
tags: Array<ExpenseTagSchema>;
};

View File

@@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { TransactionTagSchema } from './TransactionTagSchema';
export type GetAllTransactionTagsResponse = {
tags: Array<TransactionTagSchema>;
};

View File

@@ -0,0 +1,8 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type GetAllTransactionsRequest = {
isIncome: boolean;
};

View File

@@ -2,10 +2,10 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ExpenseSchemaBase } from './ExpenseSchemaBase';
import type { PaginationInfoSchema } from './PaginationInfoSchema';
export type GetAllExpensesResponse = {
expenses: Array<ExpenseSchemaBase>;
import type { TransactionSchemaBase } from './TransactionSchemaBase';
export type GetAllTransactionsResponse = {
transactions: Array<TransactionSchemaBase>;
paginationInfo: PaginationInfoSchema;
};

View File

@@ -8,6 +8,7 @@ export type GetProfitChartDataRequest = {
baseMarketplaceKey: string;
dealStatusId: number;
managerId: number;
tagId: number;
expenseTagId: number;
incomeTagId: number;
};

View File

@@ -9,7 +9,8 @@ export type GetProfitTableDataRequest = {
baseMarketplaceKey: string;
dealStatusId: number;
managerId: number;
tagId: number;
expenseTagId: number;
incomeTagId: number;
groupTableBy: ProfitTableGroupBy;
};

View File

@@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { TransactionTagSchema } from './TransactionTagSchema';
export type GetTransactionTagsResponse = {
tags: Array<TransactionTagSchema>;
};

View File

@@ -2,15 +2,16 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ExpenseTagSchema } from './ExpenseTagSchema';
import type { TransactionTagSchema } from './TransactionTagSchema';
import type { UserSchema } from './UserSchema';
export type ExpenseSchemaBase = {
export type TransactionSchemaBase = {
id: number;
name: string;
comment: string;
amount: number;
createdByUser: UserSchema;
spentDate: string;
tags: Array<ExpenseTagSchema>;
isIncome: boolean;
tags: Array<TransactionTagSchema>;
};

View File

@@ -2,8 +2,9 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type ExpenseTagSchema = {
export type TransactionTagSchema = {
name: string;
isIncome: boolean;
id: number;
};

View File

@@ -1,9 +0,0 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { UpdateExpenseSchema } from './UpdateExpenseSchema';
export type UpdateExpenseRequest = {
expense: UpdateExpenseSchema;
};

View File

@@ -1,9 +0,0 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { ExpenseTagSchema } from './ExpenseTagSchema';
export type UpdateExpenseTagRequest = {
tag: ExpenseTagSchema;
};

View File

@@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { UpdateTransactionSchema } from './UpdateTransactionSchema';
export type UpdateTransactionRequest = {
transaction: UpdateTransactionSchema;
};

View File

@@ -2,7 +2,7 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type UpdateExpenseTagResponse = {
export type UpdateTransactionResponse = {
ok: boolean;
message: string;
};

View File

@@ -2,12 +2,13 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type UpdateExpenseSchema = {
export type UpdateTransactionSchema = {
id?: (number | null);
name: string;
comment?: (string | null);
amount: number;
spentDate: string;
isIncome: boolean;
tags?: Array<string>;
};

View File

@@ -2,8 +2,8 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { BaseExpenseTagSchema } from './BaseExpenseTagSchema';
export type CreateExpenseTagRequest = {
tag: BaseExpenseTagSchema;
import type { TransactionTagSchema } from './TransactionTagSchema';
export type UpdateTransactionTagRequest = {
tag: TransactionTagSchema;
};

View File

@@ -2,7 +2,7 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type DeleteExpenseTagResponse = {
export type UpdateTransactionTagResponse = {
ok: boolean;
message: string;
};

View File

@@ -1,155 +0,0 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { CreateExpenseTagRequest } from '../models/CreateExpenseTagRequest';
import type { DeleteExpenseResponse } from '../models/DeleteExpenseResponse';
import type { DeleteExpenseTagResponse } from '../models/DeleteExpenseTagResponse';
import type { GetAllExpensesResponse } from '../models/GetAllExpensesResponse';
import type { GetAllExpenseTagsResponse } from '../models/GetAllExpenseTagsResponse';
import type { UpdateExpenseRequest } from '../models/UpdateExpenseRequest';
import type { UpdateExpenseResponse } from '../models/UpdateExpenseResponse';
import type { UpdateExpenseTagRequest } from '../models/UpdateExpenseTagRequest';
import type { UpdateExpenseTagResponse } from '../models/UpdateExpenseTagResponse';
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
export class ExpenseService {
/**
* Get All
* @returns GetAllExpensesResponse Successful Response
* @throws ApiError
*/
public static getAllExpenses({
page,
itemsPerPage,
}: {
page?: (number | null),
itemsPerPage?: (number | null),
}): CancelablePromise<GetAllExpensesResponse> {
return __request(OpenAPI, {
method: 'GET',
url: '/expense/get-all',
query: {
'page': page,
'items_per_page': itemsPerPage,
},
errors: {
422: `Validation Error`,
},
});
}
/**
* Update Expense
* @returns UpdateExpenseResponse Successful Response
* @throws ApiError
*/
public static updateExpense({
requestBody,
}: {
requestBody: UpdateExpenseRequest,
}): CancelablePromise<UpdateExpenseResponse> {
return __request(OpenAPI, {
method: 'POST',
url: '/expense/update',
body: requestBody,
mediaType: 'application/json',
errors: {
422: `Validation Error`,
},
});
}
/**
* Delete Expense
* @returns DeleteExpenseResponse Successful Response
* @throws ApiError
*/
public static deleteExpense({
expenseId,
}: {
expenseId: number,
}): CancelablePromise<DeleteExpenseResponse> {
return __request(OpenAPI, {
method: 'DELETE',
url: '/expense/delete/{expense_id}',
path: {
'expense_id': expenseId,
},
errors: {
422: `Validation Error`,
},
});
}
/**
* Get All
* @returns GetAllExpenseTagsResponse Successful Response
* @throws ApiError
*/
public static getAllExpenseTags(): CancelablePromise<GetAllExpenseTagsResponse> {
return __request(OpenAPI, {
method: 'GET',
url: '/expense/get-all-tags',
});
}
/**
* Update Expense
* @returns UpdateExpenseTagResponse Successful Response
* @throws ApiError
*/
public static createExpenseTag({
requestBody,
}: {
requestBody: CreateExpenseTagRequest,
}): CancelablePromise<UpdateExpenseTagResponse> {
return __request(OpenAPI, {
method: 'POST',
url: '/expense/create-tag',
body: requestBody,
mediaType: 'application/json',
errors: {
422: `Validation Error`,
},
});
}
/**
* Update Expense
* @returns UpdateExpenseTagResponse Successful Response
* @throws ApiError
*/
public static updateExpenseTag({
requestBody,
}: {
requestBody: UpdateExpenseTagRequest,
}): CancelablePromise<UpdateExpenseTagResponse> {
return __request(OpenAPI, {
method: 'POST',
url: '/expense/update-tag',
body: requestBody,
mediaType: 'application/json',
errors: {
422: `Validation Error`,
},
});
}
/**
* Update Expense
* @returns DeleteExpenseTagResponse Successful Response
* @throws ApiError
*/
public static deleteExpenseTag({
tagId,
}: {
tagId: number,
}): CancelablePromise<DeleteExpenseTagResponse> {
return __request(OpenAPI, {
method: 'DELETE',
url: '/expense/delete-tag/{tag_id}',
path: {
'tag_id': tagId,
},
errors: {
422: `Validation Error`,
},
});
}
}

View File

@@ -139,7 +139,7 @@ export class ShippingService {
});
}
/**
* Generate Deal Qr Code
* Generate Deal Qr Code Pdf
* @returns any Successful Response
* @throws ApiError
*/
@@ -160,7 +160,7 @@ export class ShippingService {
});
}
/**
* Generate Deal Qr Code
* Generate Pallets Pdf
* @returns any Successful Response
* @throws ApiError
*/
@@ -180,4 +180,25 @@ export class ShippingService {
},
});
}
/**
* Generate Boxes Pdf
* @returns any Successful Response
* @throws ApiError
*/
public static getBoxesPdf({
dealId,
}: {
dealId: number,
}): CancelablePromise<any> {
return __request(OpenAPI, {
method: 'GET',
url: '/shipping/pdf/boxes/{deal_id}',
path: {
'deal_id': dealId,
},
errors: {
422: `Validation Error`,
},
});
}
}

View File

@@ -0,0 +1,182 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { CreateTransactionTagRequest } from '../models/CreateTransactionTagRequest';
import type { DeleteTransactionResponse } from '../models/DeleteTransactionResponse';
import type { DeleteTransactionTagResponse } from '../models/DeleteTransactionTagResponse';
import type { GetAllTransactionsRequest } from '../models/GetAllTransactionsRequest';
import type { GetAllTransactionsResponse } from '../models/GetAllTransactionsResponse';
import type { GetAllTransactionTagsResponse } from '../models/GetAllTransactionTagsResponse';
import type { GetTransactionTagsResponse } from '../models/GetTransactionTagsResponse';
import type { UpdateTransactionRequest } from '../models/UpdateTransactionRequest';
import type { UpdateTransactionResponse } from '../models/UpdateTransactionResponse';
import type { UpdateTransactionTagRequest } from '../models/UpdateTransactionTagRequest';
import type { UpdateTransactionTagResponse } from '../models/UpdateTransactionTagResponse';
import type { CancelablePromise } from '../core/CancelablePromise';
import { OpenAPI } from '../core/OpenAPI';
import { request as __request } from '../core/request';
export class TransactionService {
/**
* Get All
* @returns GetAllTransactionsResponse Successful Response
* @throws ApiError
*/
public static getAllTransactions({
requestBody,
page,
itemsPerPage,
}: {
requestBody: GetAllTransactionsRequest,
page?: (number | null),
itemsPerPage?: (number | null),
}): CancelablePromise<GetAllTransactionsResponse> {
return __request(OpenAPI, {
method: 'POST',
url: '/transaction/get-all',
query: {
'page': page,
'items_per_page': itemsPerPage,
},
body: requestBody,
mediaType: 'application/json',
errors: {
422: `Validation Error`,
},
});
}
/**
* Update Transaction
* @returns UpdateTransactionResponse Successful Response
* @throws ApiError
*/
public static updateTransaction({
requestBody,
}: {
requestBody: UpdateTransactionRequest,
}): CancelablePromise<UpdateTransactionResponse> {
return __request(OpenAPI, {
method: 'POST',
url: '/transaction/update',
body: requestBody,
mediaType: 'application/json',
errors: {
422: `Validation Error`,
},
});
}
/**
* Delete Transaction
* @returns DeleteTransactionResponse Successful Response
* @throws ApiError
*/
public static deleteTransaction({
transactionId,
}: {
transactionId: number,
}): CancelablePromise<DeleteTransactionResponse> {
return __request(OpenAPI, {
method: 'DELETE',
url: '/transaction/delete/{transaction_id}',
path: {
'transaction_id': transactionId,
},
errors: {
422: `Validation Error`,
},
});
}
/**
* Get All Transaction Tags
* @returns GetAllTransactionTagsResponse Successful Response
* @throws ApiError
*/
public static getAllTransactionTags(): CancelablePromise<GetAllTransactionTagsResponse> {
return __request(OpenAPI, {
method: 'GET',
url: '/transaction/get-all-tags',
});
}
/**
* Get Transaction Tags
* @returns GetTransactionTagsResponse Successful Response
* @throws ApiError
*/
public static getTransactionTags({
isIncome,
}: {
isIncome: boolean,
}): CancelablePromise<GetTransactionTagsResponse> {
return __request(OpenAPI, {
method: 'GET',
url: '/transaction/get-tags/{is_income}',
path: {
'is_income': isIncome,
},
errors: {
422: `Validation Error`,
},
});
}
/**
* Create Transaction Tag
* @returns UpdateTransactionTagResponse Successful Response
* @throws ApiError
*/
public static createTransactionTag({
requestBody,
}: {
requestBody: CreateTransactionTagRequest,
}): CancelablePromise<UpdateTransactionTagResponse> {
return __request(OpenAPI, {
method: 'POST',
url: '/transaction/create-tag',
body: requestBody,
mediaType: 'application/json',
errors: {
422: `Validation Error`,
},
});
}
/**
* Update Transaction Tag
* @returns UpdateTransactionTagResponse Successful Response
* @throws ApiError
*/
public static updateTransactionTag({
requestBody,
}: {
requestBody: UpdateTransactionTagRequest,
}): CancelablePromise<UpdateTransactionTagResponse> {
return __request(OpenAPI, {
method: 'POST',
url: '/transaction/update-tag',
body: requestBody,
mediaType: 'application/json',
errors: {
422: `Validation Error`,
},
});
}
/**
* Update Transaction Tag
* @returns DeleteTransactionTagResponse Successful Response
* @throws ApiError
*/
public static deleteTransactionTag({
tagId,
}: {
tagId: number,
}): CancelablePromise<DeleteTransactionTagResponse> {
return __request(OpenAPI, {
method: 'DELETE',
url: '/transaction/delete-tag/{tag_id}',
path: {
'tag_id': tagId,
},
errors: {
422: `Validation Error`,
},
});
}
}

View File

@@ -22,8 +22,8 @@ import ShippingWarehouseForm from "../pages/ShippingWarehousesPage/modals/Shippi
import MarketplaceFormModal from "../pages/MarketplacesPage/modals/MarketplaceFormModal/MarketplaceFormModal.tsx";
import ServicePriceCategoryForm from "../pages/ServicesPage/modals/ServicePriceCategoryForm.tsx";
import ScanningModal from "./ScanningModal/ScanningModal.tsx";
import ExpenseFormModal from "../pages/AdminPage/tabs/Expenses/modals/ExpenseFormModal.tsx";
import ExpenseTagsModal from "../pages/AdminPage/tabs/Expenses/modals/ExpenseTagsModal.tsx";
import TransactionFormModal from "../pages/AdminPage/tabs/Transactions/modals/TransactionFormModal.tsx";
import TransactionTagsModal from "../pages/AdminPage/tabs/Transactions/modals/TransactionTagsModal.tsx";
import ShippingProductModal from "../pages/LeadsPage/tabs/ShippingTab/modals/ShippingProductModal.tsx";
export const modals = {
@@ -51,7 +51,7 @@ export const modals = {
marketplaceFormModal: MarketplaceFormModal,
servicePriceCategoryForm: ServicePriceCategoryForm,
scanningModal: ScanningModal,
expenseFormModal: ExpenseFormModal,
expenseTagsModal: ExpenseTagsModal,
transactionFormModal: TransactionFormModal,
transactionTagsModal: TransactionTagsModal,
shippingProductModal: ShippingProductModal,
};

View File

@@ -15,7 +15,7 @@ import { motion } from "framer-motion";
import FinancesTab from "./tabs/Finances/FinancesTab.tsx";
import WorkTimeTable from "./tabs/WorkTimeTable/ui/WorkTimeTable.tsx";
import { WorkShiftsTab } from "./tabs/WorkShifts/WorkShiftsTab.tsx";
import { ExpensesTab } from "./tabs/Expenses/ExpensesTab.tsx";
import { TransactionsTab } from "./tabs/Transactions/TransactionsTab.tsx";
import { useSelector } from "react-redux";
import { RootState } from "../../redux/store.ts";
@@ -62,9 +62,9 @@ const AdminPage = () => {
</Tabs.Tab>
{isAdmin && (
<Tabs.Tab
value={"expenses"}
value={"transactions"}
leftSection={<IconCoins />}>
Расходы
Доходы и расходы
</Tabs.Tab>
)}
</Tabs.List>
@@ -108,12 +108,12 @@ const AdminPage = () => {
<WorkShiftsTab />
</motion.div>
</Tabs.Panel>
<Tabs.Panel value={"expenses"}>
<Tabs.Panel value={"transactions"}>
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.2 }}>
<ExpensesTab />
<TransactionsTab />
</motion.div>
</Tabs.Panel>
</Tabs>

View File

@@ -0,0 +1,10 @@
import ObjectList from "../../../hooks/objectList.tsx";
import { TransactionService } from "../../../client";
const useAllTransactionTagsList = () =>
ObjectList({
queryFn: () => TransactionService.getAllTransactionTags(),
getObjectsFn: response => response.tags,
queryKey: "getAllTransactionTags",
});
export default useAllTransactionTagsList;

View File

@@ -1,10 +0,0 @@
import ObjectList from "../../../hooks/objectList.tsx";
import { ExpenseService } from "../../../client";
const useExpenseTagsList = () =>
ObjectList({
queryFn: ExpenseService.getAllExpenseTags,
getObjectsFn: response => response.tags,
queryKey: "getAllExpenseTags",
});
export default useExpenseTagsList;

View File

@@ -1,12 +0,0 @@
import { Pagination } from "../../../types/Pagination.ts";
import { ObjectListWithPagination } from "../../../hooks/objectList.tsx";
import { ExpenseService } from "../../../client";
export const useExpensesList = (pagination: Pagination) =>
ObjectListWithPagination({
queryFn: () => ExpenseService.getAllExpenses(pagination),
queryKey: "getExpenses",
getObjectsFn: response => response.expenses,
pagination,
});

View File

@@ -0,0 +1,16 @@
import ObjectList from "../../../hooks/objectList.tsx";
import { TransactionService } from "../../../client";
type Props = {
isIncome: boolean;
}
const useTransactionTagsList = ({ isIncome }: Props) =>
ObjectList({
queryFn: () => TransactionService.getTransactionTags(
{ isIncome },
),
getObjectsFn: response => response.tags,
queryKey: "getTransactionTags",
});
export default useTransactionTagsList;

View File

@@ -0,0 +1,21 @@
import { Pagination } from "../../../types/Pagination.ts";
import { ObjectListWithPagination } from "../../../hooks/objectList.tsx";
import { TransactionService } from "../../../client";
type TransitionType = {
isIncome: boolean
};
type Props = Pagination & TransitionType;
export const useTransactionsList = (props: Props) =>
ObjectListWithPagination({
queryFn: () => TransactionService.getAllTransactions({
requestBody: {
isIncome: props.isIncome,
},
...props,
}),
queryKey: "getTransactions",
getObjectsFn: response => response.transactions,
pagination: props,
});

View File

@@ -1,19 +0,0 @@
import { TagsInput, TagsInputProps } from "@mantine/core";
import useExpenseTagsList from "../../../hooks/useExpenseTagsList.tsx";
type Props = Omit<TagsInputProps, "data">;
const ExpenseTagsInput = (props: Props) => {
const { objects } = useExpenseTagsList();
return (
<TagsInput
data={objects.map(object => object.name)}
{...props}
label={"Теги"}
placeholder={"Выберите теги"}
/>
);
};
export default ExpenseTagsInput;

View File

@@ -1,39 +1,44 @@
import { useExpensesList } from "../../hooks/useExpensesList.tsx";
import { useExpensesTableColumns } from "./hooks/useExpensesTableColumns.tsx";
import { ExpenseSchemaBase, ExpenseService } from "../../../../client";
import { useTransactionsList } from "../../hooks/useTransactionsList.tsx";
import { useTransactionsTableColumns } from "./hooks/useTransactionsTableColumns.tsx";
import { TransactionSchemaBase, TransactionService } from "../../../../client";
import { dateToString } from "../../../../types/utils.ts";
import { notifications } from "../../../../shared/lib/notifications.ts";
import { modals } from "@mantine/modals";
import { BaseTable } from "../../../../components/BaseTable/BaseTable.tsx";
import { Pagination, Flex, rem, Button, Tooltip, ActionIcon } from "@mantine/core";
import { ActionIcon, Button, Flex, Pagination, rem, Tooltip } from "@mantine/core";
import { useEffect, useState } from "react";
import { IconEdit, IconTrash } from "@tabler/icons-react";
import { MRT_TableOptions } from "mantine-react-table";
import { Expense } from "./types/Expense.tsx";
import { Transaction } from "./types/Transaction.tsx";
import { TransactionsSegmentedControl, TransactionType } from "./components/TransactionsSegmentedControl.tsx";
export const ExpensesTab = () => {
export const TransactionsTab = () => {
const [transactionType, setTransactionType] = useState<TransactionType>(TransactionType.EXPENSE);
const isIncome = transactionType === TransactionType.INCOME;
const [totalPages, setTotalPages] = useState(10);
const [page, setPage] = useState(1);
const {
pagination: paginationInfo,
objects: expenses,
objects: transactions,
refetch,
} = useExpensesList({ page: page, itemsPerPage: 10 });
const columns = useExpensesTableColumns();
} = useTransactionsList({ page: page, itemsPerPage: 10, isIncome });
const columns = useTransactionsTableColumns();
useEffect(() => {
if (!paginationInfo ) return;
if (!paginationInfo) return;
if (!paginationInfo.totalPages) setTotalPages(0);
else setTotalPages(paginationInfo.totalPages);
}, [paginationInfo]);
const onUpdate = (expense: Expense) => {
ExpenseService.updateExpense({
const onUpdate = (transaction: Transaction) => {
TransactionService.updateTransaction({
requestBody: {
expense: {
...expense,
spentDate: dateToString(new Date(expense.spentDate)) ?? "",
transaction: {
...transaction,
spentDate: dateToString(new Date(transaction.spentDate)) ?? "",
isIncome,
},
},
})
@@ -44,33 +49,37 @@ export const ExpensesTab = () => {
.catch(err => console.log(err));
};
const modalTitleSuffix = isIncome ? "доходах" : "расходах";
const onCreateClick = () => {
modals.openContextModal({
modal: "expenseFormModal",
title: "Создание записи о расходах",
modal: "transactionFormModal",
title: `Создание записи о ${modalTitleSuffix}`,
withCloseButton: false,
innerProps: {
onCreate: onUpdate,
isIncome,
},
});
};
const onEditClick = (expense: ExpenseSchemaBase) => {
const expenseToEdit = { ...expense, tags: expense.tags.map(tag => tag.name) };
const onEditClick = (transaction: TransactionSchemaBase) => {
const expenseToEdit = { ...transaction, tags: transaction.tags.map(tag => tag.name) };
modals.openContextModal({
modal: "expenseFormModal",
title: "Редактирование записи о расходах",
modal: "transactionFormModal",
title: `Редактирование записи о ${modalTitleSuffix}`,
withCloseButton: false,
innerProps: {
onChange: event => onUpdate(event),
onChange: onUpdate,
element: expenseToEdit,
isIncome,
},
});
};
const onDeleteClick = (expense: ExpenseSchemaBase) => {
ExpenseService.deleteExpense({
expenseId: expense.id,
const onDeleteClick = (transaction: TransactionSchemaBase) => {
TransactionService.deleteTransaction({
transactionId: transaction.id,
})
.then(async ({ ok, message }) => {
notifications.guess(ok, { message });
@@ -81,24 +90,48 @@ export const ExpensesTab = () => {
const onTagChange = async () => {
await refetch();
}
};
const onTagsEditClick = () => {
modals.openContextModal({
modal: "expenseTagsModal",
modal: "transactionTagsModal",
title: "Редактирование тегов",
withCloseButton: false,
innerProps: { onChange: onTagChange },
innerProps: {
onChange: onTagChange,
isIncome,
},
});
}
};
const getCreateTransactionLabel = (): string => {
if (transactionType === TransactionType.EXPENSE) {
return "Создать запись о расходах";
}
return "Создать запись о доходах";
};
const getEditTagLabel = (): string => {
if (transactionType === TransactionType.EXPENSE) {
return "Редактировать теги для расходов";
}
return "Редактировать теги для доходов";
};
return (
<Flex
direction={"column"}
h={"100%"}
gap={rem(10)}>
gap={0}>
<TransactionsSegmentedControl
value={transactionType.toString()}
onChange={event => {
setPage(1);
setTransactionType(parseInt(event));
}}
/>
<BaseTable
data={expenses}
data={transactions}
columns={columns}
restProps={
{
@@ -111,12 +144,12 @@ export const ExpensesTab = () => {
<Button
variant={"default"}
onClick={() => onCreateClick()}>
Создать запись о расходах
{getCreateTransactionLabel()}
</Button>
<Button
variant={"default"}
onClick={() => onTagsEditClick()}>
Редактировать теги
{getEditTagLabel()}
</Button>
</Flex>
),
@@ -138,7 +171,7 @@ export const ExpensesTab = () => {
</Tooltip>
</Flex>
),
} as MRT_TableOptions<ExpenseSchemaBase>
} as MRT_TableOptions<TransactionSchemaBase>
}
/>
{totalPages > 1 && (

View File

@@ -1,31 +1,35 @@
import { BaseExpenseTagSchema } from "../../../../../client";
import { BaseTransactionTagSchema } from "../../../../../client";
import { Button, Stack, TextInput } from "@mantine/core";
import { useState } from "react";
import { notifications } from "../../../../../shared/lib/notifications.ts";
type Props = {
onCreate: (tag: BaseExpenseTagSchema) => void;
onCreate: (tag: BaseTransactionTagSchema) => void;
isIncome: boolean;
}
const CreateExpenseTagForm = ({ onCreate }: Props) => {
const [expenseTag, setExpenseTag] = useState<string>("");
const CreateTransactionTagForm = ({ onCreate, isIncome }: Props) => {
const [transactionTag, setTransactionTag] = useState<string>("");
const onCreateClick = () => {
if (expenseTag.length === 0) {
if (transactionTag.length === 0) {
notifications.error({ message: "Нельзя добавить тег без названия" });
return;
}
onCreate({ name: expenseTag });
setExpenseTag("");
onCreate({
name: transactionTag,
isIncome: isIncome,
});
setTransactionTag("");
};
return (
<Stack>
<TextInput
label={"Добавить тег"}
value={expenseTag}
onChange={event => setExpenseTag(event.target.value)}
value={transactionTag}
onChange={event => setTransactionTag(event.target.value)}
/>
<Button
variant={"default"}
@@ -36,4 +40,4 @@ const CreateExpenseTagForm = ({ onCreate }: Props) => {
);
};
export default CreateExpenseTagForm;
export default CreateTransactionTagForm;

View File

@@ -0,0 +1,22 @@
import { TagsInput, TagsInputProps } from "@mantine/core";
import useTransactionTagsList from "../../../hooks/useTransactionTagsList.tsx";
type IsIncome = {
isIncome: boolean;
}
type Props = Omit<TagsInputProps, "data"> & IsIncome;
const TransactionTagsInput = (props: Props) => {
const { objects } = useTransactionTagsList({ isIncome: props.isIncome });
return (
<TagsInput
data={objects.map(object => object.name)}
{...props}
label={"Теги"}
placeholder={"Выберите теги"}
/>
);
};
export default TransactionTagsInput;

View File

@@ -1,33 +1,36 @@
import { CRUDTableProps } from "../../../../../types/CRUDTable.tsx";
import { BaseExpenseTagSchema, ExpenseTagSchema } from "../../../../../client";
import { BaseTransactionTagSchema, TransactionTagSchema } from "../../../../../client";
import { FC, useState } from "react";
import { ActionIcon, Flex, Stack, Tooltip } from "@mantine/core";
import { IconCheck, IconEdit, IconTrash } from "@tabler/icons-react";
import { MRT_TableOptions } from "mantine-react-table";
import { BaseTable } from "../../../../../components/BaseTable/BaseTable.tsx";
import { useExpenseTagsTableColumns } from "../hooks/useExpenseTagsTableColumns.tsx";
import CreateExpenseTagForm from "./CreateExpenseTagForm.tsx";
import { useTransactionTagsTableColumns } from "../hooks/useTransactionTagsTableColumns.tsx";
import CreateTransactionTagForm from "./CreateTransactionTagForm.tsx";
type isIncome = {
isIncome: boolean;
}
type Props = CRUDTableProps<TransactionTagSchema, BaseTransactionTagSchema> & isIncome;
type Props = CRUDTableProps<ExpenseTagSchema, BaseExpenseTagSchema>;
const ExpenseTagsTable: FC<Props> = ({ items, onCreate, onDelete, onChange }) => {
const TransactionTagsTable: FC<Props> = ({ items, onCreate, onDelete, onChange, isIncome }) => {
const [editingTagId, setEditingTagId] = useState<number>(-1);
const [tagName, setTagName] = useState<string>("");
const columns = useExpenseTagsTableColumns({ editingTagId, setTagName });
const columns = useTransactionTagsTableColumns({ editingTagId, setTagName });
const onStartEditing = (tag: ExpenseTagSchema) => {
const onStartEditing = (tag: TransactionTagSchema) => {
setEditingTagId(tag.id);
setTagName(tag.name);
};
const onFinishEditing = (tag: ExpenseTagSchema) => {
const onFinishEditing = (tag: TransactionTagSchema) => {
if (!onChange) return;
if (tag.name !== tagName) {
onChange({
id: editingTagId,
name: tagName,
isIncome: isIncome,
});
}
@@ -37,7 +40,10 @@ const ExpenseTagsTable: FC<Props> = ({ items, onCreate, onDelete, onChange }) =>
return (
<Stack>
<CreateExpenseTagForm onCreate={item => onCreate && onCreate(item)} />
<CreateTransactionTagForm
onCreate={item => onCreate && onCreate(item)}
isIncome={isIncome}
/>
<BaseTable
data={items}
columns={columns}
@@ -74,11 +80,11 @@ const ExpenseTagsTable: FC<Props> = ({ items, onCreate, onDelete, onChange }) =>
</Tooltip>
</Flex>
),
} as MRT_TableOptions<ExpenseTagSchema>
} as MRT_TableOptions<TransactionTagSchema>
}
/>
</Stack>
);
};
export default ExpenseTagsTable;
export default TransactionTagsTable;

View File

@@ -0,0 +1,28 @@
import { SegmentedControl, SegmentedControlProps } from "@mantine/core";
import { FC } from "react";
export enum TransactionType {
EXPENSE,
INCOME,
}
type Props = Omit<SegmentedControlProps, "data">;
const data = [
{
label: "Расходы",
value: TransactionType.EXPENSE.toString(),
},
{
label: "Доходы",
value: TransactionType.INCOME.toString(),
},
];
export const TransactionsSegmentedControl: FC<Props> = props => {
return (
<SegmentedControl
data={data}
{...props}
/>
);
};

View File

@@ -1,6 +1,6 @@
import { useMemo } from "react";
import { MRT_ColumnDef } from "mantine-react-table";
import { ExpenseTagSchema } from "../../../../../client";
import { TransactionTagSchema } from "../../../../../client";
import { TextInput } from "@mantine/core";
@@ -9,10 +9,10 @@ type Props = {
setTagName: (tagName: string) => void;
}
export const useExpenseTagsTableColumns = ({
export const useTransactionTagsTableColumns = ({
editingTagId, setTagName,
}: Props) => {
return useMemo<MRT_ColumnDef<ExpenseTagSchema>[]>(
return useMemo<MRT_ColumnDef<TransactionTagSchema>[]>(
() => [
{
accessorKey: "name",

View File

@@ -1,11 +1,11 @@
import { useMemo } from "react";
import { MRT_ColumnDef } from "mantine-react-table";
import { ExpenseSchemaBase } from "../../../../../client";
import { TransactionSchemaBase } from "../../../../../client";
import { formatDate } from "../../../../../types/utils.ts";
export const useExpensesTableColumns = () => {
return useMemo<MRT_ColumnDef<ExpenseSchemaBase>[]>(
export const useTransactionsTableColumns = () => {
return useMemo<MRT_ColumnDef<TransactionSchemaBase>[]>(
() => [
{
accessorKey: "spentDate",

View File

@@ -3,22 +3,25 @@ import { useForm } from "@mantine/form";
import { Flex, NumberInput, rem, TextInput } from "@mantine/core";
import BaseFormModal, { CreateEditFormProps } from "../../../../ClientsPage/modals/BaseFormModal/BaseFormModal.tsx";
import { DatePickerInput } from "@mantine/dates";
import ExpenseTagsInput from "../components/ExpenseTagsInput.tsx";
import { Expense } from "../types/Expense.tsx";
import TransactionTagsInput from "../components/TransactionTagsInput.tsx";
import { Transaction } from "../types/Transaction.tsx";
type Props = CreateEditFormProps<Expense>;
type IsIncome = {
isIncome: boolean;
}
type Props = CreateEditFormProps<Transaction> & IsIncome;
const ExpenseFormModal = ({
context,
id,
innerProps,
}: ContextModalProps<Props>) => {
const TransactionFormModal = ({
context,
id,
innerProps,
}: ContextModalProps<Props>) => {
const isEditing = "element" in innerProps;
const initialValue: Partial<Expense> = isEditing
const initialValue: Partial<Transaction> = isEditing
? innerProps.element
: {};
const form = useForm<Partial<Expense>>({
const form = useForm<Partial<Transaction>>({
initialValues: initialValue,
validate: {
name: name => !name && "Необходимо указать наименование",
@@ -59,8 +62,9 @@ const ExpenseFormModal = ({
placeholder={"Укажите дату расхода"}
valueFormat={"DD.MM.YYYY"}
/>
<ExpenseTagsInput
<TransactionTagsInput
{...form.getInputProps("tags")}
isIncome={innerProps.isIncome}
/>
</Flex>
</BaseFormModal.Body>
@@ -68,4 +72,4 @@ const ExpenseFormModal = ({
);
};
export default ExpenseFormModal;
export default TransactionFormModal;

View File

@@ -1,23 +1,24 @@
import { ContextModalProps } from "@mantine/modals";
import { BaseExpenseTagSchema, ExpenseService, ExpenseTagSchema } from "../../../../../client";
import useExpenseTagsList from "../../../hooks/useExpenseTagsList.tsx";
import ExpenseTagsTable from "../components/ExpenseTagsTable.tsx";
import { BaseTransactionTagSchema, TransactionService, TransactionTagSchema } from "../../../../../client";
import useTransactionTagsList from "../../../hooks/useTransactionTagsList.tsx";
import TransactionTagsTable from "../components/TransactionTagsTable.tsx";
import { useCRUD } from "../../../../../hooks/useCRUD.tsx";
import { notifications } from "../../../../../shared/lib/notifications.ts";
type Props = {
onChange: () => Promise<void>;
isIncome: boolean;
};
const ExpenseTagsModal = ({
const TransactionTagsModal = ({
innerProps,
}: ContextModalProps<Props>) => {
const { onChange: onTagChange } = innerProps;
const { objects: expenseTags, refetch } = useExpenseTagsList();
const { objects: expenseTags, refetch } = useTransactionTagsList({ isIncome: innerProps.isIncome });
const crud = useCRUD<ExpenseTagSchema, BaseExpenseTagSchema>({
const crud = useCRUD<TransactionTagSchema, BaseTransactionTagSchema>({
onChange: tag => {
ExpenseService.updateExpenseTag({
TransactionService.updateTransactionTag({
requestBody: {
tag,
},
@@ -31,9 +32,12 @@ const ExpenseTagsModal = ({
.catch(err => console.log(err));
},
onCreate: tag => {
ExpenseService.createExpenseTag({
TransactionService.createTransactionTag({
requestBody: {
tag,
tag: {
...tag,
isIncome: innerProps.isIncome,
}
},
})
.then(async ({ ok, message }) => {
@@ -45,7 +49,7 @@ const ExpenseTagsModal = ({
.catch(err => console.log(err));
},
onDelete: (tag) => {
ExpenseService.deleteExpenseTag({
TransactionService.deleteTransactionTag({
tagId: tag.id,
})
.then(async ({ ok, message }) => {
@@ -58,8 +62,12 @@ const ExpenseTagsModal = ({
});
return (
<ExpenseTagsTable {...crud} items={expenseTags} />
<TransactionTagsTable
{...crud}
items={expenseTags}
isIncome={innerProps.isIncome}
/>
);
};
export default ExpenseTagsModal;
export default TransactionTagsModal;

View File

@@ -1,11 +1,12 @@
import type { UserSchema } from "../../../../../client";
export type Expense = {
export type Transaction = {
id: number;
name: string;
comment: string;
amount: number;
createdByUser: UserSchema;
spentDate: string;
isIncome: boolean;
tags: Array<string>;
};

View File

@@ -1,23 +0,0 @@
import { FC } from "react";
import useExpenseTagsList from "../../../AdminPage/hooks/useExpenseTagsList.tsx";
import { ExpenseTagSchema } from "../../../../client";
import ObjectSelect, { ObjectSelectProps } from "../../../../components/ObjectSelect/ObjectSelect.tsx";
type Props = Omit<
ObjectSelectProps<ExpenseTagSchema | null>,
"data" | "getValueFn" | "getLabelFn"
>;
const ExpenseTagSelect: FC<Props> = props => {
const { objects: tags } = useExpenseTagsList();
return (
<ObjectSelect
data={tags}
getLabelFn={(tag: ExpenseTagSchema) => tag.name}
getValueFn={(tag: ExpenseTagSchema) => tag.id.toString()}
clearable
{...props}
onClear={() => props.onChange(null)}
/>
);
};
export default ExpenseTagSelect;

View File

@@ -0,0 +1,28 @@
import { FC } from "react";
import { TransactionTagSchema } from "../../../../client";
import ObjectSelect, { ObjectSelectProps } from "../../../../components/ObjectSelect/ObjectSelect.tsx";
import useAllTransactionTagsList from "../../../AdminPage/hooks/useAllTransactionTagsList.tsx";
type IsIncome = {
isIncome: boolean;
}
type Props = Omit<
ObjectSelectProps<TransactionTagSchema | null>,
"data" | "getValueFn" | "getLabelFn"
> & IsIncome;
const TransactionTagSelect: FC<Props> = props => {
let { objects: tags } = useAllTransactionTagsList();
tags = tags.filter(tag => tag.isIncome === props.isIncome);
return (
<ObjectSelect
data={tags}
getLabelFn={(tag: TransactionTagSchema) => tag.name}
getValueFn={(tag: TransactionTagSchema) => tag.id.toString()}
clearable
{...props}
onClear={() => props.onChange(null)}
/>
);
};
export default TransactionTagSelect;

View File

@@ -1,7 +1,7 @@
import { DatePickerInput, DatePickerInputProps } from "@mantine/dates";
import { Divider, Stack, Text } from "@mantine/core";
import ClientSelectNew from "../../../../../../components/Selects/ClientSelectNew/ClientSelectNew.tsx";
import { BaseMarketplaceSchema, ClientSchema, ExpenseTagSchema, UserSchema } from "../../../../../../client";
import { BaseMarketplaceSchema, ClientSchema, TransactionTagSchema, UserSchema } from "../../../../../../client";
import { ObjectSelectProps } from "../../../../../../components/ObjectSelect/ObjectSelect.tsx";
import BaseMarketplaceSelect
from "../../../../../../components/Selects/BaseMarketplaceSelect/BaseMarketplaceSelect.tsx";
@@ -9,35 +9,34 @@ import DealStatusSelect from "../../../../../DealsPage/components/DealStatusSele
import { DealStatusType } from "../../../../../../shared/enums/DealStatus.ts";
import { ProfitTableSegmentedControl } from "../ProfitTableSegmentedControl/ProfitTableSegmentedControl.tsx";
import ManagerSelect from "../../../../../../components/ManagerSelect/ManagerSelect.tsx";
import ExpenseTagSelect from "../../../../components/ExpenseTagSelect/ExpenseTagSelect.tsx";
import TransactionTagSelect from "../../../../components/ExpenseTagSelect/TransactionTagSelect.tsx";
type SelectProps<T> = Omit<
ObjectSelectProps<T>,
"data" | "getValueFn" | "getLabelFn"
>;
type FiltersProps = {
datePickerProps?: DatePickerInputProps<"range">;
clientSelectProps?: Omit<ObjectSelectProps<ClientSchema>, "data">;
onClientClear?: () => void;
baseMarketplaceSelectProps?: Omit<
ObjectSelectProps<BaseMarketplaceSchema>,
"data" | "getValueFn" | "getLabelFn"
>;
baseMarketplaceSelectProps?: SelectProps<BaseMarketplaceSchema>;
onBaseMarketplaceClear?: () => void;
dealStatusSelectProps?: Omit<ObjectSelectProps<DealStatusType>, "data">;
onDealStatusClear?: () => void;
managerSelectProps?: Omit<
ObjectSelectProps<UserSchema | null>,
"data" | "getValueFn" | "getLabelFn"
>;
managerSelectProps?: SelectProps<UserSchema | null | undefined>;
onManagerClear?: () => void;
tagSelectProps?: Omit<
ObjectSelectProps<ExpenseTagSchema | null>,
"data" | "getValueFn" | "getLabelFn"
>;
onTagClear?: () => void;
expenseTagSelectProps?: SelectProps<TransactionTagSchema | null>;
onExpenseTagClear?: () => void;
incomeTagSelectProps?: SelectProps<TransactionTagSchema | null>;
onIncomeTagClear?: () => void;
groupTableByProps?: {
value: string,
@@ -46,20 +45,24 @@ type FiltersProps = {
}
export const Filters = (props: FiltersProps) => {
const {
datePickerProps,
clientSelectProps,
onClientClear,
baseMarketplaceSelectProps,
onBaseMarketplaceClear,
dealStatusSelectProps,
onDealStatusClear,
managerSelectProps,
onManagerClear,
tagSelectProps,
onTagClear,
groupTableByProps,
} = props;
const getTransactionTagsSelect = (isIncome: boolean) => {
const selectProps = isIncome ? props.incomeTagSelectProps : props.expenseTagSelectProps;
if (!selectProps) return;
const onClear = isIncome ? props.onIncomeTagClear : props.onExpenseTagClear;
const label = "Фильтры для " + (isIncome ? "доходов:" : "расходов:");
return (
<>
<Divider />
<Text>{label}</Text>
<TransactionTagSelect
{...selectProps}
onClear={onClear}
placeholder={"Выберите тег"}
isIncome={isIncome}
/>
</>
)
}
return (
<Stack mb={"lg"}>
@@ -67,64 +70,55 @@ export const Filters = (props: FiltersProps) => {
<Text>
Фильтры для выручки и прибыли:
</Text>
{datePickerProps &&
{props.datePickerProps &&
<DatePickerInput
{...datePickerProps}
{...props.datePickerProps}
type="range"
placeholder="Выберите даты"
maxDate={new Date()}
valueFormat={"DD.MM.YYYY"}
/>
}
{dealStatusSelectProps &&
{props.dealStatusSelectProps &&
<DealStatusSelect
{...dealStatusSelectProps}
onClear={onDealStatusClear}
{...props.dealStatusSelectProps}
onClear={props.onDealStatusClear}
clearable
placeholder={"Выберите статус"}
/>
}
{clientSelectProps &&
{props.clientSelectProps &&
<ClientSelectNew
{...clientSelectProps}
onClear={onClientClear}
{...props.clientSelectProps}
onClear={props.onClientClear}
clearable
searchable
placeholder={"Выберите клиента"}
/>
}
{baseMarketplaceSelectProps &&
{props.baseMarketplaceSelectProps &&
<BaseMarketplaceSelect
{...baseMarketplaceSelectProps}
onClear={onBaseMarketplaceClear}
{...props.baseMarketplaceSelectProps}
onClear={props.onBaseMarketplaceClear}
clearable
placeholder={"Выберите маркетплейс"}
/>
}
{managerSelectProps &&
{props.managerSelectProps &&
<ManagerSelect
{...managerSelectProps}
onClear={onManagerClear}
{...props.managerSelectProps}
onClear={props.onManagerClear}
placeholder={"Выберите менеджера"}
/>
}
{tagSelectProps &&
<>
<Divider />
<Text>Фильтры для расходов:</Text>
<ExpenseTagSelect
{...tagSelectProps}
onClear={onTagClear}
placeholder={"Выберите тег"}
/>
</>
}
{groupTableByProps &&
{getTransactionTagsSelect(false)}
{getTransactionTagsSelect(true)}
{props.groupTableByProps &&
<>
<Divider />
<Text>Группировка таблицы:</Text>
<ProfitTableSegmentedControl
{...groupTableByProps}
{...props.groupTableByProps}
orientation={"vertical"}
size={"md"}
w={"100%"}

View File

@@ -29,7 +29,8 @@ const useProfitTabContextState = () => {
marketplace: null,
dealStatus: defaultDealStatus,
manager: null,
tag: null,
expenseTag: null,
incomeTag: null,
},
});
const [isChartLoading, setIsChartLoading] = useState(false);
@@ -49,7 +50,8 @@ const useProfitTabContextState = () => {
baseMarketplaceKey: form.values.marketplace?.key ?? "all",
dealStatusId: form.values.dealStatus?.id ?? -1,
managerId: form.values.manager?.id ?? -1,
tagId: form.values.tag?.id ?? -1,
expenseTagId: form.values.expenseTag?.id ?? -1,
incomeTagId: form.values.incomeTag?.id ?? -1,
};
};

View File

@@ -44,8 +44,10 @@ export const ProfitFiltersModal = ({ form }: Props) => {
onDealStatusClear={() => form.setFieldValue("dealStatus", null)}
managerSelectProps={form.getInputProps("manager")}
onManagerClear={() => form.setFieldValue("manager", null)}
tagSelectProps={form.getInputProps("tag")}
onTagClear={() => form.setFieldValue("tag", null)}
expenseTagSelectProps={form.getInputProps("expenseTag")}
onExpenseTagClear={() => form.setFieldValue("expenseTag", null)}
incomeTagSelectProps={form.getInputProps("incomeTag")}
onIncomeTagClear={() => form.setFieldValue("incomeTag", null)}
/>
</Modal>
</>

View File

@@ -1,7 +1,7 @@
import {
GroupStatisticsTable,
} from "../tabs/ProfitTab/components/ProfitTableSegmentedControl/ProfitTableSegmentedControl.tsx";
import { BaseMarketplaceSchema, ClientSchema, ExpenseTagSchema, UserSchema } from "../../../client";
import { BaseMarketplaceSchema, ClientSchema, TransactionTagSchema, UserSchema } from "../../../client";
import { DealStatusType } from "../../../shared/enums/DealStatus.ts";
export interface FormFilters {
@@ -11,5 +11,6 @@ export interface FormFilters {
marketplace: BaseMarketplaceSchema | null;
dealStatus: DealStatusType | null;
manager: UserSchema | null;
tag: ExpenseTagSchema | null;
expenseTag: TransactionTagSchema | null;
incomeTag: TransactionTagSchema | null;
}