コード例 #1
0
    def handle(self, *args, **options):

        skaters = Skater.objects.all()

        self.stdout.write("".ljust(35) + "STATUS\tCURRENT BAL\tADJUSTMENT\tFIXED BALANCE")

        for skater in skaters:
            
            if skater.status.name == "active":
                fix = 17
            elif skater.status.name == "injured" or skater.status.name == "social":
                fix = 10
            else:
                fix = 0
            

            self.stdout.write(skater.get_short_name().ljust(35) + skater.status.name + "\t" + str(skater.balance) + "\t" + str(fix) + "\t" + str(skater.balance - fix))

            receipt = Receipt(
                    skater = skater,
                    amount = float(fix),
                    fee = 0,
                    method = "cash",
                    method_detail = "Partial May Dues - Credit",
                    date = datetime.now(),
            )
            receipt.save()

            skater.balance = skater.balance - fix
            skater.save()
コード例 #2
0
ファイル: tests.py プロジェクト: glukagen/titanfile
 def getReceipt(self, subscription, amount):    
     ''' create receipt with initial subscription and amount'''
     receipt = Receipt(amount=amount, user_created=subscription.owner, monthly_fee=0,
                 tax_rate=0, tax_amount=0, transaction_id=random.random(),
             subtotal=0, total=0, amount_paid=0, subscription_id=subscription.id, plan_id=1)
     receipt.save()
     return receipt
コード例 #3
0
def skater_tools_payment(request, skater_id):
    if not request.user.is_admin:
        return render(request, 'rink/access_denied.html')
    
    try:
        skater = Skater.objects.get(pk=skater_id)
    except Skater.DoesNotExist:
        return render(request, 'rink/access_denied.html')
    
    if request.method == 'POST':
        form = AdminSkaterPaymentForm(request.POST)
        if form.is_valid():
            receipt = Receipt(
                    skater = skater,
                    amount = float(form.cleaned_data["amount"]),
                    fee = 0,
                    method = form.cleaned_data["method"],
                    method_detail = form.cleaned_data["notes"],
                    date = datetime.now(),
                )
            receipt.save()

            skater.balance = skater.balance - form.cleaned_data["amount"]
            skater.save()

            skater.set_unpaid_invoices_paid(form.cleaned_data["amount"]) 

            request.session["payment_success"] = "<b>Payment Received</b> - " + form.cleaned_data["method"] + " of $" + str(form.cleaned_data["amount"])
        else:
            request.session["payment_error"] = "<b>Invalid payment</b> - You may have missed something on the form. Please try again."

    return HttpResponseRedirect(reverse('rink.views.skater_tools', kwargs={"skater_id": skater.id } ))