extending API to supply price wihtout formatting

This commit is contained in:
Matthias 2021-08-09 01:49:55 +02:00
parent c58ed5a07e
commit ad656b7ca7
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 17 additions and 4 deletions

View File

@ -15,7 +15,8 @@ from djmoney.contrib.django_rest_framework import MoneyField
from InvenTree.serializers import (InvenTreeAttachmentSerializerField,
InvenTreeImageSerializerField,
InvenTreeModelSerializer)
InvenTreeModelSerializer,
InvenTreeMoneySerializer)
from InvenTree.status_codes import BuildStatus, PurchaseOrderStatus
from stock.models import StockItem
@ -102,7 +103,12 @@ class PartSalePriceSerializer(InvenTreeModelSerializer):
quantity = serializers.FloatField()
price = serializers.CharField()
price = InvenTreeMoneySerializer(
max_digits=19, decimal_places=4,
allow_null=True
)
price_string = serializers.CharField(source='price', read_only=True)
class Meta:
model = PartSellPriceBreak
@ -111,6 +117,7 @@ class PartSalePriceSerializer(InvenTreeModelSerializer):
'part',
'quantity',
'price',
'price_string',
]
@ -121,7 +128,12 @@ class PartInternalPriceSerializer(InvenTreeModelSerializer):
quantity = serializers.FloatField()
price = serializers.CharField()
price = InvenTreeMoneySerializer(
max_digits=19, decimal_places=4,
allow_null=True
)
price_string = serializers.CharField(source='price', read_only=True)
class Meta:
model = PartInternalPriceBreak
@ -130,6 +142,7 @@ class PartInternalPriceSerializer(InvenTreeModelSerializer):
'part',
'quantity',
'price',
'price_string',
]

View File

@ -1115,7 +1115,7 @@ function loadPriceBreakTable(table, options) {
// split up for graph definition
var graphLabels = Array.from(tableData, x => x.quantity);
var graphData = Array.from(tableData, x => parseFloat(x.price));
var graphData = Array.from(tableData, x => x.price);
// destroy chart if exists
if (chart){