Add Database Layer and Common/Basic types (sections 5-6)
CI / docker (push) Has been cancelled
CI / build-and-test (push) Has started running

Section 6 — Common & Basic Layers:
- Money value type: Int64 cents, currency-aware arithmetic, ToCurrency
  with double intermediate (deliberate), display formatting for fiat
  (2 decimal) and crypto (6 decimal)
- 16 Basic types matching v6 schema: BasicOrganization (all denormalized
  OOD fields), BasicUser, BasicFinancialAccount (OwnerUserId, native
  currency, bitcoin fields), BasicFinancialTransaction (OrganizationSequenceId,
  BlockchainHash), BasicFinancialTransactionRow (foreign currency, bitcoin
  derivation), BasicExpenseClaim, BasicInboundInvoice, BasicOutboundInvoice,
  BasicPayout, BasicPayment, BasicPaymentGroup, BasicRefund, BasicDocument,
  BasicCurrency, BasicHotWalletAddress, BasicHotWalletUtxo

Section 5 — Database Layer:
- DatabaseConnection: three-tier factory (read/write/admin), Galera-aware,
  MySqlConnector-based
- DatabaseCredentials + DatabaseConfig for appsettings binding
- RepositoryBase: stored proc + text command helpers, parameter binding,
  type-safe reader helpers
- FinancialRepository: accounts, transactions, rows, dependencies,
  balances, budgets, unbalanced tx detection, period closing
- ApArRepository: expense claims, inbound/outbound invoices, payouts
- UserRepository: users, RBAC permissions, role assignment
- OrganizationRepository: orgs with full denormalized settings
- CryptoRepository: hot wallet addresses, UTXOs
- DocumentRepository: document metadata, typed foreign object queries
- CurrencyRepository: currencies, exchange rate snapshots/datapoints
  with micro-BTC scaling awareness
- SupportRepository: mail queue, event queue, system settings, templates

