Improves readability and reduces logging verbosity
Removes excessive logging to improve readability and reduce verbosity. Streamlines balance processing and improves logging for settlement amounts. Adds a note about Fava's internal normalization behavior to the beancount formatting.
This commit is contained in:
parent
313265b185
commit
fbda8e2980
3 changed files with 7 additions and 24 deletions
8
tasks.py
8
tasks.py
|
|
@ -183,11 +183,9 @@ async def on_invoice_paid(payment: Payment) -> None:
|
|||
# Extract fiat metadata from invoice (if present)
|
||||
fiat_currency = None
|
||||
fiat_amount = None
|
||||
logger.info(f"Payment.extra in webhook: {payment.extra}")
|
||||
if payment.extra:
|
||||
fiat_currency = payment.extra.get("fiat_currency")
|
||||
fiat_amount_str = payment.extra.get("fiat_amount")
|
||||
logger.info(f"Extracted from extra - fiat_currency: {fiat_currency}, fiat_amount_str: {fiat_amount_str}")
|
||||
if fiat_amount_str:
|
||||
fiat_amount = Decimal(str(fiat_amount_str))
|
||||
|
||||
|
|
@ -195,15 +193,11 @@ async def on_invoice_paid(payment: Payment) -> None:
|
|||
logger.error(f"Payment {payment.payment_hash} missing fiat currency/amount metadata")
|
||||
return
|
||||
|
||||
logger.info(f"Final fiat values for payment entry - currency: {fiat_currency}, amount: {fiat_amount}")
|
||||
|
||||
# Get user's current balance to determine receivables and payables
|
||||
balance = await fava.get_user_balance(user_id)
|
||||
fiat_balances = balance.get("fiat_balances", {})
|
||||
total_fiat_balance = fiat_balances.get(fiat_currency, Decimal(0))
|
||||
|
||||
logger.info(f"User {user_id[:8]} current balance: {total_fiat_balance} {fiat_currency}")
|
||||
|
||||
# Determine receivables and payables based on balance
|
||||
# Positive balance = user owes castle (receivable)
|
||||
# Negative balance = castle owes user (payable)
|
||||
|
|
@ -216,7 +210,7 @@ async def on_invoice_paid(payment: Payment) -> None:
|
|||
total_receivable = Decimal(0)
|
||||
total_payable = abs(total_fiat_balance)
|
||||
|
||||
logger.info(f"Settlement amounts - Receivable: {total_receivable}, Payable: {total_payable}, Net: {fiat_amount}")
|
||||
logger.info(f"Settlement: {fiat_amount} {fiat_currency} (Receivable: {total_receivable}, Payable: {total_payable})")
|
||||
|
||||
# Get account names
|
||||
user_receivable = await get_or_create_user_account(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue