Documentation
¶
Index ¶
- func AddAmounts(a, b int64, currency string) (int64, error)
- func AmountToInt64(amount money.Amount) (int64, error)
- func ApplyBasisPoints(smallestUnit int64, bps BasisPoints, currency string) (int64, error)
- func CalculateCompoundInterest(principal int64, rateBps BasisPoints, durationDays int, currency string) (int64, error)
- func CalculateSimpleInterest(principal int64, rateBps BasisPoints, durationDays int, currency string) (int64, error)
- func CompareAmounts(a, b int64, currency string) (int, error)
- func ConvertCurrency(amount int64, fromCurrency, toCurrency string, exchangeRateBps int64) (int64, error)
- func FormatAmount(smallestUnit int64, currency string) string
- func Int64ToAmount(smallestUnit int64, currency string) (money.Amount, error)
- func IsNegative(amount int64) bool
- func IsPositive(amount int64) bool
- func IsZero(amount int64) bool
- func MultiplyAmount(smallestUnit int64, multiplier float64, currency string) (int64, error)
- func ParseAmount(amountStr string, currency string) (int64, error)
- func SubtractAmounts(a, b int64, currency string) (int64, error)
- func ValidateCurrency(currencyCode string) bool
- type BasisPoints
- type PDFParser
- type PaginatedResponse
- type Pagination
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAmounts ¶
AddAmounts adds two amounts in smallest unit (must be same currency) Returns the sum in smallest unit
func AmountToInt64 ¶
AmountToInt64 converts money.Amount to int64 in smallest unit (minor units) Example: AmountToInt64(1000.50 KES) returns 100050 (cents)
func ApplyBasisPoints ¶
func ApplyBasisPoints(smallestUnit int64, bps BasisPoints, currency string) (int64, error)
ApplyBasisPoints applies a basis points percentage to an amount Example: ApplyBasisPoints(100000, 350, "KES") = 3500 (3.5% of 1000.00)
func CalculateCompoundInterest ¶
func CalculateCompoundInterest(principal int64, rateBps BasisPoints, durationDays int, currency string) (int64, error)
CalculateCompoundInterest calculates compound interest with daily compounding Returns the total amount (principal + interest) in smallest unit
func CalculateSimpleInterest ¶
func CalculateSimpleInterest(principal int64, rateBps BasisPoints, durationDays int, currency string) (int64, error)
CalculateSimpleInterest calculates simple interest: I = P * r * t principal: amount in smallest unit rateBps: annual interest rate in basis points durationDays: loan duration in days Returns interest amount in smallest unit
func CompareAmounts ¶
CompareAmounts compares two amounts in smallest unit (same currency) Returns: -1 if a < b, 0 if a == b, 1 if a > b
func ConvertCurrency ¶
func ConvertCurrency(amount int64, fromCurrency, toCurrency string, exchangeRateBps int64) (int64, error)
ConvertCurrency converts an amount from one currency to another using an exchange rate exchangeRateBps: exchange rate in basis points (e.g., 7700 = 0.77 USD per KES)
func FormatAmount ¶
FormatAmount formats an amount in smallest unit to a readable string Example: FormatAmount(100050, "KES") = "KES 1000.50"
func Int64ToAmount ¶
Int64ToAmount converts an amount in smallest unit (int64) to money.Amount Uses minor units (cents, satoshis, etc.) for the specified currency Example: Int64ToAmount(100050, "KES") converts 100050 cents to 1000.50 KES
func MultiplyAmount ¶
MultiplyAmount multiplies an amount by a factor Example: MultiplyAmount(100000, 2.5, "KES") = 250000 (1000.00 * 2.5 = 2500.00)
func ParseAmount ¶
ParseAmount parses a string amount to int64 in smallest unit Example: ParseAmount("1000.50", "KES") = 100050 (cents)
func SubtractAmounts ¶
SubtractAmounts subtracts two amounts in smallest unit (must be same currency) Returns a - b in smallest unit
func ValidateCurrency ¶
ValidateCurrency checks if a currency code is supported
Types ¶
type BasisPoints ¶
type BasisPoints int32
BasisPoints represents interest rates, fees, and percentages as basis points 1 basis point = 0.01% = 0.0001 Example: 15.00% = 1500 bps, 3.75% = 375 bps, 178.00% = 17800 bps
func ToBps ¶
func ToBps(percentage float64) BasisPoints
ToBps converts a percentage (as float) to basis points Example: ToBps(15.0) = 1500 (15.00%)
func (BasisPoints) String ¶
func (bp BasisPoints) String() string
String returns a formatted percentage string Example: BasisPoints(1500).String() = "15.00%"
func (BasisPoints) ToDecimal ¶
func (bp BasisPoints) ToDecimal() float64
ToDecimal converts basis points to decimal representation for multiplication Example: BasisPoints(1500).ToDecimal() = 0.15
func (BasisPoints) ToPercent ¶
func (bp BasisPoints) ToPercent() float64
ToPercent converts basis points to percentage as float Example: BasisPoints(1500).ToPercent() = 15.0
type PDFParser ¶
type PDFParser struct{}
PDFParser handles PDF document parsing
func (*PDFParser) DecryptPDF ¶
DecryptPDF decrypts a password-protected PDF
func (*PDFParser) ExtractText ¶
ExtractText extracts text from PDF
type PaginatedResponse ¶
type PaginatedResponse[T any] struct { Data []T `json:"data"` Page int `json:"page"` PageSize int `json:"page_size"` TotalCount int `json:"total_count"` }
PaginatedResponse is a generic paginated response
type Pagination ¶
Pagination is shared across services