Made-with: Cursor
This commit is contained in:
2026-04-08 16:38:59 +02:00
parent 40eefc6163
commit f9dbb889f9
28 changed files with 1718 additions and 15 deletions
+15 -15
View File
@@ -45,24 +45,24 @@
## 5. Database Layer (UsingCash.Database)
- [ ] 5.1 Implement DatabaseConnection factory with GetForReading(), GetForWriting(), GetForAdmin() — Galera-aware: LAST_INSERT_ID always read on write connection
- [ ] 5.2 Implement RepositoryBase with shared helpers: GetCommand (stored proc), AddParameter, ExecuteScalar, ExecuteReader, ExecuteNonQuery
- [ ] 5.3 Implement FinancialRepository: read methods (GetAccount, GetTransaction, GetTransactionRows, GetRowForeignCurrency, GetAccountsForOrg, GetTransactionsForAccountInRange, GetUnbalancedTransactions, GetBudgets, GetTransactionDependency, GetTransactionFromDependency)
- [ ] 5.4 Implement FinancialRepository: write methods wrapping stored procedures (CreateTransaction, AddRow, SetTag, SetDependency, CreateAccount, SetAccountName, SetAccountClosed, SetBudget, AdvanceClosedThroughYear)
- [ ] 5.5 Implement ApArRepository: read/write for expense claims, inbound/outbound invoices, payouts, payments, refunds
- [ ] 5.6 Implement UserRepository: read/write for users, roles, role assignments, permission lookups, password hash/verify
- [ ] 5.7 Implement OrganizationRepository: read/write for organizations and all denormalized settings
- [ ] 5.8 Implement CryptoRepository: read/write for hot wallet addresses, UTXOs, blockchain transactions
- [ ] 5.9 Implement DocumentRepository: read/write for document metadata and financial account documents
- [ ] 5.10 Implement CurrencyRepository: read/write for currencies, exchange rate snapshots and datapoints (micro-BTC scaling aware)
- [ ] 5.11 Implement SupportRepository: mail queue, mail templates, event queue, system settings
- [x] 5.1 Implement DatabaseConnection factory with GetForReading(), GetForWriting(), GetForAdmin() — Galera-aware: LAST_INSERT_ID always read on write connection
- [x] 5.2 Implement RepositoryBase with shared helpers: GetCommand (stored proc), AddParameter, ExecuteScalar, ExecuteReader, ExecuteNonQuery
- [x] 5.3 Implement FinancialRepository: read methods (GetAccount, GetTransaction, GetTransactionRows, GetRowForeignCurrency, GetAccountsForOrg, GetTransactionsForAccountInRange, GetUnbalancedTransactions, GetBudgets, GetTransactionDependency, GetTransactionFromDependency)
- [x] 5.4 Implement FinancialRepository: write methods wrapping stored procedures (CreateTransaction, AddRow, SetTag, SetDependency, CreateAccount, SetAccountName, SetAccountClosed, SetBudget, AdvanceClosedThroughYear)
- [x] 5.5 Implement ApArRepository: read/write for expense claims, inbound/outbound invoices, payouts, payments, refunds
- [x] 5.6 Implement UserRepository: read/write for users, roles, role assignments, permission lookups, password hash/verify
- [x] 5.7 Implement OrganizationRepository: read/write for organizations and all denormalized settings
- [x] 5.8 Implement CryptoRepository: read/write for hot wallet addresses, UTXOs, blockchain transactions
- [x] 5.9 Implement DocumentRepository: read/write for document metadata and financial account documents
- [x] 5.10 Implement CurrencyRepository: read/write for currencies, exchange rate snapshots and datapoints (micro-BTC scaling aware)
- [x] 5.11 Implement SupportRepository: mail queue, mail templates, event queue, system settings
## 6. Common & Basic Layers
- [ ] 6.1 Port enums to UsingCash.Common: FinancialAccountType, Permission, DocumentType, CryptoChain, ExpenseClaimStatus, InvoiceStatus, PayoutStatus, FinancialDependencyType — trimming governance/geography/membership enums
- [ ] 6.2 Port IHasIdentity interface and shared attributes/interfaces to UsingCash.Common
- [ ] 6.3 Port Basic types: BasicFinancialAccount (with OwnerUserId, NativeCurrencyId), BasicFinancialTransaction (with OrganizationSequenceId, BlockchainHash), BasicFinancialTransactionRow (with ForeignCurrencyCode, ForeignCurrencyAmountCents), BasicCurrency, BasicOrganization (with all denormalized settings), BasicUser, BasicDocument, BasicExpenseClaim, BasicInboundInvoice, BasicOutboundInvoice, BasicPayout, BasicHotWalletAddress, BasicHotWalletUtxo
- [ ] 6.4 Implement Money value type (Int64 Cents, Currency reference, display formatting per currency unit scale, ToCurrency using double intermediate arithmetic)
- [x] 6.1 Port enums to UsingCash.Common: FinancialAccountType, Permission, DocumentType, CryptoChain, ExpenseClaimStatus, InvoiceStatus, PayoutStatus, FinancialDependencyType — trimming governance/geography/membership enums
- [x] 6.2 Port IHasIdentity interface and shared attributes/interfaces to UsingCash.Common
- [x] 6.3 Port Basic types: BasicFinancialAccount (with OwnerUserId, NativeCurrencyId), BasicFinancialTransaction (with OrganizationSequenceId, BlockchainHash), BasicFinancialTransactionRow (with ForeignCurrencyCode, ForeignCurrencyAmountCents), BasicCurrency, BasicOrganization (with all denormalized settings), BasicUser, BasicDocument, BasicExpenseClaim, BasicInboundInvoice, BasicOutboundInvoice, BasicPayout, BasicHotWalletAddress, BasicHotWalletUtxo
- [x] 6.4 Implement Money value type (Int64 Cents, Currency reference, display formatting per currency unit scale, ToCurrency using double intermediate arithmetic)
## 7. Logic Layer (UsingCash.Logic)