Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

## [v0.504.0]

### Added

- `pay`: `CreditTransfer` now supports a `clearing` code for national bank or branch identifiers such as Danish registration numbers, UK sort codes, and US routing numbers. Its `iban`, `bic`, `number`, and `clearing` identifiers use the flexible `cbc.Code` type; the descriptive bank `name` remains a string.
- `pay`: `IsIBAN` and `IsBIC` rules tests for bank details — the ISO 13616 structure with its ISO 7064 mod 97-10 check digits, and the ISO 9362 structure. Available to rule sets that need them; no core rule applies them.
- `rules/is`: `AllOf` composes several tests into one that passes only when all of them do, alongside the existing `AnyOf` and `OneOf`.
- `fi-finvoice-v3`: approved as an external addon implemented by [`github.com/invopop/gobl.fi.finvoice`](https://github.com/invopop/gobl.fi.finvoice) — Finland's Finvoice 3.0 e-invoicing format. As with other external addons, the module must be imported (`_ "github.com/invopop/gobl.fi.finvoice/addon"`) for documents declaring the key to calculate and validate.
Expand Down
2 changes: 1 addition & 1 deletion bill/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func TestPaymentLegacyMethodMigration(t *testing.T) {
assert.Equal(t, pay.MeansKeyCreditTransfer, pmt.Methods[0].Key)
assert.Equal(t, "Wire transfer from BBVA", pmt.Methods[0].Description)
require.NotNil(t, pmt.Methods[0].CreditTransfer)
assert.Equal(t, "ES1234567890123456789012", pmt.Methods[0].CreditTransfer.IBAN)
assert.Equal(t, cbc.Code("ES1234567890123456789012"), pmt.Methods[0].CreditTransfer.IBAN)
}

func TestPaymentFromToEndpoint(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion data/schemas/head/header.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"from": {
"$ref": "https://gobl.org/draft-0/cbc/uri",
"title": "From",
"description": "From is the URI-form transport address of the envelope's issuer,\ne.g. \"gobl:samlown.example.com\" or\n\"iso6523-actorid-upis::9920:b123123123\"."
"description": "From is the URI-form transport address of the envelope's issuer,\ne.g. \"gobl:invoices.example.com\" or\n\"iso6523-actorid-upis::9920:b123123123\"."
},
"to": {
"$ref": "https://gobl.org/draft-0/cbc/uri",
Expand Down
13 changes: 9 additions & 4 deletions data/schemas/pay/credit-transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@
"pay.CreditTransfer": {
"properties": {
"iban": {
"type": "string",
"$ref": "https://gobl.org/draft-0/cbc/code",
"title": "IBAN",
"description": "International Bank Account Number"
},
"bic": {
"type": "string",
"$ref": "https://gobl.org/draft-0/cbc/code",
"title": "BIC",
"description": "Bank Identifier Code used for international transfers."
},
"number": {
"type": "string",
"$ref": "https://gobl.org/draft-0/cbc/code",
"title": "Number",
"description": "Account number, if IBAN not available."
},
"clearing": {
"$ref": "https://gobl.org/draft-0/cbc/code",
"title": "Clearing Code",
"description": "National bank or branch clearing identifier, such as a Danish registration\nnumber, UK sort code, or US routing number."
},
"name": {
"type": "string",
"title": "Name",
Expand All @@ -35,4 +40,4 @@
"description": "CreditTransfer contains fields that can be used for making payments via a bank transfer or wire."
}
}
}
}
9 changes: 6 additions & 3 deletions pay/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ type DirectDebit struct {
// a bank transfer or wire.
type CreditTransfer struct {
// International Bank Account Number
IBAN string `json:"iban,omitempty" jsonschema:"title=IBAN"`
IBAN cbc.Code `json:"iban,omitempty" jsonschema:"title=IBAN"`
// Bank Identifier Code used for international transfers.
BIC string `json:"bic,omitempty" jsonschema:"title=BIC"`
BIC cbc.Code `json:"bic,omitempty" jsonschema:"title=BIC"`
// Account number, if IBAN not available.
Number string `json:"number,omitempty" jsonschema:"title=Number"`
Number cbc.Code `json:"number,omitempty" jsonschema:"title=Number"`
// National bank or branch clearing identifier, such as a Danish registration
// number, UK sort code, or US routing number.
Clearing cbc.Code `json:"clearing,omitempty" jsonschema:"title=Clearing Code"`
// Name of the bank.
Name string `json:"name,omitempty" jsonschema:"title=Name"`
// Bank office branch address, not normally required.
Expand Down
28 changes: 28 additions & 0 deletions pay/instructions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,34 @@ func TestInstructionsNormalize(t *testing.T) {
})
}

func TestCreditTransferNormalize(t *testing.T) {
ct := &pay.CreditTransfer{
IBAN: " DK50 0040 0440 1162 43 ",
BIC: " DABADKKK ",
Number: " 0440-116243 ",
Clearing: " 1234 ",
Name: "Example Bank",
}

norm.Normalize(ct)

assert.Equal(t, cbc.Code("DK50 0040 0440 1162 43"), ct.IBAN)
assert.Equal(t, cbc.Code("DABADKKK"), ct.BIC)
assert.Equal(t, cbc.Code("0440-116243"), ct.Number)
assert.Equal(t, cbc.Code("1234"), ct.Clearing)
assert.Equal(t, "Example Bank", ct.Name)

data, err := json.Marshal(ct)
require.NoError(t, err)
assert.JSONEq(t, `{
"iban": "DK50 0040 0440 1162 43",
"bic": "DABADKKK",
"number": "0440-116243",
"clearing": "1234",
"name": "Example Bank"
}`, string(data))
}

func TestOnline(t *testing.T) {
instr := &pay.Instructions{
Key: pay.MeansKeyOnline,
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
type Version string

// VERSION is the current version of the GOBL library
const VERSION Version = "v0.503.0"
const VERSION Version = "v0.504.0"

// Semver parses and returns semver
func (v Version) Semver() *semver.Version {
Expand Down
Loading