Fix currency rendering in order tables (#7066)

* Add "currency" to CompanyBriefSerializer

* Fix nav.js bug - potential illegal chars in panel name

* Update CUI tables

* Update PUI tables

* Bump API version
This commit is contained in:
Oliver 2024-04-19 13:59:07 +10:00 committed by GitHub
parent 76e1174986
commit cd53f21120
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 52 additions and 17 deletions

View File

@ -1,11 +1,14 @@
"""InvenTree API version information.""" """InvenTree API version information."""
# InvenTree API version # InvenTree API version
INVENTREE_API_VERSION = 188 INVENTREE_API_VERSION = 189
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" """Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """ INVENTREE_API_TEXT = """
v189 - 2024-04-19 : https://github.com/inventree/InvenTree/pull/7066
- Adds "currency" field to CompanyBriefSerializer class
v188 - 2024-04-16 : https://github.com/inventree/InvenTree/pull/6970 v188 - 2024-04-16 : https://github.com/inventree/InvenTree/pull/6970
- Adds session authentication support for the API - Adds session authentication support for the API
- Improvements for login / logout endpoints for better support of React web interface - Improvements for login / logout endpoints for better support of React web interface

View File

@ -42,7 +42,9 @@ class CompanyBriefSerializer(InvenTreeModelSerializer):
"""Metaclass options.""" """Metaclass options."""
model = Company model = Company
fields = ['pk', 'url', 'name', 'description', 'image', 'thumbnail'] fields = ['pk', 'url', 'name', 'description', 'image', 'thumbnail', 'currency']
read_only_fields = ['currency']
url = serializers.CharField(source='get_absolute_url', read_only=True) url = serializers.CharField(source='get_absolute_url', read_only=True)

View File

@ -21,12 +21,15 @@ function activatePanel(label, panel_name, options={}) {
$('.panel-visible').hide(); $('.panel-visible').hide();
$('.panel-visible').removeClass('panel-visible'); $('.panel-visible').removeClass('panel-visible');
// Remove illegal chars
panel_name = panel_name.replace('/', '');
// Find the target panel // Find the target panel
var panel = `#panel-${panel_name}`; var panel = `#panel-${panel_name}`;
var select = `#select-${panel_name}`; var select = `#select-${panel_name}`;
// Check that the selected panel (and select) exist // Check that the selected panel (and select) exist
if ($(panel).length && $(select).length) { if ($(panel).exists() && $(panel).length && $(select).length) {
// Yep, both are displayed // Yep, both are displayed
} else { } else {
// Either the select or the panel are not displayed! // Either the select or the panel are not displayed!

View File

@ -1755,7 +1755,7 @@ function loadPurchaseOrderTable(table, options) {
sortable: true, sortable: true,
formatter: function(value, row) { formatter: function(value, row) {
return formatCurrency(value, { return formatCurrency(value, {
currency: row.order_currency, currency: row.order_currency ?? row.supplier_detail?.currency,
}); });
}, },
}, },

View File

@ -300,7 +300,7 @@ function loadReturnOrderTable(table, options={}) {
return '{% trans "Invalid Customer" %}'; return '{% trans "Invalid Customer" %}';
} }
return imageHoverIcon(row.customer_detail.image) + renderLink(row.customer_detail.name, `/company/${row.customer}/sales-orders/`); return imageHoverIcon(row.customer_detail.image) + renderLink(row.customer_detail.name, `/company/${row.customer}/?display=sales-orders/`);
} }
}, },
{ {
@ -384,7 +384,7 @@ function loadReturnOrderTable(table, options={}) {
visible: false, visible: false,
formatter: function(value, row) { formatter: function(value, row) {
return formatCurrency(value, { return formatCurrency(value, {
currency: row.order_currency currency: row.order_currency ?? row.customer_detail?.currency,
}); });
} }
} }

View File

@ -788,7 +788,7 @@ function loadSalesOrderTable(table, options) {
return '{% trans "Invalid Customer" %}'; return '{% trans "Invalid Customer" %}';
} }
return imageHoverIcon(row.customer_detail.image) + renderLink(row.customer_detail.name, `/company/${row.customer}/sales-orders/`); return imageHoverIcon(row.customer_detail.image) + renderLink(row.customer_detail.name, `/company/${row.customer}/?display=sales-orders/`);
} }
}, },
{ {
@ -857,7 +857,7 @@ function loadSalesOrderTable(table, options) {
sortable: true, sortable: true,
formatter: function(value, row) { formatter: function(value, row) {
return formatCurrency(value, { return formatCurrency(value, {
currency: row.order_currency, currency: row.order_currency ?? row.customer_detail?.currency,
}); });
} }
} }

View File

@ -4,6 +4,7 @@ import { useNavigate } from 'react-router-dom';
import { AddItemButton } from '../../components/buttons/AddItemButton'; import { AddItemButton } from '../../components/buttons/AddItemButton';
import { Thumbnail } from '../../components/images/Thumbnail'; import { Thumbnail } from '../../components/images/Thumbnail';
import { formatCurrency } from '../../defaults/formatters';
import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType'; import { ModelType } from '../../enums/ModelType';
import { UserRoles } from '../../enums/Roles'; import { UserRoles } from '../../enums/Roles';
@ -21,8 +22,7 @@ import {
ReferenceColumn, ReferenceColumn,
ResponsibleColumn, ResponsibleColumn,
StatusColumn, StatusColumn,
TargetDateColumn, TargetDateColumn
TotalPriceColumn
} from '../ColumnRenderers'; } from '../ColumnRenderers';
import { import {
AssignedToMeFilter, AssignedToMeFilter,
@ -92,7 +92,16 @@ export function PurchaseOrderTable({
ProjectCodeColumn(), ProjectCodeColumn(),
CreationDateColumn(), CreationDateColumn(),
TargetDateColumn(), TargetDateColumn(),
TotalPriceColumn(), {
accessor: 'total_price',
title: t`Total Price`,
sortable: true,
render: (record: any) => {
return formatCurrency(record.total_price, {
currency: record.order_currency ?? record.supplier_detail?.currency
});
}
},
ResponsibleColumn() ResponsibleColumn()
]; ];
}, []); }, []);

