Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update deduction amount and campsites status #467

Merged
merged 3 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions ledger/accounts/migrations/0014_auto_20181030_1433.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-10-30 06:33
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('accounts', '0013_auto_20180207_1210'),
]

operations = [
migrations.AlterField(
model_name='address',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='profile_addresses', to=settings.AUTH_USER_MODEL),
),
]
19 changes: 19 additions & 0 deletions ledger/payments/migrations/0021_auto_20181030_1433.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-10-30 06:33
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('payments', '0020_auto_20181026_1611'),
]

operations = [
migrations.AlterUniqueTogether(
name='oracleinterfacededuction',
unique_together=set([('oisystem', 'percentage_account_code', 'destination_account_code')]),
),
]
3 changes: 3 additions & 0 deletions ledger/payments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class OracleInterfaceDeduction(models.Model):
percentage_account_code = models.CharField(max_length=50,null=True,blank=True)
destination_account_code = models.CharField(max_length=50,null=True,blank=True)

class Meta:
unique_together = ('oisystem', 'percentage_account_code', 'destination_account_code')

def __str__(self):
return '{} - {}'.format(self.oisystem, self.destination_account_code)

Expand Down
56 changes: 29 additions & 27 deletions ledger/payments/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,36 +115,38 @@ def addToInterface(date,oracle_codes,system,override):
raise ValidationError('{} is not a valid account code'.format(k))

# Check if there is a deduction for that system/account code, and sends to another oracle account code
deduction = OracleInterfaceDeduction.objects.filter(oisystem=system, percentage_account_code=k).first()
deduction_qs = OracleInterfaceDeduction.objects.filter(oisystem=system, percentage_account_code=k)

if deduction and system.deduct_percentage:

if (not deduction.percentage or not deduction.destination_account_code):
raise Exception('Deduction Percentage and an oracle account are required if deduction is enabled.')
if deduction_qs and system.deduct_percentage:
initial_amount = D(v)
remainder_amount = initial_amount

deduction_code = None
try:
OracleAccountCode.objects.filter(active_receivables_activities=deduction.destination_account_code)
except OracleAccountCode.DoesNotExist:
raise ValidationError('The account code setup for oracle deduction does not exist.')
# Add the deducted amount to the oracle code specified in the system table
deduction_code = OracleInterface(
receipt_date = trans_date,
activity_name = deduction.destination_account_code,
amount = D(0.0),
customer_name = system.system_name,
description = deduction.destination_account_code,
source = system.source,
method = system.method,
comments = '{} GST/{}'.format(deduction.destination_account_code,date),
status = 'NEW',
status_date = today
)
deduction_code.save()
for deduction in deduction_qs:
if (not deduction.percentage or not deduction.destination_account_code):
raise Exception('Deduction Percentage and an oracle account are required if deduction is enabled.')

deduction_code = None
try:
OracleAccountCode.objects.filter(active_receivables_activities=deduction.destination_account_code)
except OracleAccountCode.DoesNotExist:
raise ValidationError('The account code setup for oracle deduction does not exist.')
# Add the deducted amount to the oracle code specified in the system table
deduction_amount = deduction.percentage * initial_amount / D(100)
deduction_code = OracleInterface(
receipt_date = trans_date,
activity_name = deduction.destination_account_code,
amount = deduction_amount,
customer_name = system.system_name,
description = deduction.destination_account_code,
source = system.source,
method = system.method,
comments = '{} GST/{}'.format(deduction.destination_account_code,date),
status = 'NEW',
status_date = today
)
deduction_code.save()
remainder_amount -= deduction_amount

initial_amount = D(v)
remainder_amount = ((100 - deduction.percentage)/ D(100)) * initial_amount
deduction_code.amount += initial_amount - remainder_amount
# Add the remainaing amount to the intial oracle account code
OracleInterface.objects.create(
receipt_date = trans_date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div class="col-md-8" v-if="campsites.length > 0"></div>
<div class="col-md-8" >
<select class="form-control" style="width: 100%;" id="multi-campsites" name="campground" placeholder="" multiple v-model="selected_campsites">
<option v-for="c in campsites" v-bind:value="c.id">{{c.name}}</option>
<option v-for="c in campsites" v-bind:value="c.id">{{c.name}} - {{c.status}}</option>
</select>
</div>
<div class="col-md-8" v-else>
Expand Down
2 changes: 1 addition & 1 deletion parkstay/static/parkstay/js/parkstay.js

Large diffs are not rendered by default.