def post(self, request): start_date = parse_date(request.POST['stdt']) end_date = parse_date(request.POST['endt']) if start_date > end_date: raise Exception('Start date must be less than end date') queryset = TIPostingStatusReport.objects.filter( posting_date__gte=start_date, posting_date__lte=end_date).exclude(ccy='NGN').exclude( ref__startswith='CBN') if queryset.exists(): wb = Workbook() sh = wb.add_sheet('Ti Contingent Non Post') row = 0 seq = 1 wrow( sh, row, ( 'SEQ', 'LC NUMBER', 'POSTING DATE', 'ACCOUNT NUMBER', 'CCY', 'AMOUNT', 'APPLICANT', 'POST STATUS',)) row += 1 for post in queryset: if not (post.is_customer_acct() or post.is_vat_acct() or post.is_income_acct() or post.post_success()): wrow(sh, row, (seq, post.ref, post.posting_date, post.acct_number, post.ccy, post.amount, post.applicant, str(post.post_success()))) row += 1 seq += 1 response = HttpResponse() response['Content-type'] = 'application/xls' response['Content-Disposition'] = \ 'attachment; filename="contingent-nonpost.xls"' wb.save(response) return response
def post(self, request): self.end_date = parse_date(request.POST['endt']) self.response = HttpResponse(content_type='application/xls') self.response['Content-Disposition'] = \ 'attachment; filename="%s-%s"' % (self.end_date, self.download_file_name,) self.contingent_accounts_asset = ContingentAccount.objects.filter(in_use=True, acct_class='ASSET') self.contingent_accounts_asset_gl_codes = self.contingent_accounts_asset.values_list('gl_code', flat=True) conts = ContingentReport.objects.filter( gl_code__in=self.contingent_accounts_asset_gl_codes, booking_date__lte=self.end_date).exclude(ti_ref__isnull=True) self.lc_references = set(conts.values_list('ti_ref', flat=True)) self.ccys = set(conts.values_list('ccy', flat=True)) self.wb = Workbook()