From 7de6322da86e90e8e2810a3dfafb9508c8d3ae7f Mon Sep 17 00:00:00 2001 From: mloweedgar Date: Sat, 19 Feb 2022 20:09:44 +0300 Subject: [PATCH] feat(meanings model): include captures_count field #11 --- server/models/Earnings.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/server/models/Earnings.js b/server/models/Earnings.js index 9a4dfbd..f977614 100644 --- a/server/models/Earnings.js +++ b/server/models/Earnings.js @@ -4,23 +4,24 @@ const axios = require('axios').default; const stakeholderUrl = `${process.env.TREETRACKER_STAKEHOLDER_API_URL}/stakeholders`; const Earning = async ({ - id, - worker_id, - funder_id, - amount, - currency, - calculated_at, - consolidation_rule_id, - consolidation_period_start, - consolidation_period_end, - payment_confirmation_id, - payment_system, - payment_confirmed_by, - payment_confirmation_method, - payment_confirmed_at, - paid_at, - status, - batch_id, + id, + worker_id, + funder_id, + captures_count, + amount, + currency, + calculated_at, + consolidation_rule_id, + consolidation_period_start, + consolidation_period_end, + payment_confirmation_id, + payment_system, + payment_confirmed_by, + payment_confirmation_method, + payment_confirmed_at, + paid_at, + status, + batch_id, }) => { const consolidation_rule = `CONSOLIDATION_RULE_${consolidation_rule_id}`; const growerResponse = await axios.get(`${stakeholderUrl}?id=${worker_id}`); @@ -29,6 +30,7 @@ const Earning = async ({ return Object.freeze({ id, worker_id, + captures_count, grower: `${growerResponse.data.stakeholders[0]?.first_name} ${growerResponse.data.stakeholders[0]?.last_name}`, funder_id, funder: funderResponse.data.stakeholders[0]?.org_name,