Documentation
¶
Index ¶
- Variables
- func ParseDateFormats(dateStr string) (time.Time, error)
- type BankAccount
- type BankAccountFilter
- type BankMatchField
- type BankMatchRule
- type BankMatchRuleFilter
- type BankReconciliation
- type BankRemediationAction
- type BankStatementImport
- type BankTransaction
- type CSVBankAccountRow
- type CSVTransactionRow
- type CreateBankAccountRequest
- type CreateBankMatchRuleRequest
- type CreateReconciliationRequest
- type FollowUpStatus
- type GORMRepository
- func (r *GORMRepository) AddTransactionToReconciliation(ctx context.Context, ...) error
- func (r *GORMRepository) CalculateAccountBalance(ctx context.Context, schemaName, accountID string) (decimal.Decimal, error)
- func (r *GORMRepository) CompleteReconciliation(ctx context.Context, schemaName, tenantID, reconciliationID string) error
- func (r *GORMRepository) CountTransactionsForAccount(ctx context.Context, schemaName, accountID string) (int, error)
- func (r *GORMRepository) CreateBankAccount(ctx context.Context, schemaName string, account *BankAccount) error
- func (r *GORMRepository) CreateBankMatchRule(ctx context.Context, schemaName string, rule *BankMatchRule) error
- func (r *GORMRepository) CreateImportRecord(ctx context.Context, schemaName string, imp *BankStatementImport) error
- func (r *GORMRepository) CreatePaymentFromTransaction(ctx context.Context, schemaName, tenantID, userID string, ...) (string, error)
- func (r *GORMRepository) CreateReconciliation(ctx context.Context, schemaName string, rec *BankReconciliation) error
- func (r *GORMRepository) CreateTransaction(ctx context.Context, schemaName string, t *BankTransaction) error
- func (r *GORMRepository) DeleteBankAccount(ctx context.Context, schemaName, tenantID, accountID string) error
- func (r *GORMRepository) DeleteBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string) error
- func (r *GORMRepository) GetBankAccount(ctx context.Context, schemaName, tenantID, accountID string) (*BankAccount, error)
- func (r *GORMRepository) GetBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string) (*BankMatchRule, error)
- func (r *GORMRepository) GetImportHistory(ctx context.Context, schemaName, tenantID, bankAccountID string) ([]BankStatementImport, error)
- func (r *GORMRepository) GetReconciliation(ctx context.Context, schemaName, tenantID, reconciliationID string) (*BankReconciliation, error)
- func (r *GORMRepository) GetTransaction(ctx context.Context, schemaName, tenantID, transactionID string) (*BankTransaction, error)
- func (r *GORMRepository) IncrementLatestImportMatchedCount(ctx context.Context, schemaName, tenantID, bankAccountID string, ...) error
- func (r *GORMRepository) IsTransactionDuplicate(ctx context.Context, schemaName, tenantID, bankAccountID string, ...) (bool, error)
- func (r *GORMRepository) ListBankAccounts(ctx context.Context, schemaName, tenantID string, filter *BankAccountFilter) ([]BankAccount, error)
- func (r *GORMRepository) ListBankMatchRules(ctx context.Context, schemaName, tenantID string, filter *BankMatchRuleFilter) ([]BankMatchRule, error)
- func (r *GORMRepository) ListPaymentMatchCandidates(ctx context.Context, schemaName, tenantID string, ...) ([]PaymentForMatching, error)
- func (r *GORMRepository) ListReconciliations(ctx context.Context, schemaName, tenantID, bankAccountID string) ([]BankReconciliation, error)
- func (r *GORMRepository) ListTransactions(ctx context.Context, schemaName, tenantID string, filter *TransactionFilter) ([]BankTransaction, error)
- func (r *GORMRepository) MatchTransaction(ctx context.Context, schemaName, tenantID, transactionID, paymentID string) error
- func (r *GORMRepository) UnmatchTransaction(ctx context.Context, schemaName, tenantID, transactionID string) error
- func (r *GORMRepository) UnsetDefaultAccounts(ctx context.Context, schemaName, tenantID string) error
- func (r *GORMRepository) UpdateBankAccount(ctx context.Context, schemaName string, account *BankAccount) error
- func (r *GORMRepository) UpdateBankMatchRule(ctx context.Context, schemaName string, rule *BankMatchRule) error
- func (r *GORMRepository) UpdateTransactionReview(ctx context.Context, schemaName, tenantID, transactionID string, ...) (*BankTransaction, error)
- type ImportBankAccountsRequest
- type ImportBankAccountsResult
- type ImportCSVRequest
- type ImportResult
- type MatchSuggestion
- type MatchTransactionRequest
- type MatcherConfig
- type PaymentForMatching
- type ReconciliationStatus
- type Repository
- type Service
- func (s *Service) AddTransactionToReconciliation(ctx context.Context, ...) error
- func (s *Service) AutoMatchTransactions(ctx context.Context, schemaName, tenantID, bankAccountID string, ...) (int, error)
- func (s *Service) CompleteReconciliation(ctx context.Context, schemaName, tenantID, reconciliationID string) error
- func (s *Service) CreateBankAccount(ctx context.Context, schemaName, tenantID string, ...) (*BankAccount, error)
- func (s *Service) CreateBankMatchRule(ctx context.Context, schemaName, tenantID string, ...) (*BankMatchRule, error)
- func (s *Service) CreatePaymentFromTransaction(ctx context.Context, schemaName, tenantID, userID, transactionID string) (string, error)
- func (s *Service) CreateReconciliation(ctx context.Context, schemaName, tenantID, bankAccountID, userID string, ...) (*BankReconciliation, error)
- func (s *Service) DeleteBankAccount(ctx context.Context, schemaName, tenantID, accountID string) error
- func (s *Service) DeleteBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string) error
- func (s *Service) GetBankAccount(ctx context.Context, schemaName, tenantID, accountID string) (*BankAccount, error)
- func (s *Service) GetBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string) (*BankMatchRule, error)
- func (s *Service) GetImportHistory(ctx context.Context, schemaName, tenantID, bankAccountID string) ([]BankStatementImport, error)
- func (s *Service) GetMatchSuggestions(ctx context.Context, schemaName, tenantID, transactionID string) ([]MatchSuggestion, error)
- func (s *Service) GetReconciliation(ctx context.Context, schemaName, tenantID, reconciliationID string) (*BankReconciliation, error)
- func (s *Service) GetTransaction(ctx context.Context, schemaName, tenantID, transactionID string) (*BankTransaction, error)
- func (s *Service) ImportBankAccounts(ctx context.Context, schemaName, tenantID string, ...) (*ImportBankAccountsResult, error)
- func (s *Service) ImportTransactions(ctx context.Context, schemaName, tenantID, bankAccountID string, ...) (*ImportResult, error)
- func (s *Service) ListBankAccounts(ctx context.Context, schemaName, tenantID string, filter *BankAccountFilter) ([]BankAccount, error)
- func (s *Service) ListBankMatchRules(ctx context.Context, schemaName, tenantID string, filter *BankMatchRuleFilter) ([]BankMatchRule, error)
- func (s *Service) ListReconciliations(ctx context.Context, schemaName, tenantID, bankAccountID string) ([]BankReconciliation, error)
- func (s *Service) ListTransactions(ctx context.Context, schemaName, tenantID string, filter *TransactionFilter) ([]BankTransaction, error)
- func (s *Service) MatchTransaction(ctx context.Context, schemaName, tenantID, transactionID, paymentID string) error
- func (s *Service) UnmatchTransaction(ctx context.Context, schemaName, tenantID, transactionID string) error
- func (s *Service) UpdateBankAccount(ctx context.Context, schemaName, tenantID, accountID string, ...) (*BankAccount, error)
- func (s *Service) UpdateBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string, ...) (*BankMatchRule, error)
- func (s *Service) UpdateTransactionReview(ctx context.Context, schemaName, tenantID, transactionID, reviewerID string, ...) (*BankTransaction, error)
- type TransactionFilter
- type TransactionReviewUpdate
- type TransactionStatus
- type UpdateBankAccountRequest
- type UpdateBankMatchRuleRequest
- type UpdateTransactionReviewRequest
Constants ¶
This section is empty.
Variables ¶
var ( ErrBankAccountNotFound = fmt.Errorf("bank account not found") ErrTransactionNotFound = fmt.Errorf("transaction not found") ErrReconciliationNotFound = fmt.Errorf("reconciliation not found") ErrAccountHasTransactions = fmt.Errorf("cannot delete bank account with transactions") ErrTransactionAlreadyMatched = fmt.Errorf("transaction not found or already matched") ErrTransactionNotMatched = fmt.Errorf("transaction not found or not matched") ErrReconciliationAlreadyDone = fmt.Errorf("reconciliation not found or already completed") ErrBankMatchRuleNotFound = fmt.Errorf("bank match rule not found") )
Functions ¶
Types ¶
type BankAccount ¶
type BankAccount struct {
ID string `json:"id"`
TenantID string `json:"tenant_id"`
Name string `json:"name"`
AccountNumber string `json:"account_number"`
BankName string `json:"bank_name,omitempty"`
SwiftCode string `json:"swift_code,omitempty"`
Currency string `json:"currency"`
GLAccountID *string `json:"gl_account_id,omitempty"`
IsDefault bool `json:"is_default"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
Balance decimal.Decimal `json:"balance,omitempty"` // Calculated field
}
BankAccount represents a bank account
type BankAccountFilter ¶
BankAccountFilter provides filtering options for bank accounts
type BankMatchField ¶
type BankMatchField string
BankMatchField defines the transaction field inspected by a bank match rule.
const ( BankMatchFieldDescription BankMatchField = "DESCRIPTION" BankMatchFieldReference BankMatchField = "REFERENCE" BankMatchFieldCounterpartyName BankMatchField = "COUNTERPARTY_NAME" BankMatchFieldCounterpartyAccount BankMatchField = "COUNTERPARTY_ACCOUNT" )
func NormalizeBankMatchField ¶
func NormalizeBankMatchField(value string) (BankMatchField, error)
NormalizeBankMatchField validates and normalizes a bank match field.
type BankMatchRule ¶
type BankMatchRule struct {
ID string `json:"id"`
TenantID string `json:"tenant_id"`
BankAccountID *string `json:"bank_account_id,omitempty"`
Name string `json:"name"`
Priority int `json:"priority"`
MatchField BankMatchField `json:"match_field"`
Pattern string `json:"pattern"`
MinConfidence float64 `json:"min_confidence"`
MaxDateDiffDays int `json:"max_date_diff_days"`
RequireExactAmount bool `json:"require_exact_amount"`
IsActive bool `json:"is_active"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
BankMatchRule tunes automatic matching for transactions that match a pattern.
type BankMatchRuleFilter ¶
BankMatchRuleFilter provides filtering options for auto-match rules.
type BankReconciliation ¶
type BankReconciliation struct {
ID string `json:"id"`
TenantID string `json:"tenant_id"`
BankAccountID string `json:"bank_account_id"`
StatementDate time.Time `json:"statement_date"`
OpeningBalance decimal.Decimal `json:"opening_balance"`
ClosingBalance decimal.Decimal `json:"closing_balance"`
Status ReconciliationStatus `json:"status"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
CreatedBy string `json:"created_by"`
}
BankReconciliation represents a reconciliation session
type BankRemediationAction ¶
type BankRemediationAction struct {
Code string `json:"code"`
Severity string `json:"severity"`
Scope string `json:"scope"`
OwnerRole string `json:"owner_role"`
WorkspaceQueue string `json:"workspace_queue,omitempty"`
AssignmentKey string `json:"assignment_key,omitempty"`
Priority string `json:"priority,omitempty"`
DueInDays int `json:"due_in_days,omitempty"`
Message string `json:"message"`
Action string `json:"action"`
EntityType string `json:"entity_type,omitempty"`
EntityID string `json:"entity_id,omitempty"`
BankAccountID string `json:"bank_account_id,omitempty"`
TransactionStatus string `json:"transaction_status,omitempty"`
FollowUpStatus string `json:"follow_up_status,omitempty"`
UIPath string `json:"ui_path,omitempty"`
CLICommand string `json:"cli_command,omitempty"`
}
BankRemediationAction describes one operator action for bank transaction follow-up.
func BuildBankRemediationActions ¶
func BuildBankRemediationActions(transaction *BankTransaction) []BankRemediationAction
BuildBankRemediationActions turns bank transaction state into accountant follow-up actions.
type BankStatementImport ¶
type BankStatementImport struct {
ID string `json:"id"`
TenantID string `json:"tenant_id"`
BankAccountID string `json:"bank_account_id"`
FileName string `json:"file_name"`
TransactionsImported int `json:"transactions_imported"`
TransactionsMatched int `json:"transactions_matched"`
DuplicatesSkipped int `json:"duplicates_skipped"`
CreatedAt time.Time `json:"created_at"`
}
BankStatementImport tracks an import session
type BankTransaction ¶
type BankTransaction struct {
ID string `json:"id"`
TenantID string `json:"tenant_id"`
BankAccountID string `json:"bank_account_id"`
TransactionDate time.Time `json:"transaction_date"`
ValueDate *time.Time `json:"value_date,omitempty"`
Amount decimal.Decimal `json:"amount"`
Currency string `json:"currency"`
Description string `json:"description,omitempty"`
Reference string `json:"reference,omitempty"`
CounterpartyName string `json:"counterparty_name,omitempty"`
CounterpartyAccount string `json:"counterparty_account,omitempty"`
Status TransactionStatus `json:"status"`
FollowUpStatus FollowUpStatus `json:"follow_up_status"`
ReviewNote string `json:"review_note,omitempty"`
ReviewedBy *string `json:"reviewed_by,omitempty"`
ReviewedAt *time.Time `json:"reviewed_at,omitempty"`
MatchedPaymentID *string `json:"matched_payment_id,omitempty"`
JournalEntryID *string `json:"journal_entry_id,omitempty"`
ReconciliationID *string `json:"reconciliation_id,omitempty"`
ImportedAt time.Time `json:"imported_at"`
ExternalID string `json:"external_id,omitempty"`
RemediationActions []BankRemediationAction `json:"remediation_actions,omitempty"`
}
BankTransaction represents an imported bank transaction
type CSVBankAccountRow ¶
type CSVBankAccountRow struct {
Name string `json:"name"`
AccountNumber string `json:"account_number"`
BankName string `json:"bank_name,omitempty"`
SwiftCode string `json:"swift_code,omitempty"`
Currency string `json:"currency,omitempty"`
GLAccountID string `json:"gl_account_id,omitempty"`
GLAccountCode string `json:"gl_account_code,omitempty"`
IsDefault string `json:"is_default,omitempty"`
IsActive string `json:"is_active,omitempty"`
}
CSVBankAccountRow represents a bank account row in CSV import payloads.
func ParseBankAccountCSVRows ¶
func ParseBankAccountCSVRows(content string) ([]CSVBankAccountRow, error)
type CSVTransactionRow ¶
type CSVTransactionRow struct {
Date string `json:"date"`
ValueDate string `json:"value_date,omitempty"`
Amount string `json:"amount"`
Currency string `json:"currency,omitempty"`
SourceAccount string `json:"source_account,omitempty"`
Description string `json:"description"`
Reference string `json:"reference,omitempty"`
CounterpartyName string `json:"counterparty_name,omitempty"`
CounterpartyAccount string `json:"counterparty_account,omitempty"`
ExternalID string `json:"external_id,omitempty"`
}
CSVTransactionRow represents a row in the CSV import
type CreateBankAccountRequest ¶
type CreateBankAccountRequest struct {
Name string `json:"name"`
AccountNumber string `json:"account_number"`
BankName string `json:"bank_name,omitempty"`
SwiftCode string `json:"swift_code,omitempty"`
Currency string `json:"currency,omitempty"`
GLAccountID *string `json:"gl_account_id,omitempty"`
IsDefault bool `json:"is_default"`
IsActive *bool `json:"is_active,omitempty"`
}
CreateBankAccountRequest is the request to create a bank account
type CreateBankMatchRuleRequest ¶
type CreateBankMatchRuleRequest struct {
BankAccountID *string `json:"bank_account_id,omitempty"`
Name string `json:"name"`
Priority int `json:"priority,omitempty"`
MatchField BankMatchField `json:"match_field,omitempty"`
Pattern string `json:"pattern"`
MinConfidence float64 `json:"min_confidence,omitempty"`
MaxDateDiffDays int `json:"max_date_diff_days,omitempty"`
RequireExactAmount bool `json:"require_exact_amount,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
}
CreateBankMatchRuleRequest is the request to create a bank auto-match rule.
type CreateReconciliationRequest ¶
type CreateReconciliationRequest struct {
StatementDate string `json:"statement_date"`
OpeningBalance decimal.Decimal `json:"opening_balance"`
ClosingBalance decimal.Decimal `json:"closing_balance"`
}
CreateReconciliationRequest is the request to start a reconciliation
type FollowUpStatus ¶
type FollowUpStatus string
FollowUpStatus represents accountant follow-up guidance on a bank transaction.
const ( FollowUpNone FollowUpStatus = "NONE" FollowUpEvidenceRequired FollowUpStatus = "EVIDENCE_REQUIRED" FollowUpReadyToMatch FollowUpStatus = "READY_TO_MATCH" )
func NormalizeFollowUpStatus ¶
func NormalizeFollowUpStatus(value string) (FollowUpStatus, error)
NormalizeFollowUpStatus validates and normalizes a follow-up status value.
type GORMRepository ¶
type GORMRepository struct {
// contains filtered or unexported fields
}
GORMRepository implements Repository using GORM
func NewGORMRepository ¶
func NewGORMRepository(db *gorm.DB) *GORMRepository
NewGORMRepository creates a new GORM banking repository
func (*GORMRepository) AddTransactionToReconciliation ¶
func (r *GORMRepository) AddTransactionToReconciliation(ctx context.Context, schemaName, tenantID, transactionID, reconciliationID string) error
AddTransactionToReconciliation adds a transaction to a reconciliation session
func (*GORMRepository) CalculateAccountBalance ¶
func (r *GORMRepository) CalculateAccountBalance(ctx context.Context, schemaName, accountID string) (decimal.Decimal, error)
CalculateAccountBalance calculates the balance of an account
func (*GORMRepository) CompleteReconciliation ¶
func (r *GORMRepository) CompleteReconciliation(ctx context.Context, schemaName, tenantID, reconciliationID string) error
CompleteReconciliation marks a reconciliation as complete
func (*GORMRepository) CountTransactionsForAccount ¶
func (r *GORMRepository) CountTransactionsForAccount(ctx context.Context, schemaName, accountID string) (int, error)
CountTransactionsForAccount counts transactions for an account
func (*GORMRepository) CreateBankAccount ¶
func (r *GORMRepository) CreateBankAccount(ctx context.Context, schemaName string, account *BankAccount) error
CreateBankAccount inserts a new bank account
func (*GORMRepository) CreateBankMatchRule ¶
func (r *GORMRepository) CreateBankMatchRule(ctx context.Context, schemaName string, rule *BankMatchRule) error
CreateBankMatchRule inserts a bank auto-match rule.
func (*GORMRepository) CreateImportRecord ¶
func (r *GORMRepository) CreateImportRecord(ctx context.Context, schemaName string, imp *BankStatementImport) error
CreateImportRecord creates an import record
func (*GORMRepository) CreatePaymentFromTransaction ¶
func (r *GORMRepository) CreatePaymentFromTransaction(ctx context.Context, schemaName, tenantID, userID string, transaction *BankTransaction) (string, error)
CreatePaymentFromTransaction creates a payment and atomically matches the bank transaction to it.
func (*GORMRepository) CreateReconciliation ¶
func (r *GORMRepository) CreateReconciliation(ctx context.Context, schemaName string, rec *BankReconciliation) error
CreateReconciliation inserts a new reconciliation
func (*GORMRepository) CreateTransaction ¶
func (r *GORMRepository) CreateTransaction(ctx context.Context, schemaName string, t *BankTransaction) error
CreateTransaction inserts a new bank transaction
func (*GORMRepository) DeleteBankAccount ¶
func (r *GORMRepository) DeleteBankAccount(ctx context.Context, schemaName, tenantID, accountID string) error
DeleteBankAccount deletes a bank account
func (*GORMRepository) DeleteBankMatchRule ¶
func (r *GORMRepository) DeleteBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string) error
DeleteBankMatchRule deletes a bank auto-match rule.
func (*GORMRepository) GetBankAccount ¶
func (r *GORMRepository) GetBankAccount(ctx context.Context, schemaName, tenantID, accountID string) (*BankAccount, error)
GetBankAccount retrieves a bank account by ID
func (*GORMRepository) GetBankMatchRule ¶
func (r *GORMRepository) GetBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string) (*BankMatchRule, error)
GetBankMatchRule retrieves a bank auto-match rule by ID.
func (*GORMRepository) GetImportHistory ¶
func (r *GORMRepository) GetImportHistory(ctx context.Context, schemaName, tenantID, bankAccountID string) ([]BankStatementImport, error)
GetImportHistory retrieves import history for a bank account
func (*GORMRepository) GetReconciliation ¶
func (r *GORMRepository) GetReconciliation(ctx context.Context, schemaName, tenantID, reconciliationID string) (*BankReconciliation, error)
GetReconciliation retrieves a reconciliation by ID
func (*GORMRepository) GetTransaction ¶
func (r *GORMRepository) GetTransaction(ctx context.Context, schemaName, tenantID, transactionID string) (*BankTransaction, error)
GetTransaction retrieves a single bank transaction
func (*GORMRepository) IncrementLatestImportMatchedCount ¶
func (r *GORMRepository) IncrementLatestImportMatchedCount(ctx context.Context, schemaName, tenantID, bankAccountID string, matchedCount int) error
IncrementLatestImportMatchedCount increments the latest import's matched transaction count.
func (*GORMRepository) IsTransactionDuplicate ¶
func (r *GORMRepository) IsTransactionDuplicate(ctx context.Context, schemaName, tenantID, bankAccountID string, date time.Time, amount decimal.Decimal, externalID string) (bool, error)
IsTransactionDuplicate checks if a transaction is a duplicate
func (*GORMRepository) ListBankAccounts ¶
func (r *GORMRepository) ListBankAccounts(ctx context.Context, schemaName, tenantID string, filter *BankAccountFilter) ([]BankAccount, error)
ListBankAccounts lists all bank accounts for a tenant
func (*GORMRepository) ListBankMatchRules ¶
func (r *GORMRepository) ListBankMatchRules(ctx context.Context, schemaName, tenantID string, filter *BankMatchRuleFilter) ([]BankMatchRule, error)
ListBankMatchRules lists bank auto-match rules for a tenant.
func (*GORMRepository) ListPaymentMatchCandidates ¶
func (r *GORMRepository) ListPaymentMatchCandidates(ctx context.Context, schemaName, tenantID string, paymentType payments.PaymentType, amount decimal.Decimal, limit int) ([]PaymentForMatching, error)
ListPaymentMatchCandidates returns unallocated payments that can be matched to a bank transaction.
func (*GORMRepository) ListReconciliations ¶
func (r *GORMRepository) ListReconciliations(ctx context.Context, schemaName, tenantID, bankAccountID string) ([]BankReconciliation, error)
ListReconciliations lists reconciliations for a bank account
func (*GORMRepository) ListTransactions ¶
func (r *GORMRepository) ListTransactions(ctx context.Context, schemaName, tenantID string, filter *TransactionFilter) ([]BankTransaction, error)
ListTransactions lists bank transactions with filters
func (*GORMRepository) MatchTransaction ¶
func (r *GORMRepository) MatchTransaction(ctx context.Context, schemaName, tenantID, transactionID, paymentID string) error
MatchTransaction matches a bank transaction to a payment
func (*GORMRepository) UnmatchTransaction ¶
func (r *GORMRepository) UnmatchTransaction(ctx context.Context, schemaName, tenantID, transactionID string) error
UnmatchTransaction removes the match from a bank transaction
func (*GORMRepository) UnsetDefaultAccounts ¶
func (r *GORMRepository) UnsetDefaultAccounts(ctx context.Context, schemaName, tenantID string) error
UnsetDefaultAccounts unsets all default accounts for a tenant
func (*GORMRepository) UpdateBankAccount ¶
func (r *GORMRepository) UpdateBankAccount(ctx context.Context, schemaName string, account *BankAccount) error
UpdateBankAccount updates a bank account
func (*GORMRepository) UpdateBankMatchRule ¶
func (r *GORMRepository) UpdateBankMatchRule(ctx context.Context, schemaName string, rule *BankMatchRule) error
UpdateBankMatchRule updates a bank auto-match rule.
func (*GORMRepository) UpdateTransactionReview ¶
func (r *GORMRepository) UpdateTransactionReview(ctx context.Context, schemaName, tenantID, transactionID string, update TransactionReviewUpdate) (*BankTransaction, error)
UpdateTransactionReview updates accountant follow-up guidance for a bank transaction.
type ImportBankAccountsRequest ¶
type ImportBankAccountsRequest struct {
FileName string `json:"file_name,omitempty"`
Rows []CSVBankAccountRow `json:"rows"`
SkipDuplicates bool `json:"skip_duplicates"`
}
ImportBankAccountsRequest is the request to import bank account master data.
type ImportBankAccountsResult ¶
type ImportBankAccountsResult struct {
FileName string `json:"file_name"`
RowsProcessed int `json:"rows_processed"`
AccountsImported int `json:"accounts_imported"`
RowsSkipped int `json:"rows_skipped"`
Errors []string `json:"errors,omitempty"`
}
ImportBankAccountsResult is the result of a bank account import.
type ImportCSVRequest ¶
type ImportCSVRequest struct {
FileName string `json:"file_name,omitempty"`
CSVContent string `json:"csv_content,omitempty"`
Format string `json:"format,omitempty"`
Transactions []CSVTransactionRow `json:"transactions,omitempty"`
SkipDuplicates bool `json:"skip_duplicates"`
}
ImportCSVRequest is the request to import bank transactions from raw statement content or already normalized rows. Format supports auto, generic, lhv, camt053, and lhv-camt.
type ImportResult ¶
type ImportResult struct {
ImportID string `json:"import_id"`
TransactionsImported int `json:"transactions_imported"`
TransactionsMatched int `json:"transactions_matched"`
DuplicatesSkipped int `json:"duplicates_skipped"`
Errors []string `json:"errors,omitempty"`
}
ImportResult is the result of a CSV import
type MatchSuggestion ¶
type MatchSuggestion struct {
PaymentID string `json:"payment_id"`
PaymentNumber string `json:"payment_number"`
PaymentDate time.Time `json:"payment_date"`
Amount decimal.Decimal `json:"amount"`
ContactName string `json:"contact_name,omitempty"`
Reference string `json:"reference,omitempty"`
Confidence float64 `json:"confidence"` // 0.0 - 1.0
MatchReason string `json:"match_reason"`
}
MatchSuggestion represents a suggested match between bank transaction and payment
type MatchTransactionRequest ¶
type MatchTransactionRequest struct {
PaymentID string `json:"payment_id"`
}
MatchTransactionRequest is the request to match a transaction
type MatcherConfig ¶
type MatcherConfig struct {
// ExactAmountBonus is the confidence boost for exact amount matches
ExactAmountBonus float64
// DateProximityWeight is how much date proximity affects confidence
DateProximityWeight float64
// ReferenceMatchWeight is how much reference matching affects confidence
ReferenceMatchWeight float64
// NameMatchWeight is how much counterparty name matching affects confidence
NameMatchWeight float64
// MinConfidence is the minimum confidence to return a suggestion
MinConfidence float64
// MaxDateDiff is the maximum days difference to consider a match
MaxDateDiff int
}
MatcherConfig configures the matching algorithm
func DefaultMatcherConfig ¶
func DefaultMatcherConfig() MatcherConfig
DefaultMatcherConfig returns sensible default matching configuration
type PaymentForMatching ¶
type PaymentForMatching struct {
ID string
PaymentNumber string
PaymentDate time.Time
Amount decimal.Decimal
ContactName string
Reference string
}
PaymentForMatching is the payment data needed for matching
type ReconciliationStatus ¶
type ReconciliationStatus string
ReconciliationStatus represents the status of a reconciliation session
const ( ReconciliationInProgress ReconciliationStatus = "IN_PROGRESS" ReconciliationCompleted ReconciliationStatus = "COMPLETED" )
type Repository ¶
type Repository interface {
CreateBankAccount(ctx context.Context, schemaName string, account *BankAccount) error
GetBankAccount(ctx context.Context, schemaName, tenantID, accountID string) (*BankAccount, error)
ListBankAccounts(ctx context.Context, schemaName, tenantID string, filter *BankAccountFilter) ([]BankAccount, error)
UpdateBankAccount(ctx context.Context, schemaName string, account *BankAccount) error
DeleteBankAccount(ctx context.Context, schemaName, tenantID, accountID string) error
UnsetDefaultAccounts(ctx context.Context, schemaName, tenantID string) error
CountTransactionsForAccount(ctx context.Context, schemaName, accountID string) (int, error)
CalculateAccountBalance(ctx context.Context, schemaName, accountID string) (decimal.Decimal, error)
CreateBankMatchRule(ctx context.Context, schemaName string, rule *BankMatchRule) error
GetBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string) (*BankMatchRule, error)
ListBankMatchRules(ctx context.Context, schemaName, tenantID string, filter *BankMatchRuleFilter) ([]BankMatchRule, error)
UpdateBankMatchRule(ctx context.Context, schemaName string, rule *BankMatchRule) error
DeleteBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string) error
ListTransactions(ctx context.Context, schemaName, tenantID string, filter *TransactionFilter) ([]BankTransaction, error)
GetTransaction(ctx context.Context, schemaName, tenantID, transactionID string) (*BankTransaction, error)
ListPaymentMatchCandidates(ctx context.Context, schemaName, tenantID string, paymentType payments.PaymentType, amount decimal.Decimal, limit int) ([]PaymentForMatching, error)
MatchTransaction(ctx context.Context, schemaName, tenantID, transactionID, paymentID string) error
UnmatchTransaction(ctx context.Context, schemaName, tenantID, transactionID string) error
UpdateTransactionReview(ctx context.Context, schemaName, tenantID, transactionID string, update TransactionReviewUpdate) (*BankTransaction, error)
CreateTransaction(ctx context.Context, schemaName string, t *BankTransaction) error
CreatePaymentFromTransaction(ctx context.Context, schemaName, tenantID, userID string, transaction *BankTransaction) (string, error)
IsTransactionDuplicate(ctx context.Context, schemaName, tenantID, bankAccountID string, date time.Time, amount decimal.Decimal, externalID string) (bool, error)
CreateReconciliation(ctx context.Context, schemaName string, r *BankReconciliation) error
GetReconciliation(ctx context.Context, schemaName, tenantID, reconciliationID string) (*BankReconciliation, error)
ListReconciliations(ctx context.Context, schemaName, tenantID, bankAccountID string) ([]BankReconciliation, error)
CompleteReconciliation(ctx context.Context, schemaName, tenantID, reconciliationID string) error
AddTransactionToReconciliation(ctx context.Context, schemaName, tenantID, transactionID, reconciliationID string) error
CreateImportRecord(ctx context.Context, schemaName string, imp *BankStatementImport) error
IncrementLatestImportMatchedCount(ctx context.Context, schemaName, tenantID, bankAccountID string, matchedCount int) error
GetImportHistory(ctx context.Context, schemaName, tenantID, bankAccountID string) ([]BankStatementImport, error)
}
Repository defines the contract for banking data access.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides bank reconciliation operations
func NewService ¶
NewService creates a new banking service
func NewServiceWithGORM ¶
NewServiceWithGORM creates a banking service backed by an existing GORM handle.
func NewServiceWithRepository ¶
func NewServiceWithRepository(repo Repository) *Service
NewServiceWithRepository creates a new banking service with a custom repository
func NewServiceWithRepositoryAndAccounting ¶
func NewServiceWithRepositoryAndAccounting(repo Repository, accounts accountingLister) *Service
NewServiceWithRepositoryAndAccounting creates a new banking service with a custom repository and accounting account lister.
func (*Service) AddTransactionToReconciliation ¶
func (s *Service) AddTransactionToReconciliation(ctx context.Context, schemaName, tenantID, transactionID, reconciliationID string) error
AddTransactionToReconciliation adds a transaction to a reconciliation session
func (*Service) AutoMatchTransactions ¶
func (s *Service) AutoMatchTransactions(ctx context.Context, schemaName, tenantID, bankAccountID string, minConfidence float64) (int, error)
AutoMatchTransactions attempts to auto-match unmatched transactions
func (*Service) CompleteReconciliation ¶
func (s *Service) CompleteReconciliation(ctx context.Context, schemaName, tenantID, reconciliationID string) error
CompleteReconciliation marks a reconciliation as complete
func (*Service) CreateBankAccount ¶
func (s *Service) CreateBankAccount(ctx context.Context, schemaName, tenantID string, req *CreateBankAccountRequest) (*BankAccount, error)
CreateBankAccount creates a new bank account
func (*Service) CreateBankMatchRule ¶
func (s *Service) CreateBankMatchRule(ctx context.Context, schemaName, tenantID string, req *CreateBankMatchRuleRequest) (*BankMatchRule, error)
CreateBankMatchRule creates a bank auto-match rule.
func (*Service) CreatePaymentFromTransaction ¶
func (s *Service) CreatePaymentFromTransaction(ctx context.Context, schemaName, tenantID, userID, transactionID string) (string, error)
CreatePaymentFromTransaction creates a new payment from a bank transaction
func (*Service) CreateReconciliation ¶
func (s *Service) CreateReconciliation(ctx context.Context, schemaName, tenantID, bankAccountID, userID string, req *CreateReconciliationRequest) (*BankReconciliation, error)
CreateReconciliation starts a new reconciliation session
func (*Service) DeleteBankAccount ¶
func (s *Service) DeleteBankAccount(ctx context.Context, schemaName, tenantID, accountID string) error
DeleteBankAccount deletes a bank account (only if no transactions)
func (*Service) DeleteBankMatchRule ¶
func (s *Service) DeleteBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string) error
DeleteBankMatchRule deletes a bank auto-match rule.
func (*Service) GetBankAccount ¶
func (s *Service) GetBankAccount(ctx context.Context, schemaName, tenantID, accountID string) (*BankAccount, error)
GetBankAccount retrieves a bank account by ID
func (*Service) GetBankMatchRule ¶
func (s *Service) GetBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string) (*BankMatchRule, error)
GetBankMatchRule retrieves a bank auto-match rule.
func (*Service) GetImportHistory ¶
func (s *Service) GetImportHistory(ctx context.Context, schemaName, tenantID, bankAccountID string) ([]BankStatementImport, error)
GetImportHistory retrieves import history for a bank account
func (*Service) GetMatchSuggestions ¶
func (s *Service) GetMatchSuggestions(ctx context.Context, schemaName, tenantID, transactionID string) ([]MatchSuggestion, error)
GetMatchSuggestions finds potential payment matches for a bank transaction
func (*Service) GetReconciliation ¶
func (s *Service) GetReconciliation(ctx context.Context, schemaName, tenantID, reconciliationID string) (*BankReconciliation, error)
GetReconciliation retrieves a reconciliation by ID
func (*Service) GetTransaction ¶
func (s *Service) GetTransaction(ctx context.Context, schemaName, tenantID, transactionID string) (*BankTransaction, error)
GetTransaction retrieves a single bank transaction
func (*Service) ImportBankAccounts ¶
func (s *Service) ImportBankAccounts(ctx context.Context, schemaName, tenantID string, req *ImportBankAccountsRequest) (*ImportBankAccountsResult, error)
ImportBankAccounts imports bank account master data from parsed CSV rows.
func (*Service) ImportTransactions ¶
func (s *Service) ImportTransactions(ctx context.Context, schemaName, tenantID, bankAccountID string, req *ImportCSVRequest) (*ImportResult, error)
ImportTransactions imports pre-parsed bank statement transactions.
func (*Service) ListBankAccounts ¶
func (s *Service) ListBankAccounts(ctx context.Context, schemaName, tenantID string, filter *BankAccountFilter) ([]BankAccount, error)
ListBankAccounts lists all bank accounts for a tenant
func (*Service) ListBankMatchRules ¶
func (s *Service) ListBankMatchRules(ctx context.Context, schemaName, tenantID string, filter *BankMatchRuleFilter) ([]BankMatchRule, error)
ListBankMatchRules lists bank auto-match rules.
func (*Service) ListReconciliations ¶
func (s *Service) ListReconciliations(ctx context.Context, schemaName, tenantID, bankAccountID string) ([]BankReconciliation, error)
ListReconciliations lists reconciliations for a bank account
func (*Service) ListTransactions ¶
func (s *Service) ListTransactions(ctx context.Context, schemaName, tenantID string, filter *TransactionFilter) ([]BankTransaction, error)
ListTransactions lists bank transactions with filters
func (*Service) MatchTransaction ¶
func (s *Service) MatchTransaction(ctx context.Context, schemaName, tenantID, transactionID, paymentID string) error
MatchTransaction matches a bank transaction to a payment
func (*Service) UnmatchTransaction ¶
func (s *Service) UnmatchTransaction(ctx context.Context, schemaName, tenantID, transactionID string) error
UnmatchTransaction removes the match from a bank transaction
func (*Service) UpdateBankAccount ¶
func (s *Service) UpdateBankAccount(ctx context.Context, schemaName, tenantID, accountID string, req *UpdateBankAccountRequest) (*BankAccount, error)
UpdateBankAccount updates a bank account
func (*Service) UpdateBankMatchRule ¶
func (s *Service) UpdateBankMatchRule(ctx context.Context, schemaName, tenantID, ruleID string, req *UpdateBankMatchRuleRequest) (*BankMatchRule, error)
UpdateBankMatchRule updates a bank auto-match rule.
func (*Service) UpdateTransactionReview ¶
func (s *Service) UpdateTransactionReview(ctx context.Context, schemaName, tenantID, transactionID, reviewerID string, req *UpdateTransactionReviewRequest) (*BankTransaction, error)
UpdateTransactionReview updates accountant follow-up metadata for a bank transaction.
type TransactionFilter ¶
type TransactionFilter struct {
BankAccountID string
Status TransactionStatus
ReconciliationID string
FromDate *time.Time
ToDate *time.Time
MinAmount *decimal.Decimal
MaxAmount *decimal.Decimal
}
TransactionFilter provides filtering options for bank transactions
type TransactionReviewUpdate ¶
type TransactionReviewUpdate struct {
FollowUpStatus *FollowUpStatus
ReviewNote *string
ReviewedBy string
ReviewedAt time.Time
}
TransactionReviewUpdate is the internal mutation payload for bank transaction review metadata.
type TransactionStatus ¶
type TransactionStatus string
TransactionStatus represents the reconciliation status of a bank transaction
const ( StatusUnmatched TransactionStatus = "UNMATCHED" StatusMatched TransactionStatus = "MATCHED" StatusReconciled TransactionStatus = "RECONCILED" )
type UpdateBankAccountRequest ¶
type UpdateBankAccountRequest struct {
Name string `json:"name,omitempty"`
BankName string `json:"bank_name,omitempty"`
SwiftCode string `json:"swift_code,omitempty"`
GLAccountID *string `json:"gl_account_id,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
IsDefault *bool `json:"is_default,omitempty"`
}
UpdateBankAccountRequest is the request to update a bank account
type UpdateBankMatchRuleRequest ¶
type UpdateBankMatchRuleRequest struct {
BankAccountID *string `json:"bank_account_id,omitempty"`
ClearBankAccount bool `json:"clear_bank_account,omitempty"`
Name *string `json:"name,omitempty"`
Priority *int `json:"priority,omitempty"`
MatchField *BankMatchField `json:"match_field,omitempty"`
Pattern *string `json:"pattern,omitempty"`
MinConfidence *float64 `json:"min_confidence,omitempty"`
MaxDateDiffDays *int `json:"max_date_diff_days,omitempty"`
RequireExactAmount *bool `json:"require_exact_amount,omitempty"`
IsActive *bool `json:"is_active,omitempty"`
}
UpdateBankMatchRuleRequest is the request to update a bank auto-match rule.
type UpdateTransactionReviewRequest ¶
type UpdateTransactionReviewRequest struct {
FollowUpStatus *FollowUpStatus `json:"follow_up_status,omitempty"`
ReviewNote *string `json:"review_note,omitempty"`
}
UpdateTransactionReviewRequest captures accountant follow-up updates for a bank transaction.