def delete_user_invoice(request): try: im = InvoiceRequestManager(request) im.delete() return HttpResponse('200') except RequestProcessException as e: return e.get_response()
def invoice_charge_state(request): try: im = InvoiceRequestManager(request) return HttpResponse(im.get_charge_state_json()) except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.args or e.message) return send_error(request, _('system error'))
def invoice_get_service_analyze_data(request): try: ix = InvoiceRequestManager(request) res = ix.get_service_analyze() return HttpResponse(res) except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.message or e.args) return send_error(request, _('system error'))
def get_analysis_data(request): try: ix = InvoiceRequestManager(request) res = ix.analysis_result() return HttpResponse(json.dumps(res, default=date_handler)) except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.message or e.args) return send_error(request, _('system error'))
def get_invoice_detail(request): try: im = InvoiceRequestManager(request) return HttpResponse( im.get_single_dict(True, True, ('comment', 'ref_number', 'pk'))) except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.message or e.args) return send_error(request, _('system error'))
def download_excel_invoice(request): try: im = InvoiceRequestManager(request) res = im.search() return export_excel(res.order_by('pay_time', '-pk'), request) except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.message or e.args) return send_error(request, _('system error'))
def invoice_print_single(request): try: sm = InvoiceRequestManager(request) i = sm.get_single_pk(True) assert isinstance(i, Invoice) return render(request, 'finance/print/SingleInvoice.html', {'i': i}) except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.message or e.args) return send_error(request, _('system error'))
def show_all_invoices(request): ia = check_ajax(request) if not (ia or request.GET.get('p') == '1' or request.GET.get('x') == '1'): service_groups = ServiceGroups.objects.filter(is_deleted=False) return render( request, 'finance/ShowAll.html', { 'service_groups': service_groups, 'get': request.GET, 'has_nav': True, 'pre_search': request.GET.urlencode() }) im = InvoiceRequestManager(request) return HttpResponse(im.get_all())
def get_float_service_items(request): try: im = InvoiceRequestManager(request) x = im.get_single_pk(True) if x.service.service_type != 12: return send_error(request, _('invalid invoice')) service = x.service.content_object options = service.fk_float_template_template.filter( is_deleted=False).values('price', 'total_price', 'value', 'option__name', 'option__group__name') res = {'service_name': service.service.name, 'options': list(options)} return HttpResponse(json.dumps(res)) except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.message or e.args) return send_error(request, _('system error'))
def get_updates_for_today(request): try: res = InvoiceRequestManager(request).today_data() return HttpResponse(json.dumps(res)) except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.message or e.args) return send_error(request, _('system error'))
def invoice_graph_analyze(request): try: res = InvoiceRequestManager.get_last_month_graph() return HttpResponse(json.dumps(res, default=date_get_day_only)) except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.args or e.message) return send_error(request, _('system error'))
def get_temp_charge_items(request): try: im = InvoiceRequestManager(request) x = im.get_single_pk(True) tmp = x.service.content_object res = { 'pk': tmp.pk, 'credit': tmp.credit, 'credit_price': tmp.credit_price, 'days': tmp.days, 'days_price': tmp.days_price } return HttpResponse(json.dumps(res)) except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.message or e.args) return send_error(request, _('system error'))
def update_invoice_comments(request): try: xm = InvoiceRequestManager(request) xm.set_post() xm.update_comments() return HttpResponse('200') except RequestProcessException as e: return e.get_response() except Exception as e: logger.error(e.message or e.args) return send_error(request, _('system error'))
def invoice_print_all(request): man = InvoiceRequestManager(request) res = man.search() total_price = res.aggregate(total_price=Sum('price')).get('total_price') return render(request, 'finance/print/print_all.html')