Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BookingUnitType config.js variable needed more comments #1317

Merged
merged 4 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ way to update this template, but currently, we follow a pattern:

## Upcoming version 2020-XX-XX

- [fix] Sync bookingUnitType variables and update comments. Client app's API (proxy) server needs to
know about unit type. [#1317](https://github.com/sharetribe/ftw-daily/pull/1317)

## [v6.0.0] 2020-06-25

- [change] Use privileged transitions for price calculation by default and
update the process alias.
- [change] Use privileged transitions for price calculation by default and update the process alias.
[#1314](https://github.com/sharetribe/ftw-daily/pull/1314)
- [add] Add client secret enquiry to 'yarn run config' script
[#1313](https://github.com/sharetribe/ftw-daily/pull/1313)
- [change] Add UI support for flexible pricing and privileged
transitions. Note that this requires updating the booking breakdown
estimation code that is now done in the backend.
- [change] Add UI support for flexible pricing and privileged transitions. Note that this requires
updating the booking breakdown estimation code that is now done in the backend.
[#1310](https://github.com/sharetribe/ftw-daily/pull/1310)
- [add] Add local API endpoints for flexible pricing and privileged transitions
[#1301](https://github.com/sharetribe/ftw-daily/pull/1301)
Expand Down
6 changes: 2 additions & 4 deletions ext/transaction-process/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ This is the transaction process that the Flex Template for Web is designed to wo
The `process.edn` file describes the process flow while the `templates` folder contains notification
messages that are used by the process.

Bookings in the process are day-based. Pricing uses privileged transitions and
the
Bookings in the process are day-based. Pricing uses privileged transitions and the
[privileged-set-line-items](https://www.sharetribe.com/docs/references/transaction-process-actions/#actionprivileged-set-line-items)
action. The process has preauthorization and it relies on the provider to accept
booking requests.
action. The process has preauthorization and it relies on the provider to accept booking requests.
8 changes: 5 additions & 3 deletions server/api-util/lineItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const { calculateQuantityFromDates, calculateTotalFromLineItems } = require('./l
const { types } = require('sharetribe-flex-sdk');
const { Money } = types;

const unitType = 'line-item/night';
// This bookingUnitType needs to be one of the following:
// line-item/night, line-item/day or line-item/units
const bookingUnitType = 'line-item/night';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the name so that it's in sync with the config.js variable (in web app).

const PROVIDER_COMMISSION_PERCENTAGE = -10;

/** Returns collection of lineItems (max 50)
Expand Down Expand Up @@ -40,9 +42,9 @@ exports.transactionLineItems = (listing, bookingData) => {
* By default BookingBreakdown prints line items inside LineItemUnknownItemsMaybe if the lineItem code is not recognized. */

const booking = {
code: 'line-item/night',
code: bookingUnitType,
unitPrice,
quantity: calculateQuantityFromDates(startDate, endDate, unitType),
quantity: calculateQuantityFromDates(startDate, endDate, bookingUnitType),
includeFor: ['customer', 'provider'],
};

Expand Down
8 changes: 6 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ const bookingProcessAlias = 'flex-default-process/release-1';
//
// Possible values: ['line-item/night', 'line-item/day', 'line-item/units';]
//
// Note: translations will use different translation keys for night, day or unit
// depending on the value chosen.
// Note 1: This 'bookingUnitType' variable affects only web app.
// If you are using privileged transitions (which is used by the default process),
// you also need to configure unit type in API server: server/api-util/lineItems.js
//
// Note 2: Translations will use different translation keys for night, day or unit
// depending on the value chosen.
const bookingUnitType = 'line-item/night';

// Should the application fetch available time slots (currently defined as
Expand Down
2 changes: 1 addition & 1 deletion src/util/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const stateDescription = {
// id is defined only to support Xstate format.
// However if you have multiple transaction processes defined,
// it is best to keep them in sync with transaction process aliases.
id: 'preauth-with-nightly-booking/release-1',
id: 'flex-default-process/release-1',

// This 'initial' state is a starting point for new transaction
initial: STATE_INITIAL,
Expand Down