Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Phyks
kresus
Commits
e826d5bc
Commit
e826d5bc
authored
Sep 03, 2018
by
Phyks (Lucas Verney)
Browse files
Fix initial amount
parent
0c01bf2d
Pipeline
#72289
failed with stages
in 2 minutes and 20 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
server/lib/accounts-manager.js
View file @
e826d5bc
...
@@ -395,13 +395,14 @@ to be resynced, by an offset of ${balanceOffset}.`);
...
@@ -395,13 +395,14 @@ to be resynced, by an offset of ${balanceOffset}.`);
let
retrievedAccount
=
accounts
.
find
(
acc
=>
acc
.
accountNumber
===
account
.
accountNumber
);
let
retrievedAccount
=
accounts
.
find
(
acc
=>
acc
.
accountNumber
===
account
.
accountNumber
);
if
(
typeof
retrievedAccount
!==
'
undefined
'
)
{
if
(
typeof
retrievedAccount
!==
'
undefined
'
)
{
let
realBalance
=
retrievedAccount
.
initialAmount
;
const
initialBalance
=
account
.
initialAmount
||
0
;
const
realBalance
=
retrievedAccount
.
initialAmount
||
0
;
let
kresusBalance
=
await
account
.
computeBalance
();
let
kresusBalance
=
await
account
.
computeBalance
();
if
(
Math
.
abs
(
realBalance
-
kresusBalance
)
>
0.01
)
{
if
(
Math
.
abs
(
realBalance
-
kresusBalance
)
>
0.01
)
{
log
.
info
(
`Updating balance for account
${
account
.
accountNumber
}
`
);
log
.
info
(
`Updating balance for account
${
account
.
accountNumber
}
`
);
account
.
initialAmount
=
account
.
initialAmount
+
realBalance
-
kresusBalance
;
account
.
initialAmount
=
initialBalance
+
realBalance
-
kresusBalance
;
await
account
.
save
();
await
account
.
save
();
}
}
}
else
{
}
else
{
...
...
server/models/account.js
View file @
e826d5bc
...
@@ -106,7 +106,7 @@ Account.prototype.computeBalance = async function computeBalance() {
...
@@ -106,7 +106,7 @@ Account.prototype.computeBalance = async function computeBalance() {
today
.
isAfter
(
op
.
debitDate
||
op
.
date
,
'
day
'
)
&&
today
.
isAfter
(
op
.
debitDate
||
op
.
date
,
'
day
'
)
&&
(
op
.
type
!==
'
type.deferred_card
'
||
this
.
type
===
'
account-type.card
'
)
(
op
.
type
!==
'
type.deferred_card
'
||
this
.
type
===
'
account-type.card
'
)
)
)
.
reduce
((
sum
,
op
)
=>
sum
+
op
.
amount
,
this
.
initialAmount
);
.
reduce
((
sum
,
op
)
=>
sum
+
op
.
amount
,
this
.
initialAmount
||
0
);
return
Math
.
round
(
s
*
100
)
/
100
;
return
Math
.
round
(
s
*
100
)
/
100
;
};
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment