示例#1
0
 def preview_invoices(self, request, permanence_qs):
     valid_permanence_qs = permanence_qs.filter(
         status__in=[PERMANENCE_INVOICED, PERMANENCE_ARCHIVED])
     wb = None
     first = True
     for permanence in valid_permanence_qs:
         if first:
             wb = export_bank(permanence=permanence,
                              wb=wb,
                              sheet_name=slugify(permanence))
         wb = export_invoice(permanence=permanence,
                             wb=wb,
                             sheet_name=slugify(permanence))
         if first:
             wb = export_permanence_stock(permanence=permanence,
                                          wb=wb,
                                          ws_customer_title=None)
             first = False
     if wb is not None:
         response = HttpResponse(
             content_type=
             'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
         )
         response[
             'Content-Disposition'] = "attachment; filename={0}-{1}.xlsx".format(
                 slugify(_("Accounting report")),
                 repanier.apps.REPANIER_SETTINGS_GROUP_NAME)
         wb.save(response)
         return response
     user_message = _("No invoice available for %(permanence)s.") % {
         'permanence': ', '.join("%s" % p for p in permanence_qs.all())
     }
     user_message_level = messages.WARNING
     self.message_user(request, user_message, user_message_level)
     return
示例#2
0
 def preview_invoices(self, request, permanence_qs):
     valid_permanence_qs = permanence_qs.filter(
         status__in=[PERMANENCE_INVOICED, PERMANENCE_ARCHIVED]
     )
     wb = None
     first = True
     for permanence in valid_permanence_qs:
         if first:
             wb = export_bank(permanence=permanence, wb=wb, sheet_name=permanence)
         wb = export_invoice(permanence=permanence, wb=wb, sheet_name=permanence)
         if first:
             wb = export_permanence_stock(permanence=permanence, wb=wb, ws_customer_title=None)
             first = False
     if wb is not None:
         response = HttpResponse(
             content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
         response['Content-Disposition'] = "attachment; filename={0}-{1}.xlsx".format(
             _("Accounting report"),
             settings.REPANIER_SETTINGS_GROUP_NAME
         )
         wb.save(response)
         return response
     user_message = _("No invoice available for %(permanence)s.") % {
         'permanence': ', '.join("{}".format(p) for p in permanence_qs.all())}
     user_message_level = messages.WARNING
     self.message_user(request, user_message, user_message_level)
     return
示例#3
0
 def accounting_report(self, request, permanence_id, permanence=None):
     wb = export_bank(permanence=permanence, wb=None, sheet_name=permanence)
     wb = export_invoice(permanence=permanence,
                         wb=wb,
                         sheet_name=permanence)
     wb = export_permanence_stock(permanence=permanence,
                                  wb=wb,
                                  ws_customer_title=None)
     if wb is not None:
         response = HttpResponse(
             content_type=
             "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
         )
         response[
             "Content-Disposition"] = "attachment; filename={0}-{1}.xlsx".format(
                 _("Accounting report"),
                 settings.REPANIER_SETTINGS_GROUP_NAME)
         wb.save(response)
         return response
     user_message = _("No invoice available for {permanence}.'.").format(
         permanence=permanence)
     user_message_level = messages.WARNING
     self.message_user(request, user_message, user_message_level)
     return HttpResponseRedirect(self.get_redirect_to_change_list_url())