Esempio n. 1
0
File: admin.py Progetto: marcyyy/tps
def make_paid(modeladmin, request, queryset):
    for obj in queryset:
        if obj.status != "Paid":
            queryset.update(
                status='Paid',
                isactive='',
            )
            messages.success(request,
                             "Billing #" + str(obj.id) + " Successfully Paid.")

            from myResidence.forms import AdminLogsForm
            date_time = datetime.now()
            admin = 1
            tenant = obj.tenant
            activity = "Billing"
            action = "Billing #" + str(obj.id) + " updated as paid."

            data = {
                'date_time': date_time,
                'admin': admin,
                'tenant': tenant,
                'activity': activity,
                'action': action,
                'is_active': 'True',
            }
            form = AdminLogsForm(data)

            print(form.errors)
            if form.is_valid():
                form.save()
        else:
            messages.error(request,
                           "Billing Record #" + str(obj.id) + " already paid.")
Esempio n. 2
0
File: admin.py Progetto: marcyyy/tps
def make_scheduled(modeladmin, request, queryset):
    for obj in queryset:
        if obj.status == "Pending":
            queryset.update(
                status='Scheduled',
                isactive='True',
            )
            messages.success(
                request,
                "Repair Request #" + str(obj.id) + " updated as Scheduled.")

            from myResidence.forms import AdminLogsForm
            date_time = datetime.now()
            admin = 1
            tenant = obj.tenant
            activity = "Repair"
            action = "Repair Request #" + str(obj.id) + " scheduled."

            data = {
                'date_time': date_time,
                'admin': admin,
                'tenant': tenant,
                'activity': activity,
                'action': action,
                'is_active': 'True',
            }
            form = AdminLogsForm(data)

            print(form.errors)
            if form.is_valid():
                form.save()
        else:
            messages.success(
                request,
                "Repair Request #" + str(obj.id) + " already processed.")
Esempio n. 3
0
File: admin.py Progetto: marcyyy/tps
def make_approved_deposit(modeladmin, request, queryset):
    for obj in queryset:
        if obj.status == "Pending":
            if TenantContract.objects.filter(tenant=obj.tenant):
                contract = TenantContract.objects.get(tenant=obj.tenant)
                init_dep = float(contract.deposit)
                billing_fee = float(obj.billing_fee)
                remain_dep = init_dep - billing_fee

                if remain_dep > 0:
                    Billing.objects.filter(id=obj.id).update(
                        status='Paid',
                        isactive='',
                    )
                    TenantContract.objects.filter(tenant=obj.tenant).update(
                        deposit=remain_dep)

                    from myResidence.forms import AdminLogsForm
                    date_time = datetime.now()
                    admin = 1
                    tenant = obj.tenant
                    activity = "Billing"
                    action = "Billing #" + str(obj.id) + " paid with deposit."

                    data = {
                        'date_time': date_time,
                        'admin': admin,
                        'tenant': tenant,
                        'activity': activity,
                        'action': action,
                        'is_active': 'True',
                    }
                    form = AdminLogsForm(data)

                    print(form.errors)
                    if form.is_valid():
                        form.save()

                    messages.success(
                        request, "Billing #" + str(obj.id) +
                        " Successfully Paid with Deposit.")
                else:
                    messages.error(request, "Tenant Deposit is Insufficient.")
            else:
                messages.error(request, "Tenant have no deposit.")
        else:
            messages.error(request,
                           "Billing Record #" + str(obj.id) + " already paid.")
Esempio n. 4
0
File: admin.py Progetto: marcyyy/tps
def make_approved_proof(modeladmin, request, queryset):
    for obj in queryset:
        if obj.status == "Pending":
            Billing.objects.filter(id=obj.billing.id).update(
                status='Paid',
                isactive='',
            )
            ProofOfPayment.objects.filter(id=obj.id).update(
                status='Approved',
                isactive='',
            )
            messages.success(request,
                             "Proof of Payment #" + str(obj.id) + " Approved.")

            from myResidence.forms import AdminLogsForm
            date_time = datetime.now()
            admin = 1
            tenant = obj.tenant
            activity = "Proof of Payment"
            action = "Proof of Payment #" + str(obj.id) + " approved."

            data = {
                'date_time': date_time,
                'admin': admin,
                'tenant': tenant,
                'activity': activity,
                'action': action,
                'is_active': 'True',
            }
            form = AdminLogsForm(data)

            print(form.errors)
            if form.is_valid():
                form.save()
        else:
            messages.error(
                request,
                "Proof of Payment #" + str(obj.id) + " already processed.")