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

Clarification needed for exchangeOffer price and refundableAmount fields #850

Open
dhoeweling-sqills opened this issue Jan 24, 2025 · 5 comments
Assignees
Labels
improvements New feature or request question Further information is requested
Milestone

Comments

@dhoeweling-sqills
Copy link

dhoeweling-sqills commented Jan 24, 2025

We need clarification on the exchangePrice and refundableAmount fields in the ExchangeOffer object. Our current assumptions are:

  • exchangePrice: The sum of all prices of the bookingParts in the offer.
  • refundableAmount: The actual balance between exchanged bookingParts and new bookingParts, including the fee.
    Calculated as: sum(exchangedBookingParts.price) - sum(newBookingParts.price) - exchangeFee
    • If positive: The customer gets a refund.
    • If negative: The customer has to pay the difference.

Questions

  1. Are our assumptions about exchangePrice and refundableAmount correct?
  2. What is the exact purpose of each field?
  3. How should these fields be used in different scenarios?

Examples

To illustrate our understanding, here are two examples:

Example 1

  • Price for new bookingParts: 100 EUR
  • Price for exchanged bookingParts: 50 EUR
  • Exchange fee: 10 EUR
{
  "exchangeFee": {
    "amount": 1000,
    "currency": "EUR",
    "scale": 2
  },
  "exchangePrice": {
    "amount": 10000,
    "currency": "EUR",
    "scale": 2
  },
  "refundableAmount": {
    "amount": -6000,
    "currency": "EUR",
    "scale": 2
  }
}

Example 2

  • Price for new bookingParts: 100EUR
  • Price for exchanged bookingParts: 150EUR
  • Exchange fee: 10EUR
{
  "exchangeFee": {
    "amount": 1000,
    "currency": "EUR",
    "scale": 2
  },
  "exchangePrice": {
    "amount": 10000,
    "currency": "EUR",
    "scale": 2
  },
  "refundableAmount": {
    "amount": 4000,
    "currency": "EUR",
    "scale": 2
  }
}
@ralfbayer-db ralfbayer-db added the question Further information is requested label Jan 24, 2025
@jspetrak jspetrak moved this to To do in OSDM Specification Jan 24, 2025
@jspetrak jspetrak added this to the 3.5.0 milestone Jan 24, 2025
@pgitips
Copy link

pgitips commented Feb 6, 2025

We made different assumptions in our implementation of exchange flow.
We calculate the same sum(exchangedBookingParts.price) - sum(newBookingParts.price) - exchangeFee.

  • if negative, balance in favor of the purchaser:
    exchangePrice: null amount
    refundableAmount: The balance as a positive amount

  • if positive, balance in favor of the retailer:
    exchangePrice: The balance as a positive amount
    refundableAmount: null amount

The exchangeFee has a clear meaning and is always positive or null.
Each field is always positive.
The prices of all booking parts in the offer can still be calculated by adding all bookingParts price.
We're also interested in a clarification on meanings of this field.

@Linus-Turnit
Copy link
Collaborator

Linus-Turnit commented Feb 7, 2025

Me and Tim suggest this.

  • exchangePrice – The price of all booking parts in the exchangeOffer (including all exchangeFees)
  • exchangeFee – Sum of exchangeFees
  • refundableAmount – When exchanging to something cheaper. This is the amount to pay back to the customer (credit amount)
  • amountToBePaid (new field) – If the user must pay more to do the exchange. This is the amount. (debit amount)

The naming of the new field must be handled by the group. Is customerCost an alternative?

@schlpbch
Copy link
Collaborator

schlpbch commented Feb 7, 2025

Next Step

@schlpbch schlpbch added the improvements New feature or request label Feb 7, 2025
@dhoeweling-sqills
Copy link
Author

I think we can work with this proposal. I just would like it very clearly documented that refundableAmount and amountToBePaid are mutually exclusive, e.g. if the customer is owed money because the exchange is cheaper refundableAmount will be filled with the corresponding value and therefore amountToBePaid must either be empty or 0.

Applied to the examples from above:

Example 1

  • Price for new bookingParts: 100 EUR
  • Price for exchanged bookingParts: 50 EUR
  • Exchange fee: 10 EUR
{
  "exchangeFee": {
    "amount": 1000,
    "currency": "EUR",
    "scale": 2
  },
  "exchangePrice": {
    "amount": 11000,  
    "currency": "EUR",
    "scale": 2
  },
  "refundableAmount": {
    "amount": 0,
    "currency": "EUR",
    "scale": 2
  },
  "amountToBePaid": {
    "amount": 6000,
    "currency": "EUR",
    "scale": 2
  }
}

Example 2

  • Price for new bookingParts: 100EUR
  • Price for exchanged bookingParts: 150EUR
  • Exchange fee: 10EUR
{
  "exchangeFee": {
    "amount": 1000,
    "currency": "EUR",
    "scale": 2
  },
  "exchangePrice": {
    "amount": 11000,
    "currency": "EUR",
    "scale": 2
  },
  "refundableAmount": {
    "amount": 4000,
    "currency": "EUR",
    "scale": 2
  },
  "amountToBePaid": {
    "amount": 0,
    "currency": "EUR",
    "scale": 2
  }
}

@Azurab
Copy link

Azurab commented Feb 7, 2025

PKP has implemented the same approach as @pgitips described above: ExchangeOffer must have exchangePrice (if positive or neutral balance) or refundableAmount (if negative balance), never both.
BTW. amounts are always non-negatives (even for refundableAmount).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvements New feature or request question Further information is requested
Projects
Status: To do
Development

No branches or pull requests

7 participants