From 1e4dbef9ee010791e178451632fadf23bfe7f0ba Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 2 Jan 2018 11:36:01 +0200 Subject: [PATCH 1/9] Reorganise breakdown items --- .../BookingBreakdown/BookingBreakdown.js | 74 ++++++++++--------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/src/components/BookingBreakdown/BookingBreakdown.js b/src/components/BookingBreakdown/BookingBreakdown.js index 7c51172e..995c4a86 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.js +++ b/src/components/BookingBreakdown/BookingBreakdown.js @@ -30,6 +30,29 @@ export const BookingBreakdownComponent = props => { const isProvider = userRole === 'provider'; const classes = classNames(rootClassName || css.root, className); + const nightPurchase = transaction.attributes.lineItems.find( + item => item.code === 'line-item/night' && !item.reversal + ); + const providerCommissionLineItem = transaction.attributes.lineItems.find( + item => item.code === 'line-item/provider-commission' && !item.reversal + ); + const refund = transaction.attributes.lineItems.find( + item => item.code === 'line-item/night' && item.reversal + ); + const commissionRefund = transaction.attributes.lineItems.find( + item => item.code === 'line-item/provider-commission' && item.reversal + ); + + const formattedUnitPrice = formatMoney(intl, nightPurchase.unitPrice); + const unitPriceItem = ( +
+ + + + {formattedUnitPrice} +
+ ); + const dateFormatOptions = { weekday: 'short', month: 'short', @@ -53,20 +76,18 @@ export const BookingBreakdownComponent = props => { /> ); - const nightPurchase = transaction.attributes.lineItems.find( - item => item.code === 'line-item/night' && !item.reversal + const nightCount = nightPurchase.quantity.toFixed(); + const nightCountMessage = ( + ); - const providerCommissionLineItem = transaction.attributes.lineItems.find( - item => item.code === 'line-item/provider-commission' && !item.reversal - ); - const refund = transaction.attributes.lineItems.find( - item => item.code === 'line-item/night' && item.reversal - ); - const commissionRefund = transaction.attributes.lineItems.find( - item => item.code === 'line-item/provider-commission' && item.reversal + const unitsItem = ( +
+ {bookingPeriod} + {nightCountMessage} +
); - const refundInfo = refund ? ( + const refundItem = refund ? (
@@ -75,22 +96,15 @@ export const BookingBreakdownComponent = props => {
) : null; - const nightCount = nightPurchase.quantity.toFixed(); - const nightCountMessage = ( - - ); - - const formattedUnitPrice = formatMoney(intl, nightPurchase.unitPrice); - // If commission is passed it will be shown as a fee already reduces from the total price - let commissionInfo = null; + let commissionItem = null; // Show night purchase line total (unit price * quantity) as a subtotal. // PLEASE NOTE that this assumes that the transaction doesn't have other // line item types than nights (e.g. week, month, year). const showSubTotal = isProvider || refund; const formattedSubTotal = formatMoney(intl, nightPurchase.lineTotal); - const subTotalInfo = showSubTotal ? ( + const subTotalItem = showSubTotal ? (
@@ -109,7 +123,7 @@ export const BookingBreakdownComponent = props => { const commission = providerCommissionLineItem.lineTotal; const formattedCommission = commission ? formatMoney(intl, commission) : null; - commissionInfo = commissionRefund ? null : ( + commissionItem = commissionRefund ? null : (
@@ -141,19 +155,11 @@ export const BookingBreakdownComponent = props => { return (
-
- - - - {formattedUnitPrice} -
-
- {bookingPeriod} - {nightCountMessage} -
- {subTotalInfo} - {commissionInfo} - {refundInfo} + {unitPriceItem} + {unitsItem} + {subTotalItem} + {commissionItem} + {refundItem}
{totalLabel}
From b59b46203501a8cddb5d5731b605640d0195e0fc Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 2 Jan 2018 11:48:59 +0200 Subject: [PATCH 2/9] Move items into a separate component --- .../BookingBreakdown/BookingBreakdown.js | 45 ++- .../BookingBreakdown.test.js.snap | 376 +++++++++--------- 2 files changed, 224 insertions(+), 197 deletions(-) diff --git a/src/components/BookingBreakdown/BookingBreakdown.js b/src/components/BookingBreakdown/BookingBreakdown.js index 995c4a86..9b550f7e 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.js +++ b/src/components/BookingBreakdown/BookingBreakdown.js @@ -3,7 +3,7 @@ * I.e. dates and other details related to payment decision in receipt format. */ import React from 'react'; -import PropTypes from 'prop-types'; +import { bool, oneOf, string } from 'prop-types'; import { FormattedMessage, FormattedHTMLMessage, intlShape, injectIntl } from 'react-intl'; import classNames from 'classnames'; import { types } from '../../util/sdkLoader'; @@ -24,11 +24,8 @@ const isValidCommission = commissionLineItem => { ); }; -export const BookingBreakdownComponent = props => { - const { rootClassName, className, userRole, transaction, booking, intl } = props; - - const isProvider = userRole === 'provider'; - const classes = classNames(rootClassName || css.root, className); +const BreakdownItems = props => { + const { transaction, booking, isProvider, intl } = props; const nightPurchase = transaction.attributes.lineItems.find( item => item.code === 'line-item/night' && !item.reversal @@ -132,6 +129,29 @@ export const BookingBreakdownComponent = props => {
); } + return ( +
+ {unitPriceItem} + {unitsItem} + {subTotalItem} + {commissionItem} + {refundItem} +
+ ); +}; + +BreakdownItems.propTypes = { + transaction: propTypes.transaction.isRequired, + booking: propTypes.booking.isRequired, + isProvider: bool.isRequired, + intl: intlShape.isRequired, +}; + +export const BookingBreakdownComponent = props => { + const { rootClassName, className, userRole, transaction, booking, intl } = props; + + const isProvider = userRole === 'provider'; + const classes = classNames(rootClassName || css.root, className); let providerTotalMessageId = 'BookingBreakdown.providerTotalDefault'; if (propTypes.txIsDelivered(transaction)) { @@ -155,11 +175,12 @@ export const BookingBreakdownComponent = props => { return (
- {unitPriceItem} - {unitsItem} - {subTotalItem} - {commissionItem} - {refundItem} +
{totalLabel}
@@ -171,8 +192,6 @@ export const BookingBreakdownComponent = props => { BookingBreakdownComponent.defaultProps = { rootClassName: null, className: null }; -const { oneOf, string } = PropTypes; - BookingBreakdownComponent.propTypes = { rootClassName: string, className: string, diff --git a/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap b/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap index 2af3179a..4ae7d2a9 100644 --- a/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap +++ b/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap @@ -4,43 +4,45 @@ exports[`BookingBreakdown customer transaction data matches snapshot 1`] = `
-
- - - BookingBreakdown.pricePerNight - - - - 10 - -
-
- - - BookingBreakdown.bookingPeriod - - - +
+ + BookingBreakdown.pricePerNight + + + + 10 + +
+
+ + + BookingBreakdown.bookingPeriod + + + + - + /> + +

-
- - - BookingBreakdown.pricePerNight - - - - 10 - -
-
- - - BookingBreakdown.bookingPeriod - - - +
+ + BookingBreakdown.pricePerNight + + + + 10 + +
+
+ + + BookingBreakdown.bookingPeriod + + + + - + /> + +

-
- - - BookingBreakdown.pricePerNight - - - - 10 - -
-
- - - BookingBreakdown.bookingPeriod - - - +
+ + BookingBreakdown.pricePerNight + + + + 10 + +
+
+ + + BookingBreakdown.bookingPeriod + + + + - -
-
- - - BookingBreakdown.subTotal + /> - - +
- 20 - -
-
- - - BookingBreakdown.refund + + + BookingBreakdown.subTotal + - - + 20 + +
+
- -20 - + + + BookingBreakdown.refund + + + + -20 + +

-
- - - BookingBreakdown.pricePerNight - - - - 10 - -
-
- - - BookingBreakdown.bookingPeriod - - - +
+ + BookingBreakdown.pricePerNight + + + + 10 + +
+
+ + + BookingBreakdown.bookingPeriod + + + + - -
-
- - - BookingBreakdown.subTotal + /> - - +
- 20 - -
-
- - - BookingBreakdown.commission + + + BookingBreakdown.subTotal + - - + 20 + +
+
- -2 - + + + BookingBreakdown.commission + + + + -2 + +

Date: Tue, 2 Jan 2018 14:52:13 +0200 Subject: [PATCH 3/9] Extract items as components --- .../BookingBreakdown/BookingBreakdown.js | 129 ++++-- .../BookingBreakdown.test.js.snap | 376 +++++++++--------- 2 files changed, 269 insertions(+), 236 deletions(-) diff --git a/src/components/BookingBreakdown/BookingBreakdown.js b/src/components/BookingBreakdown/BookingBreakdown.js index 9b550f7e..4f67672d 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.js +++ b/src/components/BookingBreakdown/BookingBreakdown.js @@ -24,24 +24,14 @@ const isValidCommission = commissionLineItem => { ); }; -const BreakdownItems = props => { - const { transaction, booking, isProvider, intl } = props; - +const UnitPriceItem = props => { + const { transaction, intl } = props; const nightPurchase = transaction.attributes.lineItems.find( item => item.code === 'line-item/night' && !item.reversal ); - const providerCommissionLineItem = transaction.attributes.lineItems.find( - item => item.code === 'line-item/provider-commission' && !item.reversal - ); - const refund = transaction.attributes.lineItems.find( - item => item.code === 'line-item/night' && item.reversal - ); - const commissionRefund = transaction.attributes.lineItems.find( - item => item.code === 'line-item/provider-commission' && item.reversal - ); - const formattedUnitPrice = formatMoney(intl, nightPurchase.unitPrice); - const unitPriceItem = ( + + return (
@@ -49,6 +39,15 @@ const BreakdownItems = props => { {formattedUnitPrice}
); +}; + +UnitPriceItem.propTypes = { + transaction: propTypes.transaction.isRequired, + intl: intlShape.isRequired, +}; + +const UnitsItem = props => { + const { transaction, booking, intl } = props; const dateFormatOptions = { weekday: 'short', @@ -72,36 +71,45 @@ const BreakdownItems = props => { }} /> ); - + const nightPurchase = transaction.attributes.lineItems.find( + item => item.code === 'line-item/night' && !item.reversal + ); const nightCount = nightPurchase.quantity.toFixed(); const nightCountMessage = ( ); - const unitsItem = ( + + return (
{bookingPeriod} {nightCountMessage}
); +}; - const refundItem = refund ? ( -
- - - - {formatMoney(intl, refund.lineTotal)} -
- ) : null; +UnitsItem.propTypes = { + transaction: propTypes.transaction.isRequired, + booking: propTypes.booking.isRequired, + intl: intlShape.isRequired, +}; - // If commission is passed it will be shown as a fee already reduces from the total price - let commissionItem = null; +const SubTotalItemMaybe = props => { + const { transaction, isProvider, intl } = props; + + const refund = transaction.attributes.lineItems.find( + item => item.code === 'line-item/night' && item.reversal + ); // Show night purchase line total (unit price * quantity) as a subtotal. // PLEASE NOTE that this assumes that the transaction doesn't have other // line item types than nights (e.g. week, month, year). const showSubTotal = isProvider || refund; + const nightPurchase = transaction.attributes.lineItems.find( + item => item.code === 'line-item/night' && !item.reversal + ); const formattedSubTotal = formatMoney(intl, nightPurchase.lineTotal); - const subTotalItem = showSubTotal ? ( + + return showSubTotal ? (
@@ -109,6 +117,26 @@ const BreakdownItems = props => { {formattedSubTotal}
) : null; +}; + +SubTotalItemMaybe.propTypes = { + transaction: propTypes.transaction.isRequired, + isProvider: bool.isRequired, + intl: intlShape.isRequired, +}; + +const CommissionItemMaybe = props => { + const { transaction, isProvider, intl } = props; + + const providerCommissionLineItem = transaction.attributes.lineItems.find( + item => item.code === 'line-item/provider-commission' && !item.reversal + ); + const commissionRefund = transaction.attributes.lineItems.find( + item => item.code === 'line-item/provider-commission' && item.reversal + ); + + // If commission is passed it will be shown as a fee already reduces from the total price + let commissionItem = null; if (isProvider) { if (!isValidCommission(providerCommissionLineItem)) { @@ -129,24 +157,38 @@ const BreakdownItems = props => {
); } - return ( -
- {unitPriceItem} - {unitsItem} - {subTotalItem} - {commissionItem} - {refundItem} -
- ); + + return commissionItem; }; -BreakdownItems.propTypes = { +CommissionItemMaybe.propTypes = { transaction: propTypes.transaction.isRequired, - booking: propTypes.booking.isRequired, isProvider: bool.isRequired, intl: intlShape.isRequired, }; +const RefundItemMaybe = props => { + const { transaction, intl } = props; + + const refund = transaction.attributes.lineItems.find( + item => item.code === 'line-item/night' && item.reversal + ); + + return refund ? ( +
+ + + + {formatMoney(intl, refund.lineTotal)} +
+ ) : null; +}; + +RefundItemMaybe.propTypes = { + transaction: propTypes.transaction.isRequired, + intl: intlShape.isRequired, +}; + export const BookingBreakdownComponent = props => { const { rootClassName, className, userRole, transaction, booking, intl } = props; @@ -175,12 +217,11 @@ export const BookingBreakdownComponent = props => { return (
- + + + + +
{totalLabel}
diff --git a/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap b/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap index 4ae7d2a9..2af3179a 100644 --- a/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap +++ b/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap @@ -4,45 +4,43 @@ exports[`BookingBreakdown customer transaction data matches snapshot 1`] = `
-
-
+ + + BookingBreakdown.pricePerNight + + + + 10 + +
+
+ + + BookingBreakdown.bookingPeriod + + + - - BookingBreakdown.pricePerNight - - - - 10 - -
-
- - - BookingBreakdown.bookingPeriod - - - - - -
+ } + /> +

-
-
+ + + BookingBreakdown.pricePerNight + + + + 10 + +
+
+ + + BookingBreakdown.bookingPeriod + + + - - BookingBreakdown.pricePerNight - - - - 10 - -
-
- - - BookingBreakdown.bookingPeriod - - - - - -
+ } + /> +

-
-
+ + + BookingBreakdown.pricePerNight + + + + 10 + +
+
+ + + BookingBreakdown.bookingPeriod + + + - - BookingBreakdown.pricePerNight - - - - 10 - -
-
- - - BookingBreakdown.bookingPeriod - - - - - -
-
+ +
+
+ - - - BookingBreakdown.subTotal - + + BookingBreakdown.subTotal - - 20 - -
-
+ - - - BookingBreakdown.refund - + 20 + +
+
+ + + BookingBreakdown.refund - - -20 - -
+ + + -20 +

-
-
+ + + BookingBreakdown.pricePerNight + + + + 10 + +
+
+ + + BookingBreakdown.bookingPeriod + + + - - BookingBreakdown.pricePerNight - - - - 10 - -
-
- - - BookingBreakdown.bookingPeriod - - - - - -
-
+ +
+
+ - - - BookingBreakdown.subTotal - + + BookingBreakdown.subTotal - - 20 - -
-
+ - - - BookingBreakdown.commission - + 20 + +
+
+ + + BookingBreakdown.commission - - -2 - -
+ + + -2 +

Date: Tue, 2 Jan 2018 15:34:11 +0200 Subject: [PATCH 4/9] 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, From 666f5966d1790a2dbc892d12a82c43457ec0a159 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 2 Jan 2018 15:45:20 +0200 Subject: [PATCH 5/9] Use units instead of nights in var names and translation keys --- src/components/ListingCard/ListingCard.css | 2 +- src/components/ListingCard/ListingCard.js | 4 ++-- .../__snapshots__/ListingCard.test.js.snap | 2 +- .../ManageListingCard/ManageListingCard.css | 2 +- .../ManageListingCard/ManageListingCard.js | 4 ++-- .../__snapshots__/ManageListingCard.test.js.snap | 2 +- .../EditListingPricingForm/EditListingPricingForm.js | 4 ++-- .../EditListingPricingForm.test.js.snap | 2 +- src/containers/ListingPage/ListingPage.css | 4 ++-- src/containers/ListingPage/ListingPage.js | 8 ++++---- .../__snapshots__/ListingPage.test.js.snap | 4 ++-- src/translations/en.json | 12 ++++++------ 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/components/ListingCard/ListingCard.css b/src/components/ListingCard/ListingCard.css index cac38782..37c5c98d 100644 --- a/src/components/ListingCard/ListingCard.css +++ b/src/components/ListingCard/ListingCard.css @@ -71,7 +71,7 @@ } } -.perNight { +.perUnit { /* Font */ @apply --marketplaceTinyFontStyles; color: var(--matterColor); diff --git a/src/components/ListingCard/ListingCard.js b/src/components/ListingCard/ListingCard.js index ad60507c..5059085c 100644 --- a/src/components/ListingCard/ListingCard.js +++ b/src/components/ListingCard/ListingCard.js @@ -64,8 +64,8 @@ export const ListingCardComponent = props => {
{formattedPrice}
-
- +
+
diff --git a/src/components/ListingCard/__snapshots__/ListingCard.test.js.snap b/src/components/ListingCard/__snapshots__/ListingCard.test.js.snap index f8a975d4..528e4e31 100644 --- a/src/components/ListingCard/__snapshots__/ListingCard.test.js.snap +++ b/src/components/ListingCard/__snapshots__/ListingCard.test.js.snap @@ -44,7 +44,7 @@ exports[`ListingCard matches snapshot 1`] = `
diff --git a/src/components/ManageListingCard/ManageListingCard.css b/src/components/ManageListingCard/ManageListingCard.css index bd995400..bc7d8dfb 100644 --- a/src/components/ManageListingCard/ManageListingCard.css +++ b/src/components/ManageListingCard/ManageListingCard.css @@ -220,7 +220,7 @@ } } -.perNight { +.perUnit { /* Font */ @apply --marketplaceTinyFontStyles; color: var(--matterColor); diff --git a/src/components/ManageListingCard/ManageListingCard.js b/src/components/ManageListingCard/ManageListingCard.js index ce4c1105..b1ebf08d 100644 --- a/src/components/ManageListingCard/ManageListingCard.js +++ b/src/components/ManageListingCard/ManageListingCard.js @@ -219,8 +219,8 @@ export const ManageListingCardComponent = props => {
{formattedPrice}
-
- +
+
diff --git a/src/components/ManageListingCard/__snapshots__/ManageListingCard.test.js.snap b/src/components/ManageListingCard/__snapshots__/ManageListingCard.test.js.snap index 12610695..65ade4b4 100644 --- a/src/components/ManageListingCard/__snapshots__/ManageListingCard.test.js.snap +++ b/src/components/ManageListingCard/__snapshots__/ManageListingCard.test.js.snap @@ -110,7 +110,7 @@ exports[`ManageListingCard matches snapshot 1`] = `
diff --git a/src/containers/EditListingPricingForm/EditListingPricingForm.js b/src/containers/EditListingPricingForm/EditListingPricingForm.js index e61689a0..4c8c6611 100644 --- a/src/containers/EditListingPricingForm/EditListingPricingForm.js +++ b/src/containers/EditListingPricingForm/EditListingPricingForm.js @@ -25,7 +25,7 @@ export const EditListingPricingFormComponent = props => { updateInProgress, } = props; - const pricePerNightMessage = intl.formatMessage({ id: 'EditListingPricingForm.pricePerNight' }); + const pricePerUnitMessage = intl.formatMessage({ id: 'EditListingPricingForm.pricePerUnit' }); const priceRequiredMessage = intl.formatMessage({ id: 'EditListingPricingForm.priceRequired' }); const pricePlaceholderMessage = intl.formatMessage({ id: 'EditListingPricingForm.priceInputPlaceholder', @@ -50,7 +50,7 @@ export const EditListingPricingFormComponent = props => { className={css.priceInput} autoFocus name="price" - label={pricePerNightMessage} + label={pricePerUnitMessage} placeholder={pricePlaceholderMessage} currencyConfig={config.currencyConfig} validate={[required(priceRequiredMessage)]} diff --git a/src/containers/EditListingPricingForm/__snapshots__/EditListingPricingForm.test.js.snap b/src/containers/EditListingPricingForm/__snapshots__/EditListingPricingForm.test.js.snap index 0c56bfbf..e03bbbfb 100644 --- a/src/containers/EditListingPricingForm/__snapshots__/EditListingPricingForm.test.js.snap +++ b/src/containers/EditListingPricingForm/__snapshots__/EditListingPricingForm.test.js.snap @@ -13,7 +13,7 @@ exports[`EditListingPricingForm matches snapshot 1`] = ` {formattedPrice}
-
- +
+
@@ -618,8 +618,8 @@ export class ListingPageComponent extends Component {
{formattedPrice}
-
- +
+
diff --git a/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap b/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap index 944e8d4d..42037d63 100644 --- a/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap +++ b/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap @@ -174,7 +174,7 @@ exports[`ListingPage matches snapshot 1`] = `
@@ -398,7 +398,7 @@ exports[`ListingPage matches snapshot 1`] = `
diff --git a/src/translations/en.json b/src/translations/en.json index 09e4501c..18dd9ead 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -39,8 +39,7 @@ "Avatar.bannedUserDisplayName": "Banned user", "BookingBreakdown.bookingPeriod": "{bookingStart} – {bookingEnd}", "BookingBreakdown.commission": "Saunatime fee", - "BookingBreakdown.nightCount": "{count, number} {count, plural, one {night} other {nights}}", - "BookingBreakdown.pricePerNight": "Price per night", + "BookingBreakdown.pricePerUnit": "Price per night", "BookingBreakdown.providerTotalCanceled": "Total price", "BookingBreakdown.providerTotalDeclined": "You would have made", "BookingBreakdown.providerTotalDefault": "You'll make", @@ -48,6 +47,7 @@ "BookingBreakdown.refund": "Refund", "BookingBreakdown.subTotal": "Subtotal", "BookingBreakdown.total": "Total price", + "BookingBreakdown.unitCount": "{count, number} {count, plural, one {night} other {nights}}", "BookingDatesForm.bookingEndTitle": "End date", "BookingDatesForm.bookingStartTitle": "Start date", "BookingDatesForm.listingCurrencyInvalid": "Oops, the currency of the listing doesn't match the currency of the marketplace.", @@ -143,7 +143,7 @@ "EditListingPhotosPanel.payoutModalTitlePayoutPreferences": "Payout preferences", "EditListingPhotosPanel.title": "Edit the photos of {listingTitle}", "EditListingPricingForm.priceInputPlaceholder": "Choose your price…", - "EditListingPricingForm.pricePerNight": "Price per night in euros", + "EditListingPricingForm.pricePerUnit": "Price per night in euros", "EditListingPricingForm.priceRequired": "You need to add a valid price.", "EditListingPricingForm.updateFailed": "Failed to update listing. Please try again.", "EditListingPricingPanel.createListingTitle": "How much does it cost?", @@ -234,7 +234,7 @@ "LandingPage.schemaDescription": "Book a sauna using Saunatime or earn some income by sharing your sauna", "LandingPage.schemaTitle": "Book saunas everywhere | {siteTitle}", "ListingCard.hostedBy": "Hosted by {authorName}.", - "ListingCard.perNight": "per night", + "ListingCard.perUnit": "per night", "ListingCard.unsupportedPrice": "({currency})", "ListingCard.unsupportedPriceTitle": "Unsupported currency ({currency})", "ListingPage.bannedUserDisplayName": "Banned user", @@ -260,7 +260,7 @@ "ListingPage.locationTitle": "Location", "ListingPage.ownClosedListing": "Your listing has been closed and can't be booked.", "ListingPage.ownListing": "This is your own listing.", - "ListingPage.perNight": "per night", + "ListingPage.perUnit": "per night", "ListingPage.reviewsError": "Loading reviews failed.", "ListingPage.reviewsHeading": "Reviews ({count})", "ListingPage.schemaTitle": "{title} - {price} | {siteTitle}", @@ -282,7 +282,7 @@ "ManageListingCard.closedListing": "This listing is closed and not visible on the marketplace.", "ManageListingCard.edit": "Edit", "ManageListingCard.openListing": "Open listing", - "ManageListingCard.perNight": "per night", + "ManageListingCard.perUnit": "per night", "ManageListingCard.unsupportedPrice": "({currency})", "ManageListingCard.unsupportedPriceTitle": "Unsupported currency ({currency})", "ManageListingCard.viewListing": "View listing", From 803de79557c7c01e7737efe6576042d96cc16424 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 2 Jan 2018 15:46:35 +0200 Subject: [PATCH 6/9] Handle unit type in a general way --- .../BookingBreakdown/BookingBreakdown.js | 62 +++++++++++-------- .../BookingBreakdown.test.js.snap | 16 ++--- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/components/BookingBreakdown/BookingBreakdown.js b/src/components/BookingBreakdown/BookingBreakdown.js index 4f67672d..1936a4d4 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.js +++ b/src/components/BookingBreakdown/BookingBreakdown.js @@ -25,16 +25,16 @@ const isValidCommission = commissionLineItem => { }; const UnitPriceItem = props => { - const { transaction, intl } = props; - const nightPurchase = transaction.attributes.lineItems.find( - item => item.code === 'line-item/night' && !item.reversal + const { transaction, unitType, intl } = props; + const unitPurchase = transaction.attributes.lineItems.find( + item => item.code === unitType && !item.reversal ); - const formattedUnitPrice = formatMoney(intl, nightPurchase.unitPrice); + const formattedUnitPrice = formatMoney(intl, unitPurchase.unitPrice); return (
- + {formattedUnitPrice}
@@ -43,11 +43,12 @@ const UnitPriceItem = props => { UnitPriceItem.propTypes = { transaction: propTypes.transaction.isRequired, + unitType: oneOf([propTypes.LINE_ITEM_NIGHT, propTypes.LINE_ITEM_DAY]).isRequired, intl: intlShape.isRequired, }; const UnitsItem = props => { - const { transaction, booking, intl } = props; + const { transaction, booking, unitType, intl } = props; const dateFormatOptions = { weekday: 'short', @@ -71,18 +72,18 @@ const UnitsItem = props => { }} /> ); - const nightPurchase = transaction.attributes.lineItems.find( - item => item.code === 'line-item/night' && !item.reversal + const unitPurchase = transaction.attributes.lineItems.find( + item => item.code === unitType && !item.reversal ); - const nightCount = nightPurchase.quantity.toFixed(); - const nightCountMessage = ( - + const unitCount = unitPurchase.quantity.toFixed(); + const unitCountMessage = ( + ); return (
{bookingPeriod} - {nightCountMessage} + {unitCountMessage}
); }; @@ -94,20 +95,20 @@ UnitsItem.propTypes = { }; const SubTotalItemMaybe = props => { - const { transaction, isProvider, intl } = props; + const { transaction, unitType, isProvider, intl } = props; const refund = transaction.attributes.lineItems.find( - item => item.code === 'line-item/night' && item.reversal + item => item.code === unitType && item.reversal ); - // Show night purchase line total (unit price * quantity) as a subtotal. + // Show unit purchase line total (unit price * quantity) as a subtotal. // PLEASE NOTE that this assumes that the transaction doesn't have other - // line item types than nights (e.g. week, month, year). + // line item types than the defined unit type (e.g. week, month, year). const showSubTotal = isProvider || refund; - const nightPurchase = transaction.attributes.lineItems.find( - item => item.code === 'line-item/night' && !item.reversal + const unitPurchase = transaction.attributes.lineItems.find( + item => item.code === unitType && !item.reversal ); - const formattedSubTotal = formatMoney(intl, nightPurchase.lineTotal); + const formattedSubTotal = formatMoney(intl, unitPurchase.lineTotal); return showSubTotal ? (
@@ -129,10 +130,10 @@ const CommissionItemMaybe = props => { const { transaction, isProvider, intl } = props; const providerCommissionLineItem = transaction.attributes.lineItems.find( - item => item.code === 'line-item/provider-commission' && !item.reversal + item => item.code === propTypes.LINE_ITEM_PROVIDER_COMMISSION && !item.reversal ); const commissionRefund = transaction.attributes.lineItems.find( - item => item.code === 'line-item/provider-commission' && item.reversal + item => item.code === propTypes.LINE_ITEM_PROVIDER_COMMISSION && item.reversal ); // If commission is passed it will be shown as a fee already reduces from the total price @@ -168,10 +169,10 @@ CommissionItemMaybe.propTypes = { }; const RefundItemMaybe = props => { - const { transaction, intl } = props; + const { transaction, unitType, intl } = props; const refund = transaction.attributes.lineItems.find( - item => item.code === 'line-item/night' && item.reversal + item => item.code === unitType && item.reversal ); return refund ? ( @@ -192,6 +193,8 @@ RefundItemMaybe.propTypes = { export const BookingBreakdownComponent = props => { const { rootClassName, className, userRole, transaction, booking, intl } = props; + const unitType = propTypes.LINE_ITEM_NIGHT; + const isProvider = userRole === 'provider'; const classes = classNames(rootClassName || css.root, className); @@ -217,11 +220,16 @@ export const BookingBreakdownComponent = props => { return (
- - - + + + - +
{totalLabel}
diff --git a/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap b/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap index 2af3179a..881fa2f0 100644 --- a/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap +++ b/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap @@ -11,7 +11,7 @@ exports[`BookingBreakdown customer transaction data matches snapshot 1`] = ` className={undefined} > - BookingBreakdown.pricePerNight + BookingBreakdown.pricePerUnit @@ -75,7 +75,7 @@ exports[`BookingBreakdown pretransaction data matches snapshot 1`] = ` className={undefined} > - BookingBreakdown.pricePerNight + BookingBreakdown.pricePerUnit @@ -139,7 +139,7 @@ exports[`BookingBreakdown provider canceled transaction data matches snapshot 1` className={undefined} > - BookingBreakdown.pricePerNight + BookingBreakdown.pricePerUnit @@ -235,7 +235,7 @@ exports[`BookingBreakdown provider transaction data matches snapshot 1`] = ` className={undefined} > - BookingBreakdown.pricePerNight + BookingBreakdown.pricePerUnit From 14763906c54c94304c673ac23647a8e751a79910 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Wed, 3 Jan 2018 13:22:17 +0200 Subject: [PATCH 7/9] Make booking unit type configurable --- .../BookingBreakdown/BookingBreakdown.example.js | 11 +++++++++++ src/components/BookingBreakdown/BookingBreakdown.js | 5 ++--- .../BookingBreakdown/BookingBreakdown.test.js | 4 ++++ .../TransactionPanel/TransactionPanel.helpers.js | 3 +++ src/config.js | 8 ++++++++ src/containers/BookingDatesForm/BookingDatesForm.js | 1 + src/containers/CheckoutPage/CheckoutPage.js | 2 ++ 7 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/components/BookingBreakdown/BookingBreakdown.example.js b/src/components/BookingBreakdown/BookingBreakdown.example.js index acf020e3..c1622a92 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.example.js +++ b/src/components/BookingBreakdown/BookingBreakdown.example.js @@ -43,6 +43,7 @@ export const Checkout = { component: BookingBreakdown, props: { userRole: 'customer', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ payinTotal: new Money(9000, CURRENCY), payoutTotal: new Money(9000, CURRENCY), @@ -68,6 +69,7 @@ export const CustomerOrder = { component: BookingBreakdown, props: { userRole: 'customer', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ payinTotal: new Money(9000, CURRENCY), payoutTotal: new Money(9000, CURRENCY), @@ -93,6 +95,7 @@ export const ProviderSale = { component: BookingBreakdown, props: { userRole: 'provider', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ payinTotal: new Money(9000, CURRENCY), payoutTotal: new Money(7000, CURRENCY), @@ -125,6 +128,7 @@ export const ProviderSaleZeroCommission = { component: BookingBreakdown, props: { userRole: 'provider', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ payinTotal: new Money(9000, CURRENCY), payoutTotal: new Money(9000, CURRENCY), @@ -157,6 +161,7 @@ export const ProviderSaleSingleNight = { component: BookingBreakdown, props: { userRole: 'provider', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ payinTotal: new Money(4500, CURRENCY), payoutTotal: new Money(2500, CURRENCY), @@ -189,6 +194,7 @@ export const ProviderSalePreauthorized = { component: BookingBreakdown, props: { userRole: 'provider', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ lastTransition: propTypes.TX_TRANSITION_PREAUTHORIZE, payinTotal: new Money(4500, CURRENCY), @@ -222,6 +228,7 @@ export const ProviderSaleAccepted = { component: BookingBreakdown, props: { userRole: 'provider', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ lastTransition: propTypes.TX_TRANSITION_ACCEPT, payinTotal: new Money(4500, CURRENCY), @@ -255,6 +262,7 @@ export const ProviderSaleDeclined = { component: BookingBreakdown, props: { userRole: 'provider', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ lastTransition: propTypes.TX_TRANSITION_DECLINE, payinTotal: new Money(4500, CURRENCY), @@ -288,6 +296,7 @@ export const ProviderSaleAutoDeclined = { component: BookingBreakdown, props: { userRole: 'provider', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ lastTransition: propTypes.TX_TRANSITION_AUTO_DECLINE, payinTotal: new Money(4500, CURRENCY), @@ -321,6 +330,7 @@ export const ProviderSaleDelivered = { component: BookingBreakdown, props: { userRole: 'provider', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ lastTransition: propTypes.TX_TRANSITION_MARK_DELIVERED, payinTotal: new Money(4500, CURRENCY), @@ -354,6 +364,7 @@ export const ProviderSaleCanceled = { component: BookingBreakdown, props: { userRole: 'provider', + unitType: propTypes.LINE_ITEM_NIGHT, transaction: exampleTransaction({ lastTransition: propTypes.TX_TRANSITION_CANCEL, payinTotal: new Money(0, CURRENCY), diff --git a/src/components/BookingBreakdown/BookingBreakdown.js b/src/components/BookingBreakdown/BookingBreakdown.js index 1936a4d4..55eb3c6f 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.js +++ b/src/components/BookingBreakdown/BookingBreakdown.js @@ -191,9 +191,7 @@ RefundItemMaybe.propTypes = { }; export const BookingBreakdownComponent = props => { - const { rootClassName, className, userRole, transaction, booking, intl } = props; - - const unitType = propTypes.LINE_ITEM_NIGHT; + const { rootClassName, className, userRole, unitType, transaction, booking, intl } = props; const isProvider = userRole === 'provider'; const classes = classNames(rootClassName || css.root, className); @@ -246,6 +244,7 @@ BookingBreakdownComponent.propTypes = { className: string, userRole: oneOf(['customer', 'provider']).isRequired, + unitType: oneOf([propTypes.LINE_ITEM_NIGHT, propTypes.LINE_ITEM_DAY]).isRequired, transaction: propTypes.transaction.isRequired, booking: propTypes.booking.isRequired, diff --git a/src/components/BookingBreakdown/BookingBreakdown.test.js b/src/components/BookingBreakdown/BookingBreakdown.test.js index d0bd41ed..63cefd72 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.test.js +++ b/src/components/BookingBreakdown/BookingBreakdown.test.js @@ -36,6 +36,7 @@ describe('BookingBreakdown', () => { const tree = renderDeep( { const tree = renderDeep( { const tree = renderDeep( { const tree = renderDeep( { diff --git a/src/config.js b/src/config.js index e599c77e..aeac26c6 100644 --- a/src/config.js +++ b/src/config.js @@ -14,6 +14,13 @@ const i18n = { firstDayOfWeek: 0, }; +// The transaction line item code for the main unit type in bookings. +// +// Possible values: ['line-item/night', 'line-item/day'] +// +// TODO: Check that this applies when API adds support for daily bookings +const bookingUnitType = 'line-item/night'; + // To pass environment variables to the client app in the build // script, react-scripts (and the sharetribe-scripts fork of // react-scripts) require using the REACT_APP_ prefix to avoid @@ -262,6 +269,7 @@ const config = { env, dev, locale, + bookingUnitType, i18n, sdk: { clientId: sdkClientId, baseUrl: sdkBaseUrl }, currency, diff --git a/src/containers/BookingDatesForm/BookingDatesForm.js b/src/containers/BookingDatesForm/BookingDatesForm.js index 15d90ea6..76745d19 100644 --- a/src/containers/BookingDatesForm/BookingDatesForm.js +++ b/src/containers/BookingDatesForm/BookingDatesForm.js @@ -84,6 +84,7 @@ const estimatedBreakdown = (bookingStart, bookingEnd, unitPrice) => { diff --git a/src/containers/CheckoutPage/CheckoutPage.js b/src/containers/CheckoutPage/CheckoutPage.js index 87a6971c..55d6f32e 100644 --- a/src/containers/CheckoutPage/CheckoutPage.js +++ b/src/containers/CheckoutPage/CheckoutPage.js @@ -25,6 +25,7 @@ import { import { StripePaymentForm } from '../../containers'; import { isScrollingDisabled } from '../../ducks/UI.duck'; import { initiateOrder, setInitialValues, speculateTransaction } from './CheckoutPage.duck'; +import config from '../../config'; import { storeData, storedData, clearData } from './CheckoutPageSessionHelpers'; import LogoIcon from './LogoIcon'; @@ -203,6 +204,7 @@ export class CheckoutPageComponent extends Component { From dc73569da665835e3186ed0b6c415d0a3546a3b9 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Wed, 3 Jan 2018 14:32:20 +0200 Subject: [PATCH 8/9] Add daysBetween helper function --- src/util/dates.js | 20 ++++++++++++++++++++ src/util/dates.test.js | 24 +++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/util/dates.js b/src/util/dates.js index 94c31328..cb7a0902 100644 --- a/src/util/dates.js +++ b/src/util/dates.js @@ -23,6 +23,26 @@ export const nightsBetween = (startDate, endDate) => { return nights; }; +/** + * Calculate the number of days between the given dates + * + * @param {Date} startDate start of the time period + * @param {Date} endDate end of the time period. NOTE: with daily + * bookings, it is expected that this date is the exclusive end date, + * i.e. the last day of the booking is the previous date of this end + * date. + * + * @throws Will throw if the end date is before the start date + * @returns {Number} number of days between the given dates + */ +export const daysBetween = (startDate, endDate) => { + const days = moment(endDate).diff(startDate, 'days'); + if (days < 0) { + throw new Error('End date cannot be before start date'); + } + return days; +}; + /** * Format the given date * diff --git a/src/util/dates.test.js b/src/util/dates.test.js index 99eacbd4..b3876cd8 100644 --- a/src/util/dates.test.js +++ b/src/util/dates.test.js @@ -1,5 +1,5 @@ import { fakeIntl } from './test-data'; -import { nightsBetween, formatDate } from './dates'; +import { nightsBetween, daysBetween, formatDate } from './dates'; describe('date utils', () => { describe('nightsBetween()', () => { @@ -24,6 +24,28 @@ describe('date utils', () => { }); }); + describe('daysBetween()', () => { + it('should fail if end date is before start date', () => { + const start = new Date(2017, 0, 2); + const end = new Date(2017, 0, 1); + expect(() => daysBetween(start, end)).toThrow('End date cannot be before start date'); + }); + it('should handle equal start and end dates', () => { + const d = new Date(2017, 0, 1); + expect(daysBetween(d, d)).toEqual(0); + }); + it('should calculate night count for a single day', () => { + const start = new Date(2017, 0, 1); + const end = new Date(2017, 0, 2); + expect(daysBetween(start, end)).toEqual(1); + }); + it('should calculate day count', () => { + const start = new Date(2017, 0, 1); + const end = new Date(2017, 0, 3); + expect(daysBetween(start, end)).toEqual(2); + }); + }); + describe('formatDate()', () => { /* NOTE: These are not really testing the formatting properly since From b44828045d90fe89314a4193e6da253f6c1a46b3 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Wed, 3 Jan 2018 14:34:31 +0200 Subject: [PATCH 9/9] Add support for daily breakdowns --- .../BookingBreakdown.example.js | 52 +++++++++++++++++++ .../BookingBreakdown/BookingBreakdown.js | 30 +++++++---- .../BookingBreakdown.test.js.snap | 16 +++--- .../BookingDatesForm/BookingDatesForm.js | 3 +- src/translations/en.json | 6 ++- 5 files changed, 87 insertions(+), 20 deletions(-) diff --git a/src/components/BookingBreakdown/BookingBreakdown.example.js b/src/components/BookingBreakdown/BookingBreakdown.example.js index c1622a92..c19ca9c7 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.example.js +++ b/src/components/BookingBreakdown/BookingBreakdown.example.js @@ -410,3 +410,55 @@ export const ProviderSaleCanceled = { }), }, }; + +export const SingleDay = { + component: BookingBreakdown, + props: { + userRole: 'customer', + unitType: propTypes.LINE_ITEM_DAY, + transaction: exampleTransaction({ + payinTotal: new Money(4500, CURRENCY), + payoutTotal: new Money(4500, CURRENCY), + lineItems: [ + { + code: 'line-item/day', + includeFor: ['customer', 'provider'], + quantity: new Decimal(1), + unitPrice: new Money(4500, CURRENCY), + lineTotal: new Money(4500, CURRENCY), + reversal: false, + }, + ], + }), + booking: exampleBooking({ + start: new Date(Date.UTC(2017, 3, 14)), + end: new Date(Date.UTC(2017, 3, 15)), + }), + }, +}; + +export const MultipleDays = { + component: BookingBreakdown, + props: { + userRole: 'customer', + unitType: propTypes.LINE_ITEM_DAY, + transaction: exampleTransaction({ + payinTotal: new Money(9000, CURRENCY), + payoutTotal: new Money(9000, CURRENCY), + lineItems: [ + { + code: 'line-item/day', + includeFor: ['customer', 'provider'], + quantity: new Decimal(2), + unitPrice: new Money(4500, CURRENCY), + lineTotal: new Money(9000, CURRENCY), + reversal: false, + }, + ], + }), + booking: exampleBooking({ + start: new Date(Date.UTC(2017, 3, 14)), + end: new Date(Date.UTC(2017, 3, 16)), + }), + }, +}; diff --git a/src/components/BookingBreakdown/BookingBreakdown.js b/src/components/BookingBreakdown/BookingBreakdown.js index 55eb3c6f..054f6450 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.js +++ b/src/components/BookingBreakdown/BookingBreakdown.js @@ -5,10 +5,12 @@ import React from 'react'; import { bool, oneOf, string } from 'prop-types'; import { FormattedMessage, FormattedHTMLMessage, intlShape, injectIntl } from 'react-intl'; +import moment from 'moment'; import classNames from 'classnames'; import { types } from '../../util/sdkLoader'; import { formatMoney } from '../../util/currency'; import * as propTypes from '../../util/propTypes'; +import { daysBetween } from '../../util/dates'; import css from './BookingBreakdown.css'; @@ -26,6 +28,7 @@ const isValidCommission = commissionLineItem => { const UnitPriceItem = props => { const { transaction, unitType, intl } = props; + const isNightly = unitType === propTypes.LINE_ITEM_NIGHT; const unitPurchase = transaction.attributes.lineItems.find( item => item.code === unitType && !item.reversal ); @@ -34,7 +37,9 @@ const UnitPriceItem = props => { return (
- + {formattedUnitPrice}
@@ -50,24 +55,28 @@ UnitPriceItem.propTypes = { const UnitsItem = props => { const { transaction, booking, unitType, intl } = props; + const { start: startDate, end: endDateRaw } = booking.attributes; + const isNightly = unitType === propTypes.LINE_ITEM_NIGHT; + const isSingleDay = !isNightly && daysBetween(startDate, endDateRaw) === 1; + + const endDay = isNightly ? endDateRaw : moment(endDateRaw).subtract(1, 'days'); + const dateFormatOptions = { weekday: 'short', month: 'short', day: 'numeric', }; - const bookingPeriod = ( + const bookingPeriod = isSingleDay ? ( + intl.formatDate(startDate, dateFormatOptions) + ) : ( - {intl.formatDate(booking.attributes.start, dateFormatOptions)} -
+ {intl.formatDate(startDate, dateFormatOptions)} ), bookingEnd: ( - - {intl.formatDate(booking.attributes.end, dateFormatOptions)} - + {intl.formatDate(endDay, dateFormatOptions)} ), }} /> @@ -77,7 +86,10 @@ const UnitsItem = props => { ); const unitCount = unitPurchase.quantity.toFixed(); const unitCountMessage = ( - + ); return ( diff --git a/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap b/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap index 881fa2f0..2af3179a 100644 --- a/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap +++ b/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap @@ -11,7 +11,7 @@ exports[`BookingBreakdown customer transaction data matches snapshot 1`] = ` className={undefined} > - BookingBreakdown.pricePerUnit + BookingBreakdown.pricePerNight @@ -75,7 +75,7 @@ exports[`BookingBreakdown pretransaction data matches snapshot 1`] = ` className={undefined} > - BookingBreakdown.pricePerUnit + BookingBreakdown.pricePerNight @@ -139,7 +139,7 @@ exports[`BookingBreakdown provider canceled transaction data matches snapshot 1` className={undefined} > - BookingBreakdown.pricePerUnit + BookingBreakdown.pricePerNight @@ -235,7 +235,7 @@ exports[`BookingBreakdown provider transaction data matches snapshot 1`] = ` className={undefined} > - BookingBreakdown.pricePerUnit + BookingBreakdown.pricePerNight diff --git a/src/containers/BookingDatesForm/BookingDatesForm.js b/src/containers/BookingDatesForm/BookingDatesForm.js index 76745d19..9f2fd4e0 100644 --- a/src/containers/BookingDatesForm/BookingDatesForm.js +++ b/src/containers/BookingDatesForm/BookingDatesForm.js @@ -45,7 +45,7 @@ const estimatedNightlyTransaction = (bookingStart, bookingEnd, unitPrice) => { payoutTotal: totalPrice, lineItems: [ { - code: 'line-item/night', + code: propTypes.LINE_ITEM_NIGHT, includeFor: ['customer', 'provider'], unitPrice: unitPrice, quantity: new Decimal(nightCount), @@ -78,6 +78,7 @@ const estimatedBreakdown = (bookingStart, bookingEnd, unitPrice) => { return null; } + // TODO: estimate daily tx if config is set const tx = estimatedNightlyTransaction(bookingStart, bookingEnd, unitPrice); return ( diff --git a/src/translations/en.json b/src/translations/en.json index 18dd9ead..160ced5c 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -39,7 +39,10 @@ "Avatar.bannedUserDisplayName": "Banned user", "BookingBreakdown.bookingPeriod": "{bookingStart} – {bookingEnd}", "BookingBreakdown.commission": "Saunatime fee", - "BookingBreakdown.pricePerUnit": "Price per night", + "BookingBreakdown.dayCount": "{count, number} {count, plural, one {day} other {days}}", + "BookingBreakdown.nightCount": "{count, number} {count, plural, one {night} other {nights}}", + "BookingBreakdown.pricePerDay": "Price per day", + "BookingBreakdown.pricePerNight": "Price per night", "BookingBreakdown.providerTotalCanceled": "Total price", "BookingBreakdown.providerTotalDeclined": "You would have made", "BookingBreakdown.providerTotalDefault": "You'll make", @@ -47,7 +50,6 @@ "BookingBreakdown.refund": "Refund", "BookingBreakdown.subTotal": "Subtotal", "BookingBreakdown.total": "Total price", - "BookingBreakdown.unitCount": "{count, number} {count, plural, one {night} other {nights}}", "BookingDatesForm.bookingEndTitle": "End date", "BookingDatesForm.bookingStartTitle": "Start date", "BookingDatesForm.listingCurrencyInvalid": "Oops, the currency of the listing doesn't match the currency of the marketplace.",