show incoming transactions on buyer template for sales

pull/3/head
lalanza808 5 years ago
parent 4a677ed9bd
commit 5e5b46c0ed

@ -7,6 +7,7 @@ from django.contrib import messages
from core.models import UserShippingAddress from core.models import UserShippingAddress
from bids.models import ItemBid from bids.models import ItemBid
from sales.models import ItemSale from sales.models import ItemSale
from core.monero import AuctionWallet
@login_required @login_required
@ -33,10 +34,14 @@ def get_sale(request, sale_id):
_address_qr = BytesIO() _address_qr = BytesIO()
address_qr = qrcode_make(qr_uri).save(_address_qr) address_qr = qrcode_make(qr_uri).save(_address_qr)
total_seller_payout = sale.agreed_price_xmr - sale.platform_fee_xmr total_seller_payout = sale.agreed_price_xmr - sale.platform_fee_xmr - sale.network_fee_xmr
if sale.network_fee_xmr: incoming_transactions = None
total_seller_payout = total_seller_payout - sale.network_fee_xmr if sale.payment_received is False:
aw = AuctionWallet()
if aw.connected:
sale_account = aw.wallet.accounts[sale.escrow_account_index]
incoming_transactions = sale_account.incoming()
context = { context = {
'sale': sale, 'sale': sale,
@ -45,6 +50,7 @@ def get_sale(request, sale_id):
user=bid.bidder user=bid.bidder
).first(), ).first(),
'total_seller_payout': total_seller_payout, 'total_seller_payout': total_seller_payout,
'incoming_transactions': incoming_transactions,
} }
return render(request, 'sales/get_sale.html', context) return render(request, 'sales/get_sale.html', context)

@ -17,6 +17,14 @@
</p> </p>
<p class="sale-info"><strong>Expected Payment (XMR)</strong>: {{ sale.expected_payment_xmr }}</p> <p class="sale-info"><strong>Expected Payment (XMR)</strong>: {{ sale.expected_payment_xmr }}</p>
<p class="sale-info"><strong>Escrow Address</strong>: {{ sale.escrow_address }}</p> <p class="sale-info"><strong>Escrow Address</strong>: {{ sale.escrow_address }}</p>
{% if incoming_transactions %}
<p class="sale-info"><strong>Incoming Payments</strong>:</p>
<ul>
{% for tx in incoming_transactions %}
<li>{{ tx.transaction.hash }} ({{ tx.amount }} XMR)</li>
{% endfor %}
</ul>
{% endif %}
<img src="data:image/png;base64,{{ qrcode }}" width=200 class="center"> <img src="data:image/png;base64,{{ qrcode }}" width=200 class="center">
<hr> <hr>
<span class="wallet-text"> <span class="wallet-text">