applyPrecisionLogic contains the core logic for converting amounts based on precision. It assumes transaction.Precision has been set appropriately before this call.
(transaction *Transaction)
| 242 | // applyPrecisionLogic contains the core logic for converting amounts based on precision. |
| 243 | // It assumes transaction.Precision has been set appropriately before this call. |
| 244 | func applyPrecisionLogic(transaction *Transaction) *big.Int { |
| 245 | // Ensure precision is not zero to avoid division by zero, though ApplyPrecision and ApplyPrecisionWithDBLookup should handle this. |
| 246 | if transaction.Precision == 0 { |
| 247 | logrus.Warn("applyPrecisionLogic called with transaction.Precision = 0, defaulting to 1") |
| 248 | transaction.Precision = 1 |
| 249 | } |
| 250 | |
| 251 | if transaction.PreciseAmount != nil && transaction.PreciseAmount.Cmp(big.NewInt(0)) > 0 { |
| 252 | convertPreciseToDecimal(transaction) |
| 253 | return transaction.PreciseAmount |
| 254 | } |
| 255 | |
| 256 | transaction.PreciseAmount = convertDecimalToPrecise(transaction) |
| 257 | return transaction.PreciseAmount |
| 258 | } |
| 259 | |
| 260 | // fetchTransactionPrecisionFromDB is a placeholder for fetching precision from the database. |
| 261 | // In a real application, this would query your database. |
no test coverage detected