def add_invoice(request): if request.method == 'POST': form = InvoiceForm(request.POST) if form.is_valid(): invoice = form.save(commit=False) invoice.price_gross = 0 invoice.price_net = 0 invoice.price_vat = 0 invoice.paid = 0 invoice.month = invoice.invoice_date.month invoice.year = invoice.invoice_date.year next_num = Invoice.objects.filter(year=invoice.year, month=invoice.month, place=invoice.place).count() + 1 invoice.invoice_nr = str(invoice.invoice_type.symbol) + '/' + str(invoice.place.invoice_code) + '/' invoice.invoice_nr += str(invoice.year) + '/' + str(invoice.month) + '/' + str(next_num) invoice.save() return HttpResponseRedirect(reverse(invoice_list) + '?info=success') else: return render(request, 'invoices/new_invoice.html', {'form': form}) else: context = { 'form': InvoiceForm() } return render(request, 'invoices/new_invoice.html', context)
def add_job(request): if request.method == "POST": form = InvoiceForm(request.POST) if form.is_valid(): form.save() return redirect("home") else: form = InvoiceForm() return render(request, "invoices/add_job.html", {"form": form})
def add_job(request): if request.method == 'POST': form = InvoiceForm(request.POST) if form.is_valid(): form.save() return form else: form = InvoiceForm() return render(request, 'invoices/add_job.html', {'form': form})
def invoice_view(request): form = InvoiceForm(request.POST or None) if form.is_valid(): doctype = form.cleaned_data['format'] filename = fill_template( 'invoices/invoice.odt', form.cleaned_data, output_format=doctype) visible_filename = 'invoice.{}'.format(doctype) return FileResponse(filename, visible_filename) else: return render(request, 'invoices/form.html', {'form': form})
def invoice_view(request): form = InvoiceForm(request.POST or None) if form.is_valid(): doctype = form.cleaned_data['format'] filename = fill_template('invoices/invoice.odt', form.cleaned_data, output_format=doctype) visible_filename = 'invoice.{}'.format(doctype) return FileResponse(filename, visible_filename) else: return render(request, 'invoices/form.html', {'form': form})
def post(self, *args, **kwargs): """Get filled invoice form and create """ invoice_form = InvoiceForm(self.request.POST, company=self.request.user.company) if invoice_form.is_valid() : invoice = invoice_form.save(commit=False) invoice.owner = self.request.user invoice.company = self.request.user.company invoice.save() messages.success(self.request, 'Invoice is successfully Added') return redirect('invoices') else: context = {} context['invoice_form'] = invoice_form context['invoice_form'].fields['client'].queryset = Client.objects.filter(company=self.request.user.company) context['invoice_form'].fields['item'].queryset = Item.objects.filter(company=self.request.user.company) return render(self.request, self.template_name, context)
def get(self, *args, **kwargs): """Display invoice form """ context = {} context['invoice_form'] = InvoiceForm() context['invoice_form'].fields['client'].queryset = Client.objects.filter(company=self.request.user.company) context['invoice_form'].fields['item'].queryset = Item.objects.filter(company=self.request.user.company) return render(self.request, self.template_name, context)
def invoice_edit(request, invoice_id): invoice_obj = get_object_or_404(Invoice, pk=invoice_id) if not (request.user.role == 'ADMIN' or request.user.is_superuser or invoice_obj.created_by == request.user or request.user in invoice_obj.assigned_to.all()): raise PermissionDenied if request.method == 'GET': context = {} context['invoice_obj'] = invoice_obj context['form'] = InvoiceForm( instance=invoice_obj, request_user=request.user) context['from_address_form'] = InvoiceAddressForm(prefix='from', instance=invoice_obj.from_address) context['to_address_form'] = InvoiceAddressForm(prefix='to', instance=invoice_obj.to_address) return render(request, 'invoice_create_1.html', context) if request.method == 'POST': form = InvoiceForm(request.POST, instance=invoice_obj, request_user=request.user) from_address_form = InvoiceAddressForm( request.POST, instance=invoice_obj.from_address, prefix='from') to_address_form = InvoiceAddressForm( request.POST, instance=invoice_obj.to_address, prefix='to') if form.is_valid() and from_address_form.is_valid() and to_address_form.is_valid(): form_changed_data = form.changed_data form_changed_data.remove('from_address') form_changed_data.remove('to_address') form_changed_data = form_changed_data + ['from_' + field for field in from_address_form.changed_data] form_changed_data = form_changed_data + ['to_' + field for field in to_address_form.changed_data] # if form_changed_data: # create_invoice_history(invoice_obj.id, request.user.id, form_changed_data) from_address_obj = from_address_form.save() to_address_obj = to_address_form.save() invoice_obj = form.save(commit=False) invoice_obj.created_by = request.user invoice_obj.from_address = from_address_obj invoice_obj.to_address = to_address_obj invoice_obj.save() form.save_m2m() if form_changed_data: create_invoice_history(invoice_obj.id, request.user.id, form_changed_data) if request.POST.getlist('teams', []): user_ids = Teams.objects.filter(id__in=request.POST.getlist('teams')).values_list('users', flat=True) assinged_to_users_ids = invoice_obj.assigned_to.all().values_list('id', flat=True) for user_id in user_ids: if user_id not in assinged_to_users_ids: invoice_obj.assigned_to.add(user_id) kwargs = {'domain': request.get_host(), 'protocol': request.scheme} send_email.delay(invoice_obj.id, **kwargs) if request.POST.get('from_account'): return JsonResponse({'error': False, 'success_url': reverse('accounts:view_account', args=(request.POST.get('from_account'),))}) return JsonResponse({'error': False, 'success_url': reverse('invoices:invoices_list')}) else: return JsonResponse({'error': True, 'errors': form.errors, 'from_address_errors': from_address_form.errors, 'to_address_errors': to_address_form.errors})
def index(request): all_notes = Note.all_notes.all() unresolved_notes = Note.unresolved_notes.all() urgent_notes = Note.urgent_notes.all() queued_invoices = Invoice.queued_invoices.all() running_invoices = Invoice.running_invoices.all() note_form = NoteForm(request.POST) is_admin = request.user.groups.filter(name='Admin') updates = Update.objects.all() if note_form.is_valid(): note_form.save() return note_form form = InvoiceForm(request.POST) if form.is_valid(): form.save() return form #return render(request, 'invoices/add_job.html', {'form': form}) return render_to_response('index.html', {'all_notes': all_notes, 'unresolved_notes': unresolved_notes, 'urgent_notes': urgent_notes, 'queued_invoices': queued_invoices, 'running_invoices': running_invoices, 'note_form': note_form, 'is_admin': is_admin, 'updates': updates, 'form': form}, context_instance=RequestContext(request))
def get(self, *args, **kwargs): """Displaying invoice data and invoice form """ context = {} context['client'] = get_object_or_404(Client, pk=kwargs['client_id']) context['invoice_form'] = InvoiceForm() context['invoice_form'].fields['client'].empty_label = None context['invoice_form'].fields['client'].queryset = Client.objects.filter(pk=kwargs['client_id']) context['invoice_form'].fields['item'].queryset = Item.objects.filter(company=self.request.user.company) return render(self.request, self.template_name, context)
def add_job(request): if request.method == 'POST': form = InvoiceForm(request.POST) if form.is_valid(): form.save() return redirect('home') else: form = InvoiceForm() return render(request, 'invoices/add_job.html', {'form': form})
def job_edit(request, invoice_id): invoice = get_object_or_404(Invoice, pk=invoice_id) if request.method == "POST": form = InvoiceForm(request.POST, instance=invoice) if form.is_valid(): if invoice.job_state == "completed": subject = "Your 3D print is completed" message = ( "Hi, %s. Your 3D print is completed. The cost for this print is $%0.2f. Please pick it up at the <a href='http://library.ndsu.edu/hours/'>Main Library Circulation Desk</a> within the next 14 days. You will need to show your Bison ID to receive your print." % (invoice.customer_first_name, invoice.job_cost) ) send_from = "*****@*****.**" send_to = [invoice.customer_email] email = EmailMessage(subject, message, send_from, send_to) email.send() form.save() return redirect("job_detail", invoice_id) else: form = InvoiceForm(instance=invoice) return render_to_response("invoices/job_edit.html", {"form": form}, context_instance=RequestContext(request))
def invoices_create(request): if request.method == 'GET': context = {} context["form"] = InvoiceForm(request_user=request.user) context["users"] = User.objects.all() # "prefix" use case in form, both from address and to address use the # same model and same model form, so the name attribute in the form will # be same for the both forms and the address will be same for both # shipping and to address, so use prefix parameter to distinguish the # forms, don't remove this comment context["from_address_form"] = InvoiceAddressForm( prefix='from') context["to_address_form"] = InvoiceAddressForm(prefix='to') if request.user.role == 'ADMIN' or request.user.is_superuser: context['teams'] = Teams.objects.all() return render(request, 'invoice_create_1.html', context) if request.method == 'POST': form = InvoiceForm(request.POST, request_user=request.user) from_address_form = InvoiceAddressForm( request.POST, prefix='from') to_address_form = InvoiceAddressForm(request.POST, prefix='to') if form.is_valid() and from_address_form.is_valid() and to_address_form.is_valid(): from_address_obj = from_address_form.save() to_address_obj = to_address_form.save() invoice_obj = form.save(commit=False) invoice_obj.created_by = request.user invoice_obj.from_address = from_address_obj invoice_obj.to_address = to_address_obj invoice_obj.save() form.save_m2m() if request.POST.getlist('teams', []): user_ids = Teams.objects.filter(id__in=request.POST.getlist('teams')).values_list('users', flat=True) assinged_to_users_ids = invoice_obj.assigned_to.all().values_list('id', flat=True) for user_id in user_ids: if user_id not in assinged_to_users_ids: invoice_obj.assigned_to.add(user_id) if request.POST.getlist('teams', []): invoice_obj.teams.add(*request.POST.getlist('teams')) create_invoice_history(invoice_obj.id, request.user.id, []) kwargs = {'domain': request.get_host(), 'protocol': request.scheme} assigned_to_list = list(invoice_obj.assigned_to.all().values_list('id', flat=True)) send_email.delay(invoice_obj.id, assigned_to_list, **kwargs) if request.POST.get('from_account'): return JsonResponse({'error': False, 'success_url': reverse('accounts:view_account', args=(request.POST.get('from_account'),))}) return JsonResponse({'error': False, 'success_url': reverse('invoices:invoices_list')}) else: return JsonResponse({'error': True, 'errors': form.errors, 'from_address_errors': from_address_form.errors, 'to_address_errors': to_address_form.errors})
def get(self, request): form = InvoiceForm(instance=self.invoice) if self.invoice.items.count(): extra = 0 else: extra = 1 if self.invoice.status > 0: return render(request=request, template_name="invoices/edit.html", context={"form": form}) ItemsFormSet = inlineformset_factory(Invoice, Item, fields="__all__", extra=extra) formset = ItemsFormSet(instance=self.invoice) return render(request=request, template_name="invoices/edit.html", context={"form": form, "formset": formset})
def invoice_edit(request, invoice_id): invoice_obj = get_object_or_404(Invoice, pk=invoice_id) if not (request.user.role == 'ADMIN' or request.user.is_superuser or invoice_obj.created_by == request.user or request.user in invoice_obj.assigned_to.all()): raise PermissionDenied if request.method == 'GET': context = {} context['invoice_obj'] = invoice_obj context['form'] = InvoiceForm(instance=invoice_obj, request_user=request.user) context['from_address_form'] = InvoiceAddressForm( prefix='from', instance=invoice_obj.from_address) context['to_address_form'] = InvoiceAddressForm( prefix='to', instance=invoice_obj.to_address) return render(request, 'invoices_create.html', context) if request.method == 'POST': form = InvoiceForm(request.POST, instance=invoice_obj, request_user=request.user) from_address_form = InvoiceAddressForm( request.POST, instance=invoice_obj.from_address, prefix='from') to_address_form = InvoiceAddressForm(request.POST, instance=invoice_obj.to_address, prefix='to') if form.is_valid() and from_address_form.is_valid( ) and to_address_form.is_valid(): from_address_obj = from_address_form.save() to_address_obj = to_address_form.save() invoice_obj = form.save(commit=False) invoice_obj.created_by = request.user invoice_obj.from_address = from_address_obj invoice_obj.to_address = to_address_obj invoice_obj.save() form.save_m2m() kwargs = {'domain': request.get_host(), 'protocol': request.scheme} send_email.delay(invoice_obj.id, **kwargs) return JsonResponse({ 'error': False, 'success_url': reverse('invoices:invoices_list') }) else: return JsonResponse({ 'error': True, 'errors': form.errors, 'from_address_errors': from_address_form.errors, 'to_address_errors': to_address_form.errors })
def post(self, request): form = InvoiceForm(request.POST) if form.is_valid(): invoice = form.save(commit=False) invoice.invoice_id = generate_id(form.cleaned_data["partner"]) invoice.save() form.save_m2m() messages.add_message(request, messages.SUCCESS, "The invoice has been successfully created.") return HttpResponseRedirect(self.next) return render(request=request, template_name="invoices/create.html", context={"form": form})
def job_edit(request, invoice_id): invoice = get_object_or_404(Invoice, pk=invoice_id) if request.method=='POST': form = InvoiceForm(request.POST, instance=invoice) if form.is_valid(): if invoice.job_state == 'completed': subject = "Your 3D print is completed" message = "Hi, %s. Your 3D print is completed. The cost for this print is $%0.2f. Please pick it up at the <a href='http://library.ndsu.edu/hours/'>Main Library Circulation Desk</a> within the next 14 days. You will need to show your Bison ID to receive your print." % (invoice.customer_first_name, invoice.job_cost) send_from = "*****@*****.**" send_to = [invoice.customer_email] email = EmailMessage(subject, message, send_from, send_to) email.send() form.save() return redirect('job_detail', invoice_id) else: form = InvoiceForm(instance=invoice) return render_to_response('invoices/job_edit.html', {'form': form}, context_instance=RequestContext(request))
def post(self, *args, **kwargs): """Get filled invoice form and create invoice """ invoice = get_object_or_404(Invoice, pk=kwargs['invoice_id']) invoice_form = InvoiceForm(self.request.POST, instance=invoice, company=self.request.user.company) if invoice_form.is_valid() : invoice_form.save() messages.success(self.request, 'Invoice is successfully updated') return redirect('invoices') else: context = {} context['invoice_form'] = InvoiceForm(self.request.POST) context['invoice_form'].fields['client'].queryset = Client.objects.filter(company=self.request.user.company) context['invoice_form'].fields['item'].queryset = Item.objects.filter(company=self.request.user.company) return render(self.request, self.template_name, context)
def invoices_create(request): if request.method == 'GET': context = {} context["form"] = InvoiceForm(request_user=request.user) # "prefix" use case in form, both from address and to address use the # same model and same model form, so the name attribute in the form will # be same for the both forms and the address will be same for both # shipping and to address, so use prefix parameter to distinguish the # forms, don't remove this comment context["from_address_form"] = InvoiceAddressForm(prefix='from') context["to_address_form"] = InvoiceAddressForm(prefix='to') return render(request, 'invoices_create.html', context) if request.method == 'POST': form = InvoiceForm(request.POST, request_user=request.user) from_address_form = InvoiceAddressForm(request.POST, prefix='from') to_address_form = InvoiceAddressForm(request.POST, prefix='to') if form.is_valid() and from_address_form.is_valid( ) and to_address_form.is_valid(): from_address_obj = from_address_form.save() to_address_obj = to_address_form.save() invoice_obj = form.save(commit=False) invoice_obj.created_by = request.user invoice_obj.from_address = from_address_obj invoice_obj.to_address = to_address_obj invoice_obj.save() form.save_m2m() kwargs = {'domain': request.get_host(), 'protocol': request.scheme} send_email.delay(invoice_obj.id, **kwargs) return JsonResponse({ 'error': False, 'success_url': reverse('invoices:invoices_list') }) else: return JsonResponse({ 'error': True, 'errors': form.errors, 'from_address_errors': from_address_form.errors, 'to_address_errors': to_address_form.errors })
def post(self, request): form = InvoiceForm(request.POST, instance=self.invoice) if self.invoice.status > 0: if form.is_valid(): invoice = form.save() if invoice.status == 1 and not invoice.bill_date: invoice.bill_date = date.today() invoice.save() messages.add_message(request, messages.SUCCESS, "The invoice has been successfully edited.") return HttpResponseRedirect(self.next) return render(request=request, template_name="invoices/edit.html", context={"form": form}) ItemsFormSet = inlineformset_factory(Invoice, Item, fields="__all__", extra=0) formset = ItemsFormSet(request.POST, instance=self.invoice) if form.is_valid() and formset.is_valid(): invoice = form.save() if invoice.status == 1 and not invoice.bill_date: invoice.bill_date = date.today() invoice.save() formset.save() messages.add_message(request, messages.SUCCESS, "The invoice has been successfully edited.") return HttpResponseRedirect(self.next) return render(request=request, template_name="invoices/edit.html", context={"form": form, "formset": formset})
def invoices_create(request): if request.method == "GET": context = {} context["form"] = InvoiceForm(request_user=request.user, request_obj=request) context["users"] = User.objects.filter(company=request.company) # "prefix" use case in form, both from address and to address use the # same model and same model form, so the name attribute in the form will # be same for the both forms and the address will be same for both # shipping and to address, so use prefix parameter to distinguish the # forms, don't remove this comment context["from_address_form"] = InvoiceAddressForm(prefix="from") context["to_address_form"] = InvoiceAddressForm(prefix="to") if request.user.role == "ADMIN" or request.user.is_superuser: context["teams"] = Teams.objects.filter(company=request.company) return render(request, "invoice_create_1.html", context) if request.method == "POST": form = InvoiceForm(request.POST, request_user=request.user, request_obj=request) from_address_form = InvoiceAddressForm(request.POST, prefix="from") to_address_form = InvoiceAddressForm(request.POST, prefix="to") if (form.is_valid() and from_address_form.is_valid() and to_address_form.is_valid()): from_address_obj = from_address_form.save() to_address_obj = to_address_form.save() invoice_obj = form.save(commit=False) invoice_obj.created_by = request.user invoice_obj.company = request.company invoice_obj.from_address = from_address_obj invoice_obj.to_address = to_address_obj invoice_obj.save() form.save_m2m() if request.POST.getlist("teams", []): user_ids = Teams.objects.filter( id__in=request.POST.getlist("teams")).values_list( "users", flat=True) assinged_to_users_ids = invoice_obj.assigned_to.all( ).values_list("id", flat=True) for user_id in user_ids: if user_id not in assinged_to_users_ids: invoice_obj.assigned_to.add(user_id) if request.POST.getlist("teams", []): invoice_obj.teams.add(*request.POST.getlist("teams")) create_invoice_history(invoice_obj.id, request.user.id, []) kwargs = {"domain": request.get_host(), "protocol": request.scheme} assigned_to_list = list(invoice_obj.assigned_to.all().values_list( "id", flat=True)) send_email.delay(invoice_obj.id, assigned_to_list, **kwargs) if request.POST.get("from_account"): return JsonResponse({ "error": False, "success_url": reverse( "accounts:view_account", args=(request.POST.get("from_account"), ), ), }) return JsonResponse({ "error": False, "success_url": reverse("invoices:invoices_list") }) else: return JsonResponse({ "error": True, "errors": form.errors, "from_address_errors": from_address_form.errors, "to_address_errors": to_address_form.errors, })
def invoice_edit(request, invoice_id): invoice_obj = get_object_or_404(Invoice, pk=invoice_id) if invoice_obj.company != request.company: raise PermissionDenied if not (request.user.role == "ADMIN" or request.user.is_superuser or invoice_obj.created_by == request.user or request.user in invoice_obj.assigned_to.all()): raise PermissionDenied if request.method == "GET": context = {} context["invoice_obj"] = invoice_obj context["teams"] = Teams.objects.filter(company=request.company) context["users"] = User.objects.filter(company=request.company) context["form"] = InvoiceForm(instance=invoice_obj, request_user=request.user, request_obj=request) context["from_address_form"] = InvoiceAddressForm( prefix="from", instance=invoice_obj.from_address) context["to_address_form"] = InvoiceAddressForm( prefix="to", instance=invoice_obj.to_address) return render(request, "invoice_create_1.html", context) if request.method == "POST": form = InvoiceForm( request.POST, instance=invoice_obj, request_user=request.user, request_obj=request, ) from_address_form = InvoiceAddressForm( request.POST, instance=invoice_obj.from_address, prefix="from") to_address_form = InvoiceAddressForm(request.POST, instance=invoice_obj.to_address, prefix="to") previous_assigned_to_users = list( invoice_obj.assigned_to.all().values_list("id", flat=True)) if (form.is_valid() and from_address_form.is_valid() and to_address_form.is_valid()): form_changed_data = form.changed_data form_changed_data.remove("from_address") form_changed_data.remove("to_address") form_changed_data = form_changed_data + [ "from_" + field for field in from_address_form.changed_data ] form_changed_data = form_changed_data + [ "to_" + field for field in to_address_form.changed_data ] # if form_changed_data: # create_invoice_history(invoice_obj.id, request.user.id, form_changed_data) from_address_obj = from_address_form.save() to_address_obj = to_address_form.save() invoice_obj = form.save(commit=False) invoice_obj.created_by = request.user invoice_obj.from_address = from_address_obj invoice_obj.to_address = to_address_obj invoice_obj.save() form.save_m2m() if form_changed_data: create_invoice_history(invoice_obj.id, request.user.id, form_changed_data) if request.POST.getlist("teams", []): user_ids = Teams.objects.filter( id__in=request.POST.getlist("teams")).values_list( "users", flat=True) assinged_to_users_ids = invoice_obj.assigned_to.all( ).values_list("id", flat=True) for user_id in user_ids: if user_id not in assinged_to_users_ids: invoice_obj.assigned_to.add(user_id) if request.POST.getlist("teams", []): invoice_obj.teams.clear() invoice_obj.teams.add(*request.POST.getlist("teams")) else: invoice_obj.teams.clear() kwargs = {"domain": request.get_host(), "protocol": request.scheme} assigned_to_list = list(invoice_obj.assigned_to.all().values_list( "id", flat=True)) recipients = list( set(assigned_to_list) - set(previous_assigned_to_users)) # send_email_to_assigned_user.delay(recipients, account_object.id, domain=current_site.domain, # protocol=self.request.scheme) send_email.delay(invoice_obj.id, recipients, **kwargs) if request.POST.get("from_account"): return JsonResponse({ "error": False, "success_url": reverse( "accounts:view_account", args=(request.POST.get("from_account"), ), ), }) return JsonResponse({ "error": False, "success_url": reverse("invoices:invoices_list") }) else: return JsonResponse({ "error": True, "errors": form.errors, "from_address_errors": from_address_form.errors, "to_address_errors": to_address_form.errors, })
def get(self, request): form = InvoiceForm() return render(request=request, template_name="invoices/create.html", context={"form": form})
def _invoice(request, pk=None, invoice_type="invoice", base_template="base.html", to_print=None, lang_code=None): if pk: instance = get_object_or_404(Invoice, pk=pk) invoice_type = instance.invoice_type else: instance = None default_data = { "number": get_next_number(request.user, invoice_type), "released_at": str(timezone.now().strftime("%Y-%m-%d")), "taxevent_at": str(timezone.now().strftime("%Y-%m-%d")), } if pk: selected_language = request.session.get('current_lang', lang_code) selected_language = selected_language if selected_language else settings.LANGUAGE_CODE else: selected_language = settings.LANGUAGE_CODE request.session[ 'current_lang'] = settings.LANGUAGE_CODE # restore the default lang in case of editing recorded translation context = { "print": to_print, "base_template": base_template, "form": InvoiceForm(initial=default_data), "instance": instance, "items": json.dumps([]), "invoice_type": invoice_type, "company_form": CompanyForm(instance=request.user.settings), "pk": pk, "selected_language": selected_language, } if request.method == "POST": form = InvoiceForm(request.POST, instance=instance) initial_items = list( instance.invoiceitem_set.all().values()) if instance else [] form_items = InvoiceItemFormSet(request.POST, initial=initial_items) is_ok, pk = process_invoice(form, form_items) if is_ok: return redirect(reverse(invoice_type, args=[pk])) context["form_items"] = form_items context["form"] = form elif instance: context["company_form"] = CompanyForm(instance=instance.user.settings) context["form"] = InvoiceForm(instance=instance) if not pk and request.user.settings.payment_iban: context["form"]["payment_type"].value = context["company_form"][ "payment_type"].value context["form"]["payment_iban"].value = context["company_form"][ "payment_iban"].value context["form"]["payment_swift"].value = context["company_form"][ "payment_swift"].value context["form"]["payment_bank"].value = context["company_form"][ "payment_bank"].value if instance: context["items"] = django_json_dumps( list(instance.invoiceitem_set.values())) # rates = {} # for from_c in settings.ALLOWED_CURRENCIES: # rates[from_c] = round(exchange_currency(Price(1.0000, currency=from_c), 'BGN').net, 5) # if instance and instance.currency: # rates[instance.currency] = instance.currency_rate # context['rates'] = rates # context['rates_json'] = django_json_dumps(rates) return render(request, template_name="invoices/_invoice.html", context=context)