FIX: exclude flow_clients remaining_balance values less than 0.01
This commit is contained in:
parent
5d41e0c50e
commit
4843b43147
1 changed files with 17 additions and 16 deletions
|
|
@ -696,9 +696,14 @@ class LamassuTransactionProcessor:
|
||||||
for client in flow_clients:
|
for client in flow_clients:
|
||||||
# Get balance as of the transaction time for temporal accuracy
|
# Get balance as of the transaction time for temporal accuracy
|
||||||
balance = await get_client_balance_summary(client.id, as_of_time=transaction_time)
|
balance = await get_client_balance_summary(client.id, as_of_time=transaction_time)
|
||||||
if balance.remaining_balance > 0: # Only include clients with remaining balance
|
# Only include clients with positive remaining balance
|
||||||
|
# NOTE: This works for fiat amounts that use cents
|
||||||
|
if balance.remaining_balance >= 0.01:
|
||||||
client_balances[client.id] = balance.remaining_balance
|
client_balances[client.id] = balance.remaining_balance
|
||||||
total_confirmed_deposits += balance.remaining_balance
|
total_confirmed_deposits += balance.remaining_balance
|
||||||
|
logger.debug(f"Client {client.id[:8]}... included with balance: {balance.remaining_balance:.2f} GTQ")
|
||||||
|
else:
|
||||||
|
logger.info(f"Client {client.id[:8]}... excluded - zero/negative balance: {balance.remaining_balance:.2f} GTQ")
|
||||||
|
|
||||||
if total_confirmed_deposits == 0:
|
if total_confirmed_deposits == 0:
|
||||||
logger.info("No clients with remaining DCA balance - skipping distribution")
|
logger.info("No clients with remaining DCA balance - skipping distribution")
|
||||||
|
|
@ -749,14 +754,12 @@ class LamassuTransactionProcessor:
|
||||||
else:
|
else:
|
||||||
client_calculations[i % len(client_calculations)]['allocated_sats'] -= 1
|
client_calculations[i % len(client_calculations)]['allocated_sats'] -= 1
|
||||||
|
|
||||||
# Second pass: create distributions with final amounts (only for clients with positive allocations)
|
# Second pass: create distributions with final amounts
|
||||||
for calc in client_calculations:
|
for calc in client_calculations:
|
||||||
client_id = calc['client_id']
|
client_id = calc['client_id']
|
||||||
client_sats_amount = calc['allocated_sats']
|
client_sats_amount = calc['allocated_sats']
|
||||||
proportion = calc['proportion']
|
proportion = calc['proportion']
|
||||||
|
|
||||||
# Only create distributions for clients with positive sats amounts
|
|
||||||
if client_sats_amount > 0:
|
|
||||||
# Calculate equivalent fiat value in GTQ for tracking purposes
|
# Calculate equivalent fiat value in GTQ for tracking purposes
|
||||||
client_fiat_amount = round(client_sats_amount / exchange_rate, 2) if exchange_rate > 0 else 0.0
|
client_fiat_amount = round(client_sats_amount / exchange_rate, 2) if exchange_rate > 0 else 0.0
|
||||||
|
|
||||||
|
|
@ -767,8 +770,6 @@ class LamassuTransactionProcessor:
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(f"Client {client_id[:8]}... gets {client_sats_amount} sats (≈{client_fiat_amount:.2f} GTQ, {proportion:.2%} share)")
|
logger.info(f"Client {client_id[:8]}... gets {client_sats_amount} sats (≈{client_fiat_amount:.2f} GTQ, {proportion:.2%} share)")
|
||||||
else:
|
|
||||||
logger.info(f"Client {client_id[:8]}... gets {client_sats_amount} sats (≈0.00 GTQ, {proportion:.2%} share) - SKIPPED (zero amount)")
|
|
||||||
|
|
||||||
# Verification: ensure total distribution equals base amount
|
# Verification: ensure total distribution equals base amount
|
||||||
total_distributed = sum(dist["sats_amount"] for dist in distributions.values())
|
total_distributed = sum(dist["sats_amount"] for dist in distributions.values())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue