diff --git a/core/clients/platform.py b/core/clients/platform.py index 1282731..b02c69a 100644 --- a/core/clients/platform.py +++ b/core/clients/platform.py @@ -766,11 +766,14 @@ class LocalPlatformClient(ABC): if not settings.DUMMY: rtrn = await self.release_funds(trade_id) + print("RELEASE FUNDS RETURN", rtrn) else: log.debug(f"DUMMY: release_funds({trade_id})") rtrn = {"message": "OK"} if rtrn["message"] == "OK": + print("MESSAGE IS OK") if not settings.DUMMY: + print("NOT SETTINGS DUMMY") await self.api.contact_message_post( trade_id, "Thanks! Releasing now :)" ) diff --git a/core/clients/platforms/agora.py b/core/clients/platforms/agora.py index 7e6d09f..08862a6 100644 --- a/core/clients/platforms/agora.py +++ b/core/clients/platforms/agora.py @@ -31,9 +31,6 @@ class AgoraClient(LocalPlatformClient, BaseClient): self.instance.password, ) - # Check if we can withdraw funds - await self.withdraw_funds() - return rtrn # TODO: write test before re-enabling adding total_trades diff --git a/core/lib/money.py b/core/lib/money.py index 2e0a60f..49e3813 100644 --- a/core/lib/money.py +++ b/core/lib/money.py @@ -340,6 +340,7 @@ class Money(object): remaining = withdraw_threshold - total_usd profit = total_usd - total_base_usd + profit_in_xmr = profit / xmr_usd["monero"]["usd"] # Convert the total USD price to GBP and SEK price_sek = rates["SEK"] * total_usd @@ -358,6 +359,7 @@ class Money(object): total_remaining = withdraw_threshold - total_with_trades total_profit = total_with_trades - total_base_usd + total_profit_in_xmr = total_profit / xmr_usd["monero"]["usd"] # cast = ( # ( @@ -392,6 +394,7 @@ class Money(object): "total_withdrawal_limit": total_withdrawal_limit, "remaining": remaining, "profit": profit, + "profit_in_xmr": profit_in_xmr, "withdraw_threshold": withdraw_threshold, } if trades: @@ -399,6 +402,7 @@ class Money(object): cast_es["total_with_trades"] = total_with_trades cast_es["total_remaining"] = total_remaining cast_es["total_profit"] = total_profit + cast_es["total_profit_in_xmr"] = total_profit_in_xmr # await self.write_to_es("get_total", cast_es) return cast_es diff --git a/core/management/commands/scheduling.py b/core/management/commands/scheduling.py index 3708ebd..b668816 100644 --- a/core/management/commands/scheduling.py +++ b/core/management/commands/scheduling.py @@ -28,6 +28,7 @@ async def withdrawal_job(group=None): checks = await money.check_all( user=group.user, nordigen=NordigenClient, agora=AgoraClient ) + print("CHECKS", checks) aggregators = Aggregator.objects.filter( user=group.user, link_group=group, @@ -45,7 +46,7 @@ async def withdrawal_job(group=None): requisitions, platforms, group.user, - checks["total_profit"], + checks["total_profit_in_xmr"], ) collapsed = money.collapse_pay_list(pay_list) if any(collapsed.values()): diff --git a/core/views/linkgroups.py b/core/views/linkgroups.py index b053b20..4e5f629 100644 --- a/core/views/linkgroups.py +++ b/core/views/linkgroups.py @@ -239,7 +239,7 @@ class LinkGroupSimulation(LoginRequiredMixin, OTPRequiredMixin, ObjectRead): print("COLLAPSED", collapsed) self.extra_context = {"collapsed": collapsed} self.extra_context["pay_list"] = pay_list - self.extra_context["total_profit"] = checks["total_profit"] + self.extra_context["total_profit"] = checks["total_profit_in_xmr"] return pay_list diff --git a/core/views/profit.py b/core/views/profit.py index 44622df..23deb24 100644 --- a/core/views/profit.py +++ b/core/views/profit.py @@ -29,9 +29,11 @@ class Profit(LoginRequiredMixin, OTPRequiredMixin, ObjectRead): "Open trade value": res["open_trade_value"], "Total": res["total_with_trades"], "Profit": res["total_profit"], + "Profit in XMR": res["total_profit_in_xmr"], "Remaining before withdrawal": res["total_remaining"], "Total (without open trades)": res["total_usd"], "Profit (without open trades)": res["profit"], + "Profit (without open trades) in XMR": res["profit_in_xmr"], "Remaining before withdrawal (without open trades)": res["remaining"], "Base balance required": res["total_base_usd"], "Amount above base balance to trigger withdrawal": res[