diff --git a/src/components/BookingBreakdown/BookingBreakdown.example.js b/src/components/BookingBreakdown/BookingBreakdown.example.js index 83e020bd..c19ca9c7 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.example.js +++ b/src/components/BookingBreakdown/BookingBreakdown.example.js @@ -43,12 +43,14 @@ 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), lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(9000, CURRENCY), @@ -67,12 +69,14 @@ 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), lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(9000, CURRENCY), @@ -91,12 +95,14 @@ 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), lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(9000, CURRENCY), @@ -104,6 +110,7 @@ export const ProviderSale = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -121,12 +128,14 @@ 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), lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(9000, CURRENCY), @@ -134,6 +143,7 @@ export const ProviderSaleZeroCommission = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(0, CURRENCY), lineTotal: new Money(0, CURRENCY), reversal: false, @@ -151,12 +161,14 @@ 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), lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(1), unitPrice: new Money(4500, CURRENCY), lineTotal: new Money(4500, CURRENCY), @@ -164,6 +176,7 @@ export const ProviderSaleSingleNight = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -181,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), @@ -188,6 +202,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 +210,7 @@ export const ProviderSalePreauthorized = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -212,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), @@ -219,6 +236,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 +244,7 @@ export const ProviderSaleAccepted = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -243,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), @@ -250,6 +270,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 +278,7 @@ export const ProviderSaleDeclined = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -274,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), @@ -281,6 +304,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 +312,7 @@ export const ProviderSaleAutoDeclined = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -305,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), @@ -312,6 +338,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 +346,7 @@ export const ProviderSaleDelivered = { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], unitPrice: new Money(-2000, CURRENCY), lineTotal: new Money(-2000, CURRENCY), reversal: false, @@ -336,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), @@ -343,6 +372,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 +380,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 +388,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 +396,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), @@ -377,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 7c51172e..054f6450 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.js +++ b/src/components/BookingBreakdown/BookingBreakdown.js @@ -3,12 +3,14 @@ * 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 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'; @@ -24,73 +26,103 @@ const isValidCommission = commissionLineItem => { ); }; -export const BookingBreakdownComponent = props => { - const { rootClassName, className, userRole, transaction, booking, intl } = props; +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 + ); + const formattedUnitPrice = formatMoney(intl, unitPurchase.unitPrice); - const isProvider = userRole === 'provider'; - const classes = classNames(rootClassName || css.root, className); + return ( +
+ + + + {formattedUnitPrice} +
+ ); +}; + +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, 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)} ), }} /> ); - - 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 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 unitCount = unitPurchase.quantity.toFixed(); + const unitCountMessage = ( + ); - const refundInfo = refund ? ( + return (
- - - - {formatMoney(intl, refund.lineTotal)} + {bookingPeriod} + {unitCountMessage}
- ) : null; + ); +}; - const nightCount = nightPurchase.quantity.toFixed(); - const nightCountMessage = ( - +UnitsItem.propTypes = { + transaction: propTypes.transaction.isRequired, + booking: propTypes.booking.isRequired, + intl: intlShape.isRequired, +}; + +const SubTotalItemMaybe = props => { + const { transaction, unitType, isProvider, intl } = props; + + const refund = transaction.attributes.lineItems.find( + item => item.code === unitType && item.reversal ); - 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; - - // 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 formattedSubTotal = formatMoney(intl, nightPurchase.lineTotal); - const subTotalInfo = showSubTotal ? ( + const unitPurchase = transaction.attributes.lineItems.find( + item => item.code === unitType && !item.reversal + ); + const formattedSubTotal = formatMoney(intl, unitPurchase.lineTotal); + + return showSubTotal ? (
@@ -98,6 +130,26 @@ export const BookingBreakdownComponent = 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 === propTypes.LINE_ITEM_PROVIDER_COMMISSION && !item.reversal + ); + const commissionRefund = transaction.attributes.lineItems.find( + 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 + let commissionItem = null; if (isProvider) { if (!isValidCommission(providerCommissionLineItem)) { @@ -109,7 +161,7 @@ export const BookingBreakdownComponent = props => { const commission = providerCommissionLineItem.lineTotal; const formattedCommission = commission ? formatMoney(intl, commission) : null; - commissionInfo = commissionRefund ? null : ( + commissionItem = commissionRefund ? null : (
@@ -119,6 +171,43 @@ export const BookingBreakdownComponent = props => { ); } + return commissionItem; +}; + +CommissionItemMaybe.propTypes = { + transaction: propTypes.transaction.isRequired, + isProvider: bool.isRequired, + intl: intlShape.isRequired, +}; + +const RefundItemMaybe = props => { + const { transaction, unitType, intl } = props; + + const refund = transaction.attributes.lineItems.find( + item => item.code === unitType && 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, unitType, transaction, booking, intl } = props; + + const isProvider = userRole === 'provider'; + const classes = classNames(rootClassName || css.root, className); + let providerTotalMessageId = 'BookingBreakdown.providerTotalDefault'; if (propTypes.txIsDelivered(transaction)) { providerTotalMessageId = 'BookingBreakdown.providerTotalDelivered'; @@ -141,19 +230,16 @@ export const BookingBreakdownComponent = props => { return (
-
- - - - {formattedUnitPrice} -
-
- {bookingPeriod} - {nightCountMessage} -
- {subTotalInfo} - {commissionInfo} - {refundInfo} + + + + +
{totalLabel}
@@ -165,13 +251,12 @@ export const BookingBreakdownComponent = props => { BookingBreakdownComponent.defaultProps = { rootClassName: null, className: null }; -const { oneOf, string } = PropTypes; - BookingBreakdownComponent.propTypes = { rootClassName: string, 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 b4addd56..63cefd72 100644 --- a/src/components/BookingBreakdown/BookingBreakdown.test.js +++ b/src/components/BookingBreakdown/BookingBreakdown.test.js @@ -36,12 +36,14 @@ describe('BookingBreakdown', () => { const tree = renderDeep( { const tree = renderDeep( { const tree = renderDeep( { }, { code: 'line-item/provider-commission', + includeFor: ['provider'], lineTotal: new Money(-200, 'USD'), unitPrice: new Money(-200, 'USD'), reversal: false, @@ -122,6 +129,7 @@ describe('BookingBreakdown', () => { const tree = renderDeep( { lineItems: [ { code: 'line-item/night', + includeFor: ['customer', 'provider'], quantity: new Decimal(2), lineTotal: new Money(2000, 'USD'), unitPrice: new Money(1000, 'USD'), @@ -136,6 +145,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 +153,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 +161,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/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/components/TransactionPanel/TransactionPanel.helpers.js b/src/components/TransactionPanel/TransactionPanel.helpers.js index 30ece11e..22b322b8 100644 --- a/src/components/TransactionPanel/TransactionPanel.helpers.js +++ b/src/components/TransactionPanel/TransactionPanel.helpers.js @@ -11,6 +11,8 @@ import { PrimaryButton, SecondaryButton, } from '../../components'; +import config from '../../config'; + import css from './TransactionPanel.css'; // Functional component as a helper to build ActivityFeed section @@ -85,6 +87,7 @@ export const BreakdownMaybe = props => { diff --git a/src/components/TransactionPanel/__snapshots__/TransactionPanel.test.js.snap b/src/components/TransactionPanel/__snapshots__/TransactionPanel.test.js.snap index a5a484d8..19a9c1fe 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", @@ -4338,6 +4513,10 @@ exports[`TransactionPanel - Order enquired matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -4351,6 +4530,9 @@ exports[`TransactionPanel - Order enquired matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -100, "currency": "USD", @@ -5969,6 +6151,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", @@ -5982,6 +6168,9 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6079,6 +6268,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", @@ -6092,6 +6285,9 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6189,6 +6385,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", @@ -6202,6 +6402,9 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6417,6 +6620,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", @@ -6430,6 +6637,9 @@ exports[`TransactionPanel - Sale accepted matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6614,6 +6824,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", @@ -6627,6 +6841,9 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6726,6 +6943,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", @@ -6739,6 +6960,9 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6836,6 +7060,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", @@ -6849,6 +7077,9 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -6946,6 +7177,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", @@ -6959,6 +7194,9 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7174,6 +7412,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", @@ -7187,6 +7429,9 @@ exports[`TransactionPanel - Sale autodeclined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7371,6 +7616,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", @@ -7384,6 +7633,9 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7483,6 +7735,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", @@ -7496,6 +7752,9 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7593,6 +7852,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", @@ -7606,6 +7869,9 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7703,6 +7969,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", @@ -7716,6 +7986,9 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -7931,6 +8204,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", @@ -7944,6 +8221,9 @@ exports[`TransactionPanel - Sale canceled matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8128,6 +8408,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", @@ -8141,6 +8425,9 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8240,6 +8527,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", @@ -8253,6 +8544,9 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8350,6 +8644,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", @@ -8363,6 +8661,9 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8460,6 +8761,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", @@ -8473,6 +8778,9 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8688,6 +8996,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", @@ -8701,6 +9013,9 @@ exports[`TransactionPanel - Sale declined matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8885,6 +9200,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", @@ -8898,6 +9217,9 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -8997,6 +9319,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", @@ -9010,6 +9336,9 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -9107,6 +9436,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", @@ -9120,6 +9453,9 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -9217,6 +9553,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", @@ -9230,6 +9570,9 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -9445,6 +9788,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", @@ -9458,6 +9805,9 @@ exports[`TransactionPanel - Sale delivered matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -9642,6 +9992,10 @@ exports[`TransactionPanel - Sale enquired matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -9655,6 +10009,9 @@ exports[`TransactionPanel - Sale enquired matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -9754,6 +10111,10 @@ exports[`TransactionPanel - Sale enquired matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -9767,6 +10128,9 @@ exports[`TransactionPanel - Sale enquired matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -9864,6 +10228,10 @@ exports[`TransactionPanel - Sale enquired matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -9877,6 +10245,9 @@ exports[`TransactionPanel - Sale enquired matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -9974,6 +10345,10 @@ exports[`TransactionPanel - Sale enquired matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -9987,6 +10362,9 @@ exports[`TransactionPanel - Sale enquired matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -10202,6 +10580,10 @@ exports[`TransactionPanel - Sale enquired matches snapshot 1`] = ` "lineItems": Array [ Object { "code": "line-item/night", + "includeFor": Array [ + "customer", + "provider", + ], "lineTotal": Money { "amount": 16500, "currency": "USD", @@ -10215,6 +10597,9 @@ exports[`TransactionPanel - Sale enquired matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -10399,6 +10784,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", @@ -10412,6 +10801,9 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -10511,6 +10903,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", @@ -10524,6 +10920,9 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -10621,6 +11020,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", @@ -10634,6 +11037,9 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -10731,6 +11137,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", @@ -10744,6 +11154,9 @@ exports[`TransactionPanel - Sale preauthorized matches snapshot 1`] = ` }, Object { "code": "line-item/provider-commission", + "includeFor": Array [ + "provider", + ], "lineTotal": Money { "amount": -1000, "currency": "USD", @@ -10959,6 +11372,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", @@ -10972,6 +11389,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/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 6800e9db..9f2fd4e0 100644 --- a/src/containers/BookingDatesForm/BookingDatesForm.js +++ b/src/containers/BookingDatesForm/BookingDatesForm.js @@ -45,7 +45,8 @@ 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), lineTotal: totalPrice, @@ -77,12 +78,14 @@ 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/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/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 { 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/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/translations/en.json b/src/translations/en.json index 09e4501c..160ced5c 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -39,7 +39,9 @@ "Avatar.bannedUserDisplayName": "Banned user", "BookingBreakdown.bookingPeriod": "{bookingStart} – {bookingEnd}", "BookingBreakdown.commission": "Saunatime fee", + "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", @@ -143,7 +145,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 +236,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 +262,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 +284,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", 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 diff --git a/src/util/propTypes.js b/src/util/propTypes.js index 5b2bde9a..fa233053 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,