bugfix-vm-detail-no-invoice #16

Merged
mravi merged 5 commits from bugfix-vm-detail-no-invoice into master 2024-01-26 03:46:12 +00:00
2 changed files with 10 additions and 3 deletions

View file

@ -46,7 +46,7 @@
<div class="vm-vmid">
<div class="vm-item-subtitle">{% trans "Current Pricing" %}</div>
<div class="vm-item-lg">{{order.price|floatformat:2|intcomma}} CHF/{% if order.generic_product %}{% trans order.generic_product.product_subscription_interval %}{% else %}{% trans "Month" %}{% endif %}</div>
<a class="btn btn-vm-invoice" href="{{inv_url}}" target="_blank">{% trans "See Invoice" %}</a>
{% if inv_url %}<a class="btn btn-vm-invoice" href="{{inv_url}}" target="_blank">{% trans "See Invoice" %}</a>{%else%}{% trans "No invoice as of now" %}{% endif %}
</div>
</div>
<div class="vm-detail-item">

View file

@ -1694,6 +1694,10 @@ class VirtualMachineView(LoginRequiredMixin, View):
login_url = reverse_lazy('hosting:login')
def get_object(self):
username = self.request.GET.get('username')
if self.request.user.is_admin and username:
owner = CustomUser.objects.get(username=username)
else:
owner = self.request.user
vm = None
manager = OpenNebulaManager(
@ -1750,7 +1754,10 @@ class VirtualMachineView(LoginRequiredMixin, View):
subscription=hosting_order.subscription_id,
count=1
)
if stripe_obj.data:
inv_url = stripe_obj.data[0].hosted_invoice_url
else:
inv_url = ''
elif hosting_order.stripe_charge_id:
stripe_obj = stripe.Charge.retrieve(
hosting_order.stripe_charge_id