1. Question 1 Note: you will have to do part one before part two however, we strongly…
- User
- Question 1
Note: you will have to do part one before part two however, we strongly recommend reading both parts before starting the problem as part two is an extension of part one. All test cases will not pass until both part one and part two are completed.
Part One
Stripe processes charges on behalf of a merchant, takes a fee for processing the charges, and later sends the remaining funds to the merchant. The sending of funds to a merchant is referred to as a "payout". Payouts can only be sent in the currencies of the merchant's bank accounts. Therefore, if the merchant processes charges in a currency that they don't have a bank account for, Stripe has to exchange (FX) the funds to the bank account currency first. For example, my online t- shirt business has expanded from the U.S. to parts of Europe so I allow my European customers to pay in Euro (€). However, I still only have a bank account in U.S. Dollars ($) where Stripe sends me the funds from my business sales. Therefore Stripe will exchange any Euro charges to U.S. Dollars before sending a payout to my U.S. Dollar bank account. Complete the function calculate_payouts: when the parameter part is "part_one" it should print out the total amount the merchant will be paid out per bank account currency, given a list of charges this merchant has processed.
Input
calculate_payouts has the following parameters:
part: a string, dictating which part of the question to do, equal to either "part_one" or "part_two". For this part it will equal "part_one".
bank_account_currencies: an array of strings, representing the currencies the merchant has bank accounts in.
charges: an array of strings, representing charges the merchant has processed on Stripe. Charges will be in chronological order of when they were processed.
Note: depending on the language you choose, the function signature of calculate_payouts may also provide the size of the arrays.
Format of the strings in the array charges
Each value in charges is a comma separated string in the format date, amount, currency where date is in the format YYYY-MM-DD
amount is a whole number in the currency's smallest denomination (every currency in this
question has 2 decimal places)
currency is one of ["CHF", "EUR", "GBP", "USD"]
e.g. "2022-02-13,12050, EUR" represents a charge of €120.50 that was processed on 13th of February 2022.
D
Default bank account
The first element of the bank_account_currencies array is considered the "default" bank account. Any charges in a currency that a merchant does not have a bank account for, they should be converted to the default currency so we can pay them to their default bank account. E.g. I have two bank accounts, one in EUR and one in USD where my default bank account is EUR. If I process a charge in GBP, it will be converted to EUR and paid out to my EUR bank account.
- Assistant