mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-20 15:05:12 +00:00
Pricing role (#13034)
* add 'pricing' role * Create new 'pricing' app - migrate existing pricing models * bug fixes * Move API endpoints to /api/pricing/ * Adjust target branch for playwright tests * Fix permission checks for nested OptionalField entries * Migrate existing background tasks * Point to master branch demo data --------- Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
1 parent
a91f079530
commit
4c948cda1b
43 files changed
+3175
-1388
No files matched your search
@@ -116,12 +116,12 @@ export enum ApiEndpoints {
|
||||
// Part API endpoints
|
||||
part_list = 'part/',
|
||||
part_thumbs_list = 'part/thumbs/',
|
||||
part_pricing = 'part/:id/pricing/',
|
||||
part_pricing = 'pricing/part/:id/',
|
||||
part_requirements = 'part/:id/requirements/',
|
||||
part_serial_numbers = 'part/:id/serial-numbers/',
|
||||
part_scheduling = 'part/:id/scheduling/',
|
||||
part_pricing_internal = 'part/internal-price/',
|
||||
part_pricing_sale = 'part/sale-price/',
|
||||
part_pricing_internal = 'pricing/internal-price/',
|
||||
part_pricing_sale = 'pricing/sale-price/',
|
||||
part_stocktake_list = 'part/stocktake/',
|
||||
part_stocktake_generate = 'part/stocktake/generate/',
|
||||
category_list = 'part/category/',
|
||||
|
||||
@@ -9,6 +9,7 @@ export enum UserRoles {
|
||||
build = 'build',
|
||||
part = 'part',
|
||||
part_category = 'part_category',
|
||||
pricing = 'pricing',
|
||||
purchase_order = 'purchase_order',
|
||||
return_order = 'return_order',
|
||||
transfer_order = 'transfer_order',
|
||||
@@ -37,6 +38,8 @@ export function userRoleLabel(role: UserRoles): string {
|
||||
return t`Parts`;
|
||||
case UserRoles.part_category:
|
||||
return t`Part Categories`;
|
||||
case UserRoles.pricing:
|
||||
return t`Pricing`;
|
||||
case UserRoles.purchase_order:
|
||||
return t`Purchase Orders`;
|
||||
case UserRoles.return_order:
|
||||
|
||||
@@ -372,6 +372,7 @@ export default function PartDetail() {
|
||||
name: 'pricing',
|
||||
label: t`Part Pricing`,
|
||||
icon: <IconCurrencyDollar />,
|
||||
hidden: !user.hasViewRole(UserRoles.pricing),
|
||||
content: part ? <PartPricingPanel part={part} /> : <Skeleton />
|
||||
},
|
||||
{
|
||||
|
||||
@@ -112,7 +112,7 @@ export default function PriceBreakPanel({
|
||||
onClick={() => {
|
||||
newPriceBreak.open();
|
||||
}}
|
||||
hidden={!user.hasAddRole(UserRoles.part)}
|
||||
hidden={!user.hasAddRole(UserRoles.pricing)}
|
||||
/>
|
||||
];
|
||||
}, [user]);
|
||||
@@ -121,14 +121,14 @@ export default function PriceBreakPanel({
|
||||
(record: any): RowAction[] => {
|
||||
return [
|
||||
RowEditAction({
|
||||
hidden: !user.hasChangeRole(UserRoles.part),
|
||||
hidden: !user.hasChangeRole(UserRoles.pricing),
|
||||
onClick: () => {
|
||||
setSelectedPriceBreak(record.pk);
|
||||
editPriceBreak.open();
|
||||
}
|
||||
}),
|
||||
RowDeleteAction({
|
||||
hidden: !user.hasDeleteRole(UserRoles.part),
|
||||
hidden: !user.hasDeleteRole(UserRoles.pricing),
|
||||
onClick: () => {
|
||||
setSelectedPriceBreak(record.pk);
|
||||
deletePriceBreak.open();
|
||||
|
||||
@@ -25,6 +25,7 @@ import { DataTable } from 'mantine-datatable';
|
||||
import { type ReactNode, useCallback, useMemo } from 'react';
|
||||
|
||||
import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
|
||||
import { UserRoles } from '@lib/enums/Roles';
|
||||
import { apiUrl } from '@lib/functions/Api';
|
||||
import type { ApiFormFieldSet } from '@lib/types/Forms';
|
||||
import { api } from '../../../App';
|
||||
@@ -37,6 +38,7 @@ import { formatCurrency, formatDate } from '../../../defaults/formatters';
|
||||
import { InvenTreeIcon } from '../../../functions/icons';
|
||||
import { useEditApiFormModal } from '../../../hooks/UseForm';
|
||||
import { useGlobalSettingsState } from '../../../states/SettingsStates';
|
||||
import { useUserState } from '../../../states/UserState';
|
||||
import { panelOptions } from '../PartPricingPanel';
|
||||
|
||||
interface PricingOverviewEntry {
|
||||
@@ -65,6 +67,7 @@ export default function PricingOverviewPanel({
|
||||
doNavigation: (panel: panelOptions) => void;
|
||||
}>): ReactNode {
|
||||
const globalSettings = useGlobalSettingsState();
|
||||
const user = useUserState();
|
||||
|
||||
const refreshPricing = useCallback(() => {
|
||||
const url = apiUrl(ApiEndpoints.part_pricing, part.pk);
|
||||
@@ -305,6 +308,7 @@ export default function PricingOverviewPanel({
|
||||
{
|
||||
name: t`Refresh`,
|
||||
tooltip: t`Refresh pricing data`,
|
||||
hidden: !user.hasChangeRole(UserRoles.pricing),
|
||||
icon: (
|
||||
<InvenTreeIcon
|
||||
icon='refresh'
|
||||
@@ -316,6 +320,7 @@ export default function PricingOverviewPanel({
|
||||
}
|
||||
},
|
||||
EditItemAction({
|
||||
hidden: !user.hasChangeRole(UserRoles.pricing),
|
||||
onClick: () => {
|
||||
editPricing.open();
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user