-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution for booking date bug #18 #23
Open
svenjeppsson
wants to merge
8
commits into
mitch000001:master
Choose a base branch
from
svenjeppsson:bookingDateBug
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d29f598
Merge pull request #1 from mitch000001/master
svenjeppsson 9023d26
test: test for booking date bug
3ed485f
fix(swift): fix bookingdate bases correct bookingyear
16bf389
fix: removed debug printlin
svenjeppsson d826d4e
chore: make a tests better readable
c4167b5
fix(swift): test and fix for date century difference
8a3a69c
fix(swift): optimize an fix linting error
aa6e6b3
chore: add .idea to .gitignore
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,66 +153,94 @@ func TestTransactionTagUnmarshal(t *testing.T) { | |
} | ||
|
||
func TestBookingDateBug(t *testing.T) { | ||
|
||
tests := []struct { | ||
testdata string | ||
expectedBookingDate string | ||
today string | ||
balanceStartBookingDateString string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we are already using the dates as |
||
balanceClosingBookingDateString string | ||
bookingDateString string | ||
valutaDateString string | ||
}{ | ||
{ | ||
// Valuta Date 2019-01-01 Booking Date 2018-12-28 | ||
testdata: "\r\n:20:HBCIKTOLST" + "\r\n:25:12345678/1234123456" + | ||
"\r\n:28C:0" + | ||
"\r\n:60F:C181228EUR1234,56" + | ||
"\r\n:61:1901011228DR50,NMSCNONREF" + | ||
"\r\n/OCMT/EUR50,//CHGS/ 0,/" + | ||
"\r\n:86:177?00SB-SEPA-Ueberweisung?20 ?30?31?32Max Maier ?33 ?34000" + | ||
"\r\n:62F:C190125EUR1234,56" + | ||
"\r\n-", | ||
expectedBookingDate: "2018-12-28", | ||
today: "2019-02-10", | ||
bookingDateString: "2018-12-28", | ||
valutaDateString: "2019-01-01", | ||
balanceStartBookingDateString: "2018-12-28", | ||
balanceClosingBookingDateString: "2019-01-25", | ||
}, | ||
// Valuta Date 2019-01-01 Booking Date 2019-01-01 | ||
{ | ||
testdata: "\r\n:20:HBCIKTOLST" + "\r\n:25:12345678/1234123456" + | ||
"\r\n:28C:0" + | ||
"\r\n:60F:C181228EUR1234,56" + | ||
"\r\n:61:1901011228DR50,NMSCNONREF" + | ||
"\r\n/OCMT/EUR50,//CHGS/ 0,/" + | ||
"\r\n:86:177?00SB-SEPA-Ueberweisung?20 ?30?31?32Max Maier ?33 ?34000" + | ||
"\r\n:62F:C190125EUR1234,56" + | ||
"\r\n-", | ||
expectedBookingDate: "2018-12-28", | ||
today: "2019-02-10", | ||
bookingDateString: "2019-01-01", | ||
valutaDateString: "2019-01-01", | ||
balanceStartBookingDateString: "2018-12-28", | ||
balanceClosingBookingDateString: "2019-01-25", | ||
}, { | ||
today: "2019-02-10", | ||
bookingDateString: "2019-01-01", | ||
valutaDateString: "2018-12-28", | ||
balanceStartBookingDateString: "2018-12-28", | ||
balanceClosingBookingDateString: "2019-01-25", | ||
}, { | ||
// Valuta Date 2018-12-28 Booking Date 2019-01-01 (not sure if that can happen ? ) | ||
|
||
testdata: "\r\n:20:HBCIKTOLST" + "\r\n:25:12345678/1234123456" + | ||
"\r\n:28C:0" + | ||
"\r\n:60F:C181228EUR1234,56" + | ||
"\r\n:61:1812280101DR50,NMSCNONREF" + | ||
"\r\n/OCMT/EUR50,//CHGS/ 0,/" + | ||
"\r\n:86:177?00SB-SEPA-Ueberweisung?20 ?30?31?32Max Maier ?33 ?34000" + | ||
"\r\n:62F:C190125EUR1234,56" + | ||
"\r\n-", | ||
expectedBookingDate: "2019-01-01", | ||
today: "2100-02-10", | ||
bookingDateString: "2100-01-01", | ||
valutaDateString: "2099-12-28", | ||
balanceStartBookingDateString: "2099-12-28", | ||
balanceClosingBookingDateString: "2100-01-25", | ||
}, { | ||
today: "2100-02-10", | ||
bookingDateString: "2100-01-01", | ||
valutaDateString: "2100-12-28", | ||
balanceStartBookingDateString: "2099-12-28", | ||
balanceClosingBookingDateString: "2100-01-25", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
mt := &MT940{} | ||
|
||
err := mt.Unmarshal([]byte(test.testdata)) | ||
today, _ := time.Parse("2006-01-02", test.today) | ||
mt.ReferenceDate = today | ||
expectedBookingDate, _ := time.Parse("2006-01-02", test.bookingDateString) | ||
expectedValutaDate, _ := time.Parse("2006-01-02", test.valutaDateString) | ||
expectedBalanceStartBookingDate, _ := time.Parse("2006-01-02", test.balanceStartBookingDateString) | ||
expectedBalanceClosingBookingDate, _ := time.Parse("2006-01-02", test.balanceClosingBookingDateString) | ||
testdata := "\r\n:20:HBCIKTOLST" + "\r\n:25:12345678/1234123456" + | ||
"\r\n:28C:0" + | ||
"\r\n:60F:C" + expectedBalanceStartBookingDate.Format("060102") + "EUR1234,56" + | ||
"\r\n:61:" + expectedValutaDate.Format("060102") + expectedBookingDate.Format("0102") + "DR50,NMSCNONREF" + | ||
"\r\n/OCMT/EUR50,//CHGS/ 0,/" + | ||
"\r\n:86:177?00SB-SEPA-Ueberweisung?20 ?30?31?32Max Maier ?33 ?34000" + | ||
"\r\n:62F:C" + expectedBalanceClosingBookingDate.Format("060102") + "EUR1234,56" + | ||
"\r\n-" | ||
err := mt.Unmarshal([]byte(testdata)) | ||
if err != nil { | ||
t.Log(err) | ||
t.Fail() | ||
} | ||
|
||
if len(mt.Transactions) != 1 { | ||
t.Log("There should be exactly one transaction") | ||
t.Fail() | ||
} | ||
|
||
if test.expectedBookingDate != mt.Transactions[0].Transaction.BookingDate.String() { | ||
if test.bookingDateString != mt.Transactions[0].Transaction.BookingDate.String() { | ||
t.Logf("Booking date should be %s but is %s", test.bookingDateString, mt.Transactions[0].Transaction.BookingDate.String()) | ||
t.Fail() | ||
} | ||
|
||
if test.valutaDateString != mt.Transactions[0].Transaction.ValutaDate.String() { | ||
t.Logf("Valudate date should be %s but is %s", test.valutaDateString, mt.Transactions[0].Transaction.ValutaDate.String()) | ||
t.Fail() | ||
} | ||
|
||
t.Logf("Booking date should be %s but is %s", test.expectedBookingDate, mt.Transactions[0].Transaction.BookingDate.String()) | ||
if test.balanceStartBookingDateString != mt.StartingBalance.BookingDate.String() { | ||
t.Logf("balance start booking date should be %s but is %s", test.balanceStartBookingDateString, mt.StartingBalance.BookingDate.String()) | ||
t.Fail() | ||
} | ||
|
||
if test.balanceClosingBookingDateString != mt.ClosingBalance.BookingDate.String() { | ||
t.Logf("balance closing booking date should be %s but is %s", test.balanceClosingBookingDateString, mt.ClosingBalance.BookingDate.String()) | ||
t.Fail() | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I read it correctly you're using
ReferenceDate
as a way for dependency injection. As the value is always hardcoded totime.Now
atelement.swift.go:30
. What do you think about not exposing it yet and guarding against zero value within theUnmarshal
method atswift/mt940_unmarshaler.go:12
?