Name NLB uploads izpisek_YYYY-MM-DD
Back to the dashed date rename_izpiski.py used, so a statement the script already named is recognised as already there when it is uploaded again, rather than landing as a second copy under the underscored name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -65,7 +65,7 @@ func (p *nlbParser) Parse(path string, acc *config.Account) ([]RawTxn, error) {
|
||||
return parseNLBText(text, p.digits)
|
||||
}
|
||||
|
||||
// StatementName names an izpisek after its statement date, izpisek_YYYY_MM_DD,
|
||||
// StatementName names an izpisek after its statement date, izpisek_YYYY-MM-DD,
|
||||
// so the folder sorts by date and two downloads of one statement collide.
|
||||
func (p *nlbParser) StatementName(path string) (string, error) {
|
||||
text, err := pdfToText(path)
|
||||
@@ -80,7 +80,7 @@ func nlbStatementName(text string) string {
|
||||
if m == nil {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("izpisek_%s_%s_%s", m[3], m[2], m[1])
|
||||
return fmt.Sprintf("izpisek_%s-%s-%s", m[3], m[2], m[1])
|
||||
}
|
||||
|
||||
// parseNLBText holds the whole parser, separated from PDF extraction so it can
|
||||
|
||||
@@ -117,8 +117,8 @@ func TestParseNLBRejectsMalformedLine(t *testing.T) {
|
||||
func TestNLBStatementName(t *testing.T) {
|
||||
header := " IZPISEK 001/2026\n" +
|
||||
" Datum izpiska 31.01.2026 Stran 1\n"
|
||||
if got := nlbStatementName(header + nlbPage); got != "izpisek_2026_01_31" {
|
||||
t.Errorf("name = %q, want izpisek_2026_01_31", got)
|
||||
if got := nlbStatementName(header + nlbPage); got != "izpisek_2026-01-31" {
|
||||
t.Errorf("name = %q, want izpisek_2026-01-31", got)
|
||||
}
|
||||
if got := nlbStatementName(nlbPage); got != "" {
|
||||
t.Errorf("name without a statement date = %q, want none", got)
|
||||
|
||||
Reference in New Issue
Block a user