Skip to content

Commit

Permalink
Do not include dimension1 from costCentres.
Browse files Browse the repository at this point in the history
Always start from `dimension2`
  • Loading branch information
runely committed Aug 26, 2022
1 parent 4d6f996 commit 426bd10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Update users in `Mytos` based on users from `Visma` which has payed phone from u

`Email`, `EmployeeId` and `Dim*` (where **\*** represents an incrementing number from 1 for all costCentres on a user) will be updated

> `dimension1` from **costCentres** will be ignored as we don't use it. We will use `dimension2` and forward
There can be a maximum of `5` **Dim\*** entries

```json
Expand Down
14 changes: 13 additions & 1 deletion lib/Visma/repack-visma-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ const fixedTransactionPropsToRemove = [
'amount'
]

const costCentresPropsToRemove = [
'dimension1'
]

const repackFixedTransaction = fixedTransaction => {
fixedTransactionPropsToRemove.forEach(prop => {
delete fixedTransaction[prop]
Expand All @@ -62,6 +66,14 @@ const repackFixedTransaction = fixedTransaction => {
return fixedTransaction
}

const repackCostCentres = costCentres => {
costCentresPropsToRemove.forEach(prop => {
delete costCentres[prop]
})

return costCentres
}

const repackPosition = position => {
if (!position.costCentres) return {}
if (!position.fixedTransactions || !position.fixedTransactions.fixedTransaction) return {}
Expand All @@ -71,7 +83,7 @@ const repackPosition = position => {
})

const obj = {
costCentres: position.costCentres
costCentres: repackCostCentres(position.costCentres)
}

if (Array.isArray(position.fixedTransactions.fixedTransaction)) {
Expand Down

0 comments on commit 426bd10

Please sign in to comment.