mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-31 02:26:50 +10:00
Fix merge conflicts and run prettier
This commit is contained in:
parent
5ac536a5ae
commit
096af7c766
5 changed files with 118 additions and 93 deletions
|
|
@ -7,13 +7,15 @@ export const Checkout = {
|
|||
props: {
|
||||
bookingStart: new Date(Date.UTC(2017, 3, 14)),
|
||||
bookingEnd: new Date(Date.UTC(2017, 3, 16)),
|
||||
userRole: "customer",
|
||||
lineItems: [{
|
||||
code: "line-item.purchase/night",
|
||||
quantity: new Decimal(2),
|
||||
unitPrice: new types.Money(4500, 'USD'),
|
||||
lineTotal: new types.Money(9000, 'USD'),
|
||||
}],
|
||||
userRole: 'customer',
|
||||
lineItems: [
|
||||
{
|
||||
code: 'line-item.purchase/night',
|
||||
quantity: new Decimal(2),
|
||||
unitPrice: new types.Money(4500, 'USD'),
|
||||
lineTotal: new types.Money(9000, 'USD'),
|
||||
},
|
||||
],
|
||||
payinTotal: new types.Money(9000, 'USD'),
|
||||
},
|
||||
};
|
||||
|
|
@ -23,13 +25,15 @@ export const CustomerOrder = {
|
|||
props: {
|
||||
bookingStart: new Date(Date.UTC(2017, 3, 14)),
|
||||
bookingEnd: new Date(Date.UTC(2017, 3, 16)),
|
||||
userRole: "customer",
|
||||
lineItems: [{
|
||||
code: "line-item.purchase/night",
|
||||
quantity: new Decimal(2),
|
||||
unitPrice: new types.Money(4500, 'USD'),
|
||||
lineTotal: new types.Money(9000, 'USD'),
|
||||
}],
|
||||
userRole: 'customer',
|
||||
lineItems: [
|
||||
{
|
||||
code: 'line-item.purchase/night',
|
||||
quantity: new Decimal(2),
|
||||
unitPrice: new types.Money(4500, 'USD'),
|
||||
lineTotal: new types.Money(9000, 'USD'),
|
||||
},
|
||||
],
|
||||
payinTotal: new types.Money(9000, 'USD'),
|
||||
},
|
||||
};
|
||||
|
|
@ -39,17 +43,20 @@ export const ProviderSale = {
|
|||
props: {
|
||||
bookingStart: new Date(Date.UTC(2017, 3, 14)),
|
||||
bookingEnd: new Date(Date.UTC(2017, 3, 16)),
|
||||
userRole: "provider",
|
||||
lineItems: [{
|
||||
code: "line-item.purchase/night",
|
||||
quantity: new Decimal(2),
|
||||
unitPrice: new types.Money(4500, 'USD'),
|
||||
lineTotal: new types.Money(9000, 'USD'),
|
||||
}, {
|
||||
code: "line-item.commission/provider",
|
||||
unitPrice: new types.Money(-2000, 'USD'),
|
||||
lineTotal: new types.Money(-2000, 'USD'),
|
||||
}],
|
||||
userRole: 'provider',
|
||||
lineItems: [
|
||||
{
|
||||
code: 'line-item.purchase/night',
|
||||
quantity: new Decimal(2),
|
||||
unitPrice: new types.Money(4500, 'USD'),
|
||||
lineTotal: new types.Money(9000, 'USD'),
|
||||
},
|
||||
{
|
||||
code: 'line-item.commission/provider',
|
||||
unitPrice: new types.Money(-2000, 'USD'),
|
||||
lineTotal: new types.Money(-2000, 'USD'),
|
||||
},
|
||||
],
|
||||
payoutTotal: new types.Money(7000, 'USD'),
|
||||
},
|
||||
};
|
||||
|
|
@ -59,17 +66,20 @@ export const ProviderSaleZeroCommission = {
|
|||
props: {
|
||||
bookingStart: new Date(Date.UTC(2017, 3, 14)),
|
||||
bookingEnd: new Date(Date.UTC(2017, 3, 16)),
|
||||
userRole: "provider",
|
||||
lineItems: [{
|
||||
code: "line-item.purchase/night",
|
||||
quantity: new Decimal(2),
|
||||
unitPrice: new types.Money(4500, 'USD'),
|
||||
lineTotal: new types.Money(9000, 'USD'),
|
||||
}, {
|
||||
code: "line-item.commission/provider",
|
||||
unitPrice: new types.Money(0, 'USD'),
|
||||
lineTotal: new types.Money(0, 'USD'),
|
||||
}],
|
||||
userRole: 'provider',
|
||||
lineItems: [
|
||||
{
|
||||
code: 'line-item.purchase/night',
|
||||
quantity: new Decimal(2),
|
||||
unitPrice: new types.Money(4500, 'USD'),
|
||||
lineTotal: new types.Money(9000, 'USD'),
|
||||
},
|
||||
{
|
||||
code: 'line-item.commission/provider',
|
||||
unitPrice: new types.Money(0, 'USD'),
|
||||
lineTotal: new types.Money(0, 'USD'),
|
||||
},
|
||||
],
|
||||
payoutTotal: new types.Money(9000, 'USD'),
|
||||
},
|
||||
};
|
||||
|
|
@ -79,17 +89,20 @@ export const ProviderSaleSingleNight = {
|
|||
props: {
|
||||
bookingStart: new Date(Date.UTC(2017, 3, 14)),
|
||||
bookingEnd: new Date(Date.UTC(2017, 3, 15)),
|
||||
userRole: "provider",
|
||||
lineItems: [{
|
||||
code: "line-item.purchase/night",
|
||||
quantity: new Decimal(1),
|
||||
unitPrice: new types.Money(4500, 'USD'),
|
||||
lineTotal: new types.Money(4500, 'USD'),
|
||||
},{
|
||||
code: "line-item.commission/provider",
|
||||
lineTotal: new types.Money(-2000, 'USD'),
|
||||
unitPrice: new types.Money(-2000, 'USD'),
|
||||
}],
|
||||
userRole: 'provider',
|
||||
lineItems: [
|
||||
{
|
||||
code: 'line-item.purchase/night',
|
||||
quantity: new Decimal(1),
|
||||
unitPrice: new types.Money(4500, 'USD'),
|
||||
lineTotal: new types.Money(4500, 'USD'),
|
||||
},
|
||||
{
|
||||
code: 'line-item.commission/provider',
|
||||
unitPrice: new types.Money(-2000, 'USD'),
|
||||
lineTotal: new types.Money(-2000, 'USD'),
|
||||
},
|
||||
],
|
||||
payoutTotal: new types.Money(2500, 'USD'),
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -71,20 +71,20 @@ export const BookingBreakdownComponent = props => {
|
|||
// If commission is passed it will be shown as a fee already reduces from the total price
|
||||
let commissionInfo = null;
|
||||
|
||||
if (userRole === "provider") {
|
||||
if (userRole === 'provider') {
|
||||
const commission = providerCommission.lineTotal;
|
||||
const commissionAsNumber = commission ? convertMoneyToNumber(commission, subUnitDivisor) : 0;
|
||||
const formattedCommission = commission
|
||||
? intl.formatNumber(new Decimal(commissionAsNumber).negated().toNumber(), currencyConfig)
|
||||
: null;
|
||||
? intl.formatNumber(new Decimal(commissionAsNumber).negated().toNumber(), currencyConfig)
|
||||
: null;
|
||||
|
||||
commissionInfo = (
|
||||
<div className={css.lineItem}>
|
||||
<span className={css.itemLabel}>
|
||||
<FormattedMessage id="BookingBreakdown.commission" />
|
||||
</span>
|
||||
<span className={css.itemValue}>{formattedCommission}</span>
|
||||
</div>
|
||||
<span className={css.itemLabel}>
|
||||
<FormattedMessage id="BookingBreakdown.commission" />
|
||||
</span>
|
||||
<span className={css.itemValue}>{formattedCommission}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@ describe('BookingBreakdown', () => {
|
|||
bookingEnd={new Date(Date.UTC(2017, 3, 16))}
|
||||
payinTotal={new types.Money(2000, 'USD')}
|
||||
userRole="customer"
|
||||
lineItems={[{
|
||||
code: "line-item.purchase/night",
|
||||
quantity: new Decimal(2),
|
||||
lineTotal: new types.Money(2000, 'USD'),
|
||||
unitPrice: new types.Money(1000, 'USD'),
|
||||
}]}
|
||||
lineItems={[
|
||||
{
|
||||
code: 'line-item.purchase/night',
|
||||
quantity: new Decimal(2),
|
||||
lineTotal: new types.Money(2000, 'USD'),
|
||||
unitPrice: new types.Money(1000, 'USD'),
|
||||
},
|
||||
]}
|
||||
intl={fakeIntl}
|
||||
/>
|
||||
);
|
||||
|
|
@ -32,12 +34,14 @@ describe('BookingBreakdown', () => {
|
|||
bookingEnd={new Date(Date.UTC(2017, 3, 16))}
|
||||
userRole="customer"
|
||||
payinTotal={new types.Money(2000, 'USD')}
|
||||
lineItems={[{
|
||||
code: "line-item.purchase/night",
|
||||
quantity: new Decimal(2),
|
||||
lineTotal: new types.Money(2000, 'USD'),
|
||||
unitPrice: new types.Money(1000, 'USD'),
|
||||
}]}
|
||||
lineItems={[
|
||||
{
|
||||
code: 'line-item.purchase/night',
|
||||
quantity: new Decimal(2),
|
||||
lineTotal: new types.Money(2000, 'USD'),
|
||||
unitPrice: new types.Money(1000, 'USD'),
|
||||
},
|
||||
]}
|
||||
intl={fakeIntl}
|
||||
/>
|
||||
);
|
||||
|
|
@ -52,16 +56,19 @@ describe('BookingBreakdown', () => {
|
|||
commission={new types.Money(200, 'USD')}
|
||||
payoutTotal={new types.Money(1800, 'USD')}
|
||||
userRole="provider"
|
||||
lineItems={[{
|
||||
code: "line-item.purchase/night",
|
||||
quantity: new Decimal(2),
|
||||
lineTotal: new types.Money(2000, 'USD'),
|
||||
unitPrice: new types.Money(1000, 'USD'),
|
||||
}, {
|
||||
code: "line-item.commission/provider",
|
||||
lineTotal: new types.Money(200, 'USD'),
|
||||
unitPrice: new types.Money(200, 'USD'),
|
||||
}]}
|
||||
lineItems={[
|
||||
{
|
||||
code: 'line-item.purchase/night',
|
||||
quantity: new Decimal(2),
|
||||
lineTotal: new types.Money(2000, 'USD'),
|
||||
unitPrice: new types.Money(1000, 'USD'),
|
||||
},
|
||||
{
|
||||
code: 'line-item.commission/provider',
|
||||
lineTotal: new types.Money(200, 'USD'),
|
||||
unitPrice: new types.Money(200, 'USD'),
|
||||
},
|
||||
]}
|
||||
intl={fakeIntl}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -34,12 +34,14 @@ const breakdown = (bookingStart, bookingEnd, unitPrice) => {
|
|||
}
|
||||
const nightCount = nightsBetween(bookingStart, bookingEnd);
|
||||
const totalPrice = estimatedTotalPrice(unitPrice, nightCount);
|
||||
const lineItems = [{
|
||||
code: "line-item.purchase/night",
|
||||
unitPrice: unitPrice,
|
||||
quantity: new Decimal(nightCount),
|
||||
lineTotal: totalPrice,
|
||||
}];
|
||||
const lineItems = [
|
||||
{
|
||||
code: 'line-item.purchase/night',
|
||||
unitPrice: unitPrice,
|
||||
quantity: new Decimal(nightCount),
|
||||
lineTotal: totalPrice,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<BookingBreakdown
|
||||
|
|
|
|||
|
|
@ -92,16 +92,19 @@ export const createTransaction = options => {
|
|||
state,
|
||||
payinTotal: total,
|
||||
payoutTotal: new Money(total.amount - commission.amount, total.currency),
|
||||
lineItems: [{
|
||||
code: "line-item.purchase/night",
|
||||
quantity: new Decimal(nightCount),
|
||||
unitPrice: new Money(total.amount / nightCount, total.currency),
|
||||
lineTotal: total,
|
||||
}, {
|
||||
code: "line-item.commission/provider",
|
||||
unitPrice: commission,
|
||||
lineTotal: commission,
|
||||
}]
|
||||
lineItems: [
|
||||
{
|
||||
code: 'line-item.purchase/night',
|
||||
quantity: new Decimal(nightCount),
|
||||
unitPrice: new Money(total.amount / nightCount, total.currency),
|
||||
lineTotal: total,
|
||||
},
|
||||
{
|
||||
code: 'line-item.commission/provider',
|
||||
unitPrice: commission,
|
||||
lineTotal: commission,
|
||||
},
|
||||
],
|
||||
},
|
||||
booking,
|
||||
listing,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue