From 7a1e589af30da1d8c9d600150b07ebcc729b082c Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 2 Jan 2018 15:34:11 +0200 Subject: [PATCH] Validate lien items more strictly --- .../BookingBreakdown.example.js | 22 + .../BookingBreakdown/BookingBreakdown.test.js | 8 + .../TransactionPanel.test.js.snap | 420 ++++++++++++++++++ .../BookingDatesForm/BookingDatesForm.js | 1 + .../BookingDatesForm/BookingDatesForm.test.js | 1 + .../__snapshots__/InboxPage.test.js.snap | 28 ++ .../TransactionPage.test.js.snap | 14 + src/util/propTypes.js | 12 +- src/util/test-data.js | 2 + 9 files changed, 507 insertions(+), 1 deletion(-) diff --git a/src/components/BookingBreakdown/BookingBreakdown.example.js b/src/components/BookingBreakdown/BookingBreakdown.example.js index 83e020bd..acf020e3 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.example.js +++ b/src/components/BookingBreakdown/BookingBreakdown.example.js @@ -49,6 +49,7 @@ export const Checkout = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(9000, CURRENCY), @@ -73,6 +74,7 @@ export const CustomerOrder = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(9000, CURRENCY), @@ -97,6 +99,7 @@ export const ProviderSale = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(9000, CURRENCY), @@ -104,6 +107,7 @@ export const ProviderSale = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -127,6 +131,7 @@ export const ProviderSaleZeroCommission = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(9000, CURRENCY), @@ -134,6 +139,7 @@ export const ProviderSaleZeroCommission = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(0, CURRENCY), lineTotal: new Money(0, CURRENCY), reversal: false, @@ -157,6 +163,7 @@ export const ProviderSaleSingleNight = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(1), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(4500, CURRENCY), @@ -164,6 +171,7 @@ export const ProviderSaleSingleNight = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -188,6 +196,7 @@ export const ProviderSalePreauthorized = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(1), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(4500, CURRENCY), @@ -195,6 +204,7 @@ export const ProviderSalePreauthorized = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -219,6 +229,7 @@ export const ProviderSaleAccepted = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(1), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(4500, CURRENCY), @@ -226,6 +237,7 @@ export const ProviderSaleAccepted = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -250,6 +262,7 @@ export const ProviderSaleDeclined = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(1), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(4500, CURRENCY), @@ -257,6 +270,7 @@ export const ProviderSaleDeclined = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -281,6 +295,7 @@ export const ProviderSaleAutoDeclined = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(1), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(4500, CURRENCY), @@ -288,6 +303,7 @@ export const ProviderSaleAutoDeclined = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -312,6 +328,7 @@ export const ProviderSaleDelivered = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(1), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(4500, CURRENCY), @@ -319,6 +336,7 @@ export const ProviderSaleDelivered = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -343,6 +361,7 @@ export const ProviderSaleCanceled = { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(1), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(4500, CURRENCY), @@ -350,6 +369,7 @@ export const ProviderSaleCanceled = { }, { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(-1), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(-4500, CURRENCY), @@ -357,6 +377,7 @@ export const ProviderSaleCanceled = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], quantity: new Decimal(1), unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), @@ -364,6 +385,7 @@ export const ProviderSaleCanceled = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], quantity: new Decimal(-1), unitPrice: new Money(2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), diff --git a/src/components/BookingBreakdown/BookingBreakdown.test.js b/src/components/BookingBreakdown/BookingBreakdown.test.js index b4addd56..d0bd41ed 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.test.js +++ b/src/components/BookingBreakdown/BookingBreakdown.test.js @@ -42,6 +42,7 @@ describe('BookingBreakdown', () => { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), lineTotal: new Money(2000, 'USD'), unitPrice: new Money(1000, 'USD'), @@ -69,6 +70,7 @@ describe('BookingBreakdown', () => { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), lineTotal: new Money(2000, 'USD'), unitPrice: new Money(1000, 'USD'), @@ -96,6 +98,7 @@ describe('BookingBreakdown', () => { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), lineTotal: new Money(2000, 'USD'), unitPrice: new Money(1000, 'USD'), @@ -103,6 +106,7 @@ describe('BookingBreakdown', () => { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], lineTotal: new Money(-200, 'USD'), unitPrice: new Money(-200, 'USD'), reversal: false, @@ -129,6 +133,7 @@ describe('BookingBreakdown', () => { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), lineTotal: new Money(2000, 'USD'), unitPrice: new Money(1000, 'USD'), @@ -136,6 +141,7 @@ describe('BookingBreakdown', () => { }, { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(-2), lineTotal: new Money(-2000, 'USD'), unitPrice: new Money(1000, 'USD'), @@ -143,6 +149,7 @@ describe('BookingBreakdown', () => { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], quantity: new Decimal(1), lineTotal: new Money(-200, 'USD'), unitPrice: new Money(-200, 'USD'), @@ -150,6 +157,7 @@ describe('BookingBreakdown', () => { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], quantity: new Decimal(-1), lineTotal: new Money(200, 'USD'), unitPrice: new Money(-200, 'USD'), diff --git a/src/components/TransactionPanel/__snapshots__/TransactionPanel.test.js.snap b/src/components/TransactionPanel/__snapshots__/TransactionPanel.test.js.snap index 19db7a76..e13d8e42 100644 --- a/src/components/TransactionPanel/__snapshots__/TransactionPanel.test.js.snap +++ b/src/components/TransactionPanel/__snapshots__/TransactionPanel.test.js.snap @@ -88,6 +88,10 @@ exports[`TransactionPanel - Order accepted matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -101,6 +105,9 @@ exports[`TransactionPanel - Order accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -213,6 +220,10 @@ exports[`TransactionPanel - Order accepted matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -226,6 +237,9 @@ exports[`TransactionPanel - Order accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -335,6 +349,10 @@ exports[`TransactionPanel - Order accepted matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -348,6 +366,9 @@ exports[`TransactionPanel - Order accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -457,6 +478,10 @@ exports[`TransactionPanel - Order accepted matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -470,6 +495,9 @@ exports[`TransactionPanel - Order accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -697,6 +725,10 @@ exports[`TransactionPanel - Order accepted matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -710,6 +742,9 @@ exports[`TransactionPanel - Order accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -913,6 +948,10 @@ exports[`TransactionPanel - Order autodeclined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -926,6 +965,9 @@ exports[`TransactionPanel - Order autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -1038,6 +1080,10 @@ exports[`TransactionPanel - Order autodeclined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -1051,6 +1097,9 @@ exports[`TransactionPanel - Order autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -1160,6 +1209,10 @@ exports[`TransactionPanel - Order autodeclined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -1173,6 +1226,9 @@ exports[`TransactionPanel - Order autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -1282,6 +1338,10 @@ exports[`TransactionPanel - Order autodeclined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -1295,6 +1355,9 @@ exports[`TransactionPanel - Order autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -1522,6 +1585,10 @@ exports[`TransactionPanel - Order autodeclined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -1535,6 +1602,9 @@ exports[`TransactionPanel - Order autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -1738,6 +1808,10 @@ exports[`TransactionPanel - Order canceled matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -1751,6 +1825,9 @@ exports[`TransactionPanel - Order canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -1863,6 +1940,10 @@ exports[`TransactionPanel - Order canceled matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -1876,6 +1957,9 @@ exports[`TransactionPanel - Order canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -1985,6 +2069,10 @@ exports[`TransactionPanel - Order canceled matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -1998,6 +2086,9 @@ exports[`TransactionPanel - Order canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -2107,6 +2198,10 @@ exports[`TransactionPanel - Order canceled matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -2120,6 +2215,9 @@ exports[`TransactionPanel - Order canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -2347,6 +2445,10 @@ exports[`TransactionPanel - Order canceled matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -2360,6 +2462,9 @@ exports[`TransactionPanel - Order canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -2563,6 +2668,10 @@ exports[`TransactionPanel - Order declined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -2576,6 +2685,9 @@ exports[`TransactionPanel - Order declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -2688,6 +2800,10 @@ exports[`TransactionPanel - Order declined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -2701,6 +2817,9 @@ exports[`TransactionPanel - Order declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -2810,6 +2929,10 @@ exports[`TransactionPanel - Order declined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -2823,6 +2946,9 @@ exports[`TransactionPanel - Order declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -2932,6 +3058,10 @@ exports[`TransactionPanel - Order declined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -2945,6 +3075,9 @@ exports[`TransactionPanel - Order declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -3172,6 +3305,10 @@ exports[`TransactionPanel - Order declined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -3185,6 +3322,9 @@ exports[`TransactionPanel - Order declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -3388,6 +3528,10 @@ exports[`TransactionPanel - Order delivered matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -3401,6 +3545,9 @@ exports[`TransactionPanel - Order delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -3513,6 +3660,10 @@ exports[`TransactionPanel - Order delivered matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -3526,6 +3677,9 @@ exports[`TransactionPanel - Order delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -3635,6 +3789,10 @@ exports[`TransactionPanel - Order delivered matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -3648,6 +3806,9 @@ exports[`TransactionPanel - Order delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -3757,6 +3918,10 @@ exports[`TransactionPanel - Order delivered matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -3770,6 +3935,9 @@ exports[`TransactionPanel - Order delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -3997,6 +4165,10 @@ exports[`TransactionPanel - Order delivered matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -4010,6 +4182,9 @@ exports[`TransactionPanel - Order delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -4213,6 +4388,10 @@ exports[`TransactionPanel - Order preauthorized matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -4226,6 +4405,9 @@ exports[`TransactionPanel - Order preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -4338,6 +4520,10 @@ exports[`TransactionPanel - Order preauthorized matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -4351,6 +4537,9 @@ exports[`TransactionPanel - Order preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -4460,6 +4649,10 @@ exports[`TransactionPanel - Order preauthorized matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -4473,6 +4666,9 @@ exports[`TransactionPanel - Order preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -4582,6 +4778,10 @@ exports[`TransactionPanel - Order preauthorized matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -4595,6 +4795,9 @@ exports[`TransactionPanel - Order preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -4822,6 +5025,10 @@ exports[`TransactionPanel - Order preauthorized matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -4835,6 +5042,9 @@ exports[`TransactionPanel - Order preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -5032,6 +5242,10 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -5045,6 +5259,9 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -5144,6 +5361,10 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -5157,6 +5378,9 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -5254,6 +5478,10 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -5267,6 +5495,9 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -5364,6 +5595,10 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -5377,6 +5612,9 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -5592,6 +5830,10 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -5605,6 +5847,9 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -5789,6 +6034,10 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -5802,6 +6051,9 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -5901,6 +6153,10 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -5914,6 +6170,9 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6011,6 +6270,10 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -6024,6 +6287,9 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6121,6 +6387,10 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -6134,6 +6404,9 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6349,6 +6622,10 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -6362,6 +6639,9 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6546,6 +6826,10 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -6559,6 +6843,9 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6658,6 +6945,10 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -6671,6 +6962,9 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6768,6 +7062,10 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -6781,6 +7079,9 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6878,6 +7179,10 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -6891,6 +7196,9 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7106,6 +7414,10 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -7119,6 +7431,9 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7303,6 +7618,10 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -7316,6 +7635,9 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7415,6 +7737,10 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -7428,6 +7754,9 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7525,6 +7854,10 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -7538,6 +7871,9 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7635,6 +7971,10 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -7648,6 +7988,9 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7863,6 +8206,10 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -7876,6 +8223,9 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8060,6 +8410,10 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -8073,6 +8427,9 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8172,6 +8529,10 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -8185,6 +8546,9 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8282,6 +8646,10 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -8295,6 +8663,9 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8392,6 +8763,10 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -8405,6 +8780,9 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8620,6 +8998,10 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -8633,6 +9015,9 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8817,6 +9202,10 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -8830,6 +9219,9 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8929,6 +9321,10 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -8942,6 +9338,9 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -9039,6 +9438,10 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -9052,6 +9455,9 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -9149,6 +9555,10 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -9162,6 +9572,9 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -9377,6 +9790,10 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -9390,6 +9807,9 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", diff --git a/src/containers/BookingDatesForm/BookingDatesForm.js b/src/containers/BookingDatesForm/BookingDatesForm.js index 6800e9db..15d90ea6 100644 --- a/src/containers/BookingDatesForm/BookingDatesForm.js +++ b/src/containers/BookingDatesForm/BookingDatesForm.js @@ -46,6 +46,7 @@ const estimatedNightlyTransaction = (bookingStart, bookingEnd, unitPrice) => { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], unitPrice: unitPrice, quantity: new Decimal(nightCount), lineTotal: totalPrice, diff --git a/src/containers/BookingDatesForm/BookingDatesForm.test.js b/src/containers/BookingDatesForm/BookingDatesForm.test.js index 8d7f1179..539f5b91 100644 --- a/src/containers/BookingDatesForm/BookingDatesForm.test.js +++ b/src/containers/BookingDatesForm/BookingDatesForm.test.js @@ -55,6 +55,7 @@ describe('BookingDatesForm', () => { expect(transaction.attributes.lineItems).toEqual([ { code: 'line-item/night', + includeFor: ['customer', 'provider'], unitPrice: price, quantity: new Decimal(2), lineTotal: new Money(2198, 'USD'), diff --git a/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap b/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap index 7131cc9e..7ab5e382 100644 --- a/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap +++ b/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap @@ -98,6 +98,10 @@ exports[`InboxPage matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 1000, "currency": "USD", @@ -111,6 +115,9 @@ exports[`InboxPage matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -213,6 +220,10 @@ exports[`InboxPage matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 1000, "currency": "USD", @@ -226,6 +237,9 @@ exports[`InboxPage matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -486,6 +500,10 @@ exports[`InboxPage matches snapshot 3`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 1000, "currency": "USD", @@ -499,6 +517,9 @@ exports[`InboxPage matches snapshot 3`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -601,6 +622,10 @@ exports[`InboxPage matches snapshot 3`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 1000, "currency": "USD", @@ -614,6 +639,9 @@ exports[`InboxPage matches snapshot 3`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", diff --git a/src/containers/TransactionPage/__snapshots__/TransactionPage.test.js.snap b/src/containers/TransactionPage/__snapshots__/TransactionPage.test.js.snap index f2ef88fc..108f07e0 100644 --- a/src/containers/TransactionPage/__snapshots__/TransactionPage.test.js.snap +++ b/src/containers/TransactionPage/__snapshots__/TransactionPage.test.js.snap @@ -68,6 +68,10 @@ exports[`TransactionPage - Order matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 1000, "currency": "USD", @@ -81,6 +85,9 @@ exports[`TransactionPage - Order matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -259,6 +266,10 @@ exports[`TransactionPage - Sale matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 1000, "currency": "USD", @@ -272,6 +283,9 @@ exports[`TransactionPage - Sale matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", diff --git a/src/util/propTypes.js b/src/util/propTypes.js index 1d610910..af1a0776 100644 --- a/src/util/propTypes.js +++ b/src/util/propTypes.js @@ -300,6 +300,15 @@ export const review = shape({ subject: user, }); +export const LINE_ITEM_NIGHT = 'line-item/night'; + +// TODO: This is speculative, check again when the API adds the day support +export const LINE_ITEM_DAY = 'line-item/day'; + +export const LINE_ITEM_PROVIDER_COMMISSION = 'line-item/provider-commission'; + +const LINE_ITEMS = [LINE_ITEM_NIGHT, LINE_ITEM_DAY, LINE_ITEM_PROVIDER_COMMISSION]; + // Denormalised transaction object export const transaction = shape({ id: uuid.isRequired, @@ -316,7 +325,8 @@ export const transaction = shape({ lineItems: arrayOf( shape({ - code: string.isRequired, + code: oneOf(LINE_ITEMS).isRequired, + includeFor: arrayOf(oneOf(['customer', 'provider'])).isRequired, quantity: instanceOf(Decimal), unitPrice: money.isRequired, lineTotal: money.isRequired, diff --git a/src/util/test-data.js b/src/util/test-data.js index e5776af4..588b0744 100644 --- a/src/util/test-data.js +++ b/src/util/test-data.js @@ -134,6 +134,7 @@ export const createTransaction = options => { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(nightCount), unitPrice: new Money(total.amount / nightCount, total.currency), lineTotal: total, @@ -141,6 +142,7 @@ export const createTransaction = options => { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(commission.amount * -1, commission.currency), lineTotal: new Money(commission.amount * -1, commission.currency), reversal: false,