Skip to content

Commit

Permalink
feat(batch update earnings): set payment comfirmed by field
Browse files Browse the repository at this point in the history
note: this is still work in progress
  • Loading branch information
Mloweedgar committed Jan 25, 2022
1 parent cb7f690 commit 2c52c90
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
15 changes: 13 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"express-async-handler": "^1.1.4",
"express-validator": "^6.4.0",
"joi": "^17.4.2",
"jwt-decode": "^3.1.2",
"knex": "^0.95.11",
"loglevel": "^1.6.8",
"multer": "^1.4.3",
Expand Down
5 changes: 5 additions & 0 deletions server/handlers/earningsHandler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Joi = require('joi');
const jwt_decode = require('jwt-decode');
const csv = require('csvtojson');
const fs = require('fs');
const { v4: uuid } = require('uuid');
Expand Down Expand Up @@ -126,6 +127,8 @@ const earningsBatchPatch = async (req, res, next) => {

const batchUpdateEarnings = (batch_id) => {
let count = 0;
const authorizationHeader = req.get('authorization');
const adminPanelUser = jwt_decode(authorizationHeader);
return new Promise((resolve, reject) => {
csv()
.fromStream(csvReadStream)
Expand All @@ -137,6 +140,8 @@ const earningsBatchPatch = async (req, res, next) => {
await updateEarnings(earningsRepo, {
...json,
batch_id,
payment_confirmation_method: 'batch',
payment_confirmed_by: adminPanelUser?.id,
});
count++;
},
Expand Down

0 comments on commit 2c52c90

Please sign in to comment.