1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-02 20:28:38 -04:00

testing: Add initial OFX investment import tests

Also fix up a "bug" caused by financial institutions not deciding on
which sign to use for an OFX field...
This commit is contained in:
2017-11-28 21:25:50 -05:00
parent 238809cd46
commit 30d4515780
3 changed files with 47 additions and 0 deletions

View File

@ -233,6 +233,9 @@ func (i *OFXImport) GetInvBuyTran(buy *ofxgo.InvBuy, curdef *Security, account *
fees.Set(&buy.Fees.Rat)
load.Set(&buy.Load.Rat)
total.Set(&buy.Total.Rat)
if total.Sign() > 0 {
total.Neg(&total)
}
tradingTotal.Neg(&total)
tradingTotal.Sub(&tradingTotal, &commission)
@ -495,6 +498,9 @@ func (i *OFXImport) GetReinvestTran(reinvest *ofxgo.Reinvest, curdef *Security,
fees.Set(&reinvest.Fees.Rat)
load.Set(&reinvest.Load.Rat)
total.Set(&reinvest.Total.Rat)
if total.Sign() > 0 {
total.Neg(&total)
}
tradingTotal.Neg(&total)
tradingTotal.Sub(&tradingTotal, &commission)
@ -694,6 +700,9 @@ func (i *OFXImport) GetInvSellTran(sell *ofxgo.InvSell, curdef *Security, accoun
fees.Set(&sell.Fees.Rat)
load.Set(&sell.Load.Rat)
total.Set(&sell.Total.Rat)
if total.Sign() < 0 {
total.Neg(&total)
}
tradingTotal.Neg(&total)
tradingTotal.Sub(&tradingTotal, &commission)