recount_payments.py 714 Bytes
#-*- coding:utf-8 -*-

from django.core.management.base import BaseCommand

from accounts.models import RealizedPhraseology

class Command(BaseCommand):
    args = 'none'
    help = 'Recount phraseology payments.'

    def handle(self, **options):
        recount_payments()

def recount_payments():
    for real_phras in RealizedPhraseology.objects.all():
        cash = 0.0
        cash += (float(real_phras.new_frames)*7.0)
        cash += (float(real_phras.reused_frames)*2.0)
        cash += (float(real_phras.prop_frames)*0.5)
        cash += (float(real_phras.corr_frames)*7.0)
        cash += (float(real_phras.ncorr_frames)*4.0)
        print cash
        real_phras.cash = cash
        real_phras.save()