def share_pain001(request): if request.method != 'POST': raise Http404 now = timezone.now() response = HttpResponse(content_type='text/xml') response[ 'Content-Disposition'] = 'attachment; filename = "share_pain' + now.strftime( '%y_%m_%d_%H_%M') + '.xml"' t = loader.get_template('iso20022/share_pain.001.xml') share_ids = request.POST.get('share_ids').split('_') shares = [get_object_or_404(Share, id=int(sid)) for sid in share_ids] payable_shares = [ share for share in shares if share.member.iban is not None and share.member.iban != '' ] context = { 'shares': payable_shares, 'nmbr_of_tx': len(payable_shares), 'amount': Config.share_price(), 'total_amount': len(payable_shares) * int(Config.share_price()), 'banking_info': Config.organisation_bank_connection(), 'version': '1.1.8', 'now': now, 'name': Config.organisation_long_name(), } response.write(t.render(context)) return response
def bill_share(share): now = timezone.now() price = float(Config.share_price()) refnumber = generate_ref_number('share', share.id, share.member.id) bill = Bill.objects.create(billable=share, amount=price, ref_number=refnumber, bill_date=now) send_bill_share(bill, share, share.member)