Files
bank/receiving_test.go
zeekayandHanzo Dev d934daa779 feat: correct receiving details, card-rail transactions, and desktop density
Second polish pass over the dash from the visual sweep — the remaining screens
now carry the data a real bank shows and use the space they have.

Backend:
- Receiving coordinates are currency-correct. The "US IBAN" was wrong — the US
  issues no IBANs. receivingFor derives bank name + ABA routing + account
  number + SWIFT + bank address for US accounts, IBAN + BIC for IBAN markets,
  deterministic per account, exposed as account.receiving. account.iban is now
  empty for US. Dropped the redundant stored iban metadata.
- Card purchases are their own transaction type (`card`) — a debit like a
  payment but on the card rail, so they carry no wire fee and don't route to
  forex (both fall through cleanly). The Cards screen lists these specifically.

Dash:
- Accounts + Send render the full receiving coordinates (one Coordinates
  component, shape chosen by currency), each line copyable — enough to actually
  receive a wire.
- Cards: spend-limits panel (month-to-date debits vs the account ceiling) and a
  card-transaction list, filling the desktop dead space; one column on mobile.
- Exchange: the pair is priced on arrival (rate is a property of the pair, not
  the amount) and recent conversions sit beside the converter.
- Activity: a conversion reads as one movement (both legs on the line) instead
  of two adjacent rows; filtering still splits the legs.
- Wallet: copy button on the full deposit address. Landing hero balance now
  equals the demo account, tile for tile. Named nav landmarks; EMV chip detail.

SDK 1.3.4: Account.receiving typed. e2e up to 29 green (added activity + cards
specs, receiving/landing/exchange/wallet/shell coverage). Backend go
test/vet/staticcheck/deadcode clean.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-23 07:14:13 -07:00

66 lines
1.8 KiB
Go

package bank
import (
"testing"
"github.com/hanzoai/base/core"
"github.com/luxfi/bank/collections"
)
// receivingFor must shape the coordinates to the account's currency: a US
// account settles by routing + account number and carries no IBAN; an IBAN
// market carries an IBAN and no routing. Deterministic in the account id.
func TestReceivingForByCurrency(t *testing.T) {
app := newBankApp(t)
defer app.Cleanup()
col, err := app.FindCollectionByNameOrId(collections.AccountCollectionName)
if err != nil {
t.Fatalf("accounts collection: %v", err)
}
mk := func(currency string) *core.Record {
r := core.NewRecord(col)
r.Set("owner", "u")
r.Set("entityName", "Acme")
r.Set("entityType", "business")
r.Set("country", "US")
r.Set("currency", currency)
r.Set("status", "active")
r.Set("kycStatus", "approved")
r.Set("riskRating", "low")
if err := app.Save(r); err != nil {
t.Fatalf("save account: %v", err)
}
return r
}
usd := receivingFor(mk("USD"))
if usd.RoutingNumber == "" || usd.AccountNumber == "" {
t.Errorf("USD account missing routing/account: %+v", usd)
}
if usd.IBAN != "" {
t.Errorf("US account must not carry an IBAN, got %q", usd.IBAN)
}
if len(usd.RoutingNumber) != 9 {
t.Errorf("routing number = %q, want 9 digits", usd.RoutingNumber)
}
eur := receivingFor(mk("EUR"))
if eur.IBAN == "" {
t.Errorf("EUR account missing IBAN: %+v", eur)
}
if eur.RoutingNumber != "" {
t.Errorf("IBAN-market account must not carry a routing number, got %q", eur.RoutingNumber)
}
if eur.IBAN[:2] != "DE" {
t.Errorf("EUR IBAN country = %q, want DE", eur.IBAN[:2])
}
// Deterministic: same account yields the same coordinates.
a := mk("USD")
first, second := receivingFor(a).AccountNumber, receivingFor(a).AccountNumber
if first != second {
t.Errorf("receivingFor not deterministic: %q != %q", first, second)
}
}