Improve error messages when TransactionPanel is rendering line-items.

This commit is contained in:
Vesa Luusua 2018-03-20 13:28:03 +02:00
parent e116c1cd6a
commit 467377027b
4 changed files with 19 additions and 0 deletions

View file

@ -52,6 +52,10 @@ const LineItemBookingPeriod = props => {
item => item.code === unitType && !item.reversal
);
if (!unitPurchase) {
throw new Error(`LineItemBookingPeriod: lineItem (${unitType}) missing`);
}
const useQuantityForDayCount = isNightly || isDaily;
const count = useQuantityForDayCount ? unitPurchase.quantity.toFixed() : dayCount;

View file

@ -43,6 +43,11 @@ const LineItemSubTotalMaybe = props => {
const unitPurchase = transaction.attributes.lineItems.find(
item => item.code === unitType && !item.reversal
);
if (!unitPurchase) {
throw new Error(`LineItemSubTotalMaybe: lineItem (${unitType}) missing`);
}
const formattedSubTotal = formatMoney(intl, unitPurchase.lineTotal);
return showSubTotal ? (

View file

@ -16,6 +16,11 @@ const LineItemUnitPrice = props => {
const unitPurchase = transaction.attributes.lineItems.find(
item => item.code === unitType && !item.reversal
);
if (!unitPurchase) {
throw new Error(`LineItemUnitPrice: lineItem (${unitType}) missing`);
}
const formattedUnitPrice = formatMoney(intl, unitPurchase.unitPrice);
return (

View file

@ -14,6 +14,11 @@ const LineItemUnitsMaybe = props => {
const unitPurchase = transaction.attributes.lineItems.find(
item => item.code === unitType && !item.reversal
);
if (!unitPurchase) {
throw new Error(`LineItemUnitsMaybe: lineItem (${unitType}) missing`);
}
const quantity = unitPurchase.quantity;
return (