View File

@ -3,6 +3,7 @@ import { useCallback, useMemo } from 'react';
import { AddItemButton } from '../../components/buttons/AddItemButton'; import { AddItemButton } from '../../components/buttons/AddItemButton';
import { Thumbnail } from '../../components/images/Thumbnail'; import { Thumbnail } from '../../components/images/Thumbnail';
import { formatCurrency } from '../../defaults/formatters';
import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType'; import { ModelType } from '../../enums/ModelType';
import { UserRoles } from '../../enums/Roles'; import { UserRoles } from '../../enums/Roles';
@ -18,8 +19,7 @@ import {
ReferenceColumn, ReferenceColumn,
ResponsibleColumn, ResponsibleColumn,
StatusColumn, StatusColumn,
TargetDateColumn, TargetDateColumn
TotalPriceColumn
} from '../ColumnRenderers'; } from '../ColumnRenderers';
import { import {
AssignedToMeFilter, AssignedToMeFilter,
@ -81,7 +81,16 @@ export function ReturnOrderTable({ params }: { params?: any }) {
CreationDateColumn(), CreationDateColumn(),
TargetDateColumn(), TargetDateColumn(),
ResponsibleColumn(), ResponsibleColumn(),
TotalPriceColumn() {
accessor: 'total_price',
title: t`Total Price`,
sortable: true,
render: (record: any) => {
return formatCurrency(record.total_price, {
currency: record.order_currency ?? record.customer_detail?.currency
});
}
}
]; ];
}, []); }, []);

View File

@ -4,6 +4,7 @@ import { useNavigate } from 'react-router-dom';
import { AddItemButton } from '../../components/buttons/AddItemButton'; import { AddItemButton } from '../../components/buttons/AddItemButton';
import { Thumbnail } from '../../components/images/Thumbnail'; import { Thumbnail } from '../../components/images/Thumbnail';
import { formatCurrency } from '../../defaults/formatters';
import { ApiEndpoints } from '../../enums/ApiEndpoints'; import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType'; import { ModelType } from '../../enums/ModelType';
import { UserRoles } from '../../enums/Roles'; import { UserRoles } from '../../enums/Roles';
@ -21,8 +22,7 @@ import {
ReferenceColumn, ReferenceColumn,
ShipmentDateColumn, ShipmentDateColumn,
StatusColumn, StatusColumn,
TargetDateColumn, TargetDateColumn
TotalPriceColumn
} from '../ColumnRenderers'; } from '../ColumnRenderers';
import { import {
AssignedToMeFilter, AssignedToMeFilter,
@ -117,7 +117,16 @@ export function SalesOrderTable({
CreationDateColumn(), CreationDateColumn(),
TargetDateColumn(), TargetDateColumn(),
ShipmentDateColumn(), ShipmentDateColumn(),
TotalPriceColumn() {
accessor: 'total_price',
title: t`Total Price`,
sortable: true,
render: (record: any) => {
return formatCurrency(record.total_price, {
currency: record.order_currency ?? record.customer_detail?.currency
});
}
}
]; ];
}, []); }, []);