forked from CGM_Public/pretix_original
Improve date format heuristic for bank statement import (#4814)
When dates are ambiguous, use the event's locale to infer whether the day or month comes first. Since regions follow certain date format conventions, this helps make more accurate guesses.
This commit is contained in:
@@ -790,3 +790,33 @@ def test_ignore_by_external_id(env, job):
|
||||
}])
|
||||
with scopes_disabled():
|
||||
assert BankTransaction.objects.count() == 2
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_ambigious_date_without_region(env, job):
|
||||
process_banktransfers(job, [{
|
||||
'payer': 'Karla Kundin',
|
||||
'reference': 'Bestellung DUMMY1Z3AS',
|
||||
'date': '03/05/2016',
|
||||
'amount': '23.00'
|
||||
}])
|
||||
env[2].refresh_from_db()
|
||||
|
||||
with scopes_disabled():
|
||||
assert env[2].payments.last().info_data["date"] == "2016-03-05"
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_ambigious_date_with_region(env, job):
|
||||
env[0].settings.region = "GB"
|
||||
|
||||
process_banktransfers(job, [{
|
||||
'payer': 'Karla Kundin',
|
||||
'reference': 'Bestellung DUMMY1Z3AS',
|
||||
'date': '03/05/2016',
|
||||
'amount': '23.00'
|
||||
}])
|
||||
env[2].refresh_from_db()
|
||||
|
||||
with scopes_disabled():
|
||||
assert env[2].payments.last().info_data["date"] == "2016-05-03"
|
||||
|
||||
@@ -40,3 +40,5 @@ def test_date_formats():
|
||||
|
||||
assert dt == parse_date("2020-07-01")
|
||||
assert dt == parse_date("2020-7-1")
|
||||
|
||||
assert dt == parse_date("01/07/2020", "GB")
|
||||
|
||||
Reference in New Issue
Block a user