Skip to content

Commit cdfd20c

Browse files
authored
Merge pull request #464 from arpitchaudhari/dev
Resolving merge conflict - Deposit amount calculation logic
2 parents ff9b65b + 3d0408c commit cdfd20c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/services/TeamService.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,11 +1158,12 @@ suggestMembers.schema = Joi.object().keys({
11581158

11591159
/**
11601160
* Calculates total amount
1161-
* @param {Object} body
1161+
* @param {Object} amount
11621162
* @returns {int} totalAmount
11631163
*/
1164-
async function calculateAmount(body) {
1165-
const totalAmount = body.numberOfResources * body.rates * body.durationWeeks;
1164+
async function calculateAmount(amount) {
1165+
let totalAmount = 0;
1166+
_.forEach(amount, amt => totalAmount += amt.numberOfResources * amt.rate * amt.durationWeeks)
11661167
return { totalAmount };
11671168
}
11681169

@@ -1172,8 +1173,9 @@ suggestMembers.schema = Joi.object().keys({
11721173
* @returns {string} paymentIntentToken
11731174
*/
11741175
async function createPayment(totalAmount) {
1176+
const dollarToCents = (totalAmount*100);
11751177
const paymentIntent = await stripe.paymentIntents.create({
1176-
amount: totalAmount,
1178+
amount: dollarToCents,
11771179
currency: config.CURRENCY,
11781180
});
11791181
return { paymentIntentToken: paymentIntent.client_secret };

0 commit comments

Comments
 (0)