Skip to content

Commit

Permalink
Merge dfeca92 into 72796ec
Browse files Browse the repository at this point in the history
  • Loading branch information
rayrayndwiga committed Oct 26, 2017
2 parents 72796ec + dfeca92 commit 20b586f
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 45 deletions.
4 changes: 3 additions & 1 deletion ledger/payments/bpoint/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,12 @@ def last_digits(self):

@property
def bankcard(self):
return TempBankCard(
card = TempBankCard(
self.DVToken,
self.expiry_date.strftime("%m%y")
)
card.last_digits = self.last_digits
return card

def delete(self):
UsedBpointToken.objects.create(DVToken=self.DVToken)
Expand Down
20 changes: 20 additions & 0 deletions ledger/payments/migrations/0006_oracleinterfacesystem_enabled.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2017-10-26 02:32
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('payments', '0005_oracleinterfacesystem_percentage'),
]

operations = [
migrations.AddField(
model_name='oracleinterfacesystem',
name='enabled',
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions ledger/payments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class OracleInterface(models.Model):
class OracleInterfaceSystem(models.Model):
system_id = models.CharField(max_length=10)
system_name = models.CharField(max_length=128)
enabled = models.BooleanField(default=False)
deduct_percentage = models.BooleanField(default=False)
percentage = models.PositiveIntegerField(validators=[MaxValueValidator(99), MinValueValidator(1)],null=True,blank=True)
percentage_account_code = models.CharField(max_length=50,null=True,blank=True)
Expand Down
29 changes: 19 additions & 10 deletions ledger/payments/reports.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from six.moves import StringIO
import csv
import pytz
from datetime import timedelta
from decimal import Decimal as D
from ledger.payments.models import Invoice, CashTransaction, BpointTransaction, BpayTransaction

PERTH_TIMEZONE = pytz.timezone('Australia/Perth')

def daterange(start,end):
for n in range(int ((end-start).days) + 1):
yield start + timedelta(n)
Expand All @@ -18,7 +21,7 @@ def generate_items_csv(system,start,end,banked_start,banked_end,region=None,dist
items = []
oracle_codes = {}
banked_oracle_codes = {}
date_format = '%A %d/%m/%y'
date_format = '%d/%m/%y'

eftpos = []
banked_cash = []
Expand Down Expand Up @@ -59,6 +62,7 @@ def generate_items_csv(system,start,end,banked_start,banked_end,region=None,dist
invoices.append(invoice)
invoice_list.append(str(b.crn))

invoice_list = list(set(invoice_list))

if invoices:
strIO = StringIO()
Expand Down Expand Up @@ -101,7 +105,7 @@ def generate_items_csv(system,start,end,banked_start,banked_end,region=None,dist
# Loop through the payments and not the invoices
for i in invoices:
# Add items of invoice if not in list
if i.order and not i.voided:
if i.order:# and not i.voided:
if i.reference not in parsed_invoices.keys():
parsed_invoices[i.reference] = {'amount':i.amount,'paid':i.payment_amount,'refunded':i.refundable_amount}
for x in i.order.lines.all():
Expand Down Expand Up @@ -177,6 +181,7 @@ def generate_items_csv(system,start,end,banked_start,banked_end,region=None,dist
payment_details = item.get('item').payment_details
refund_details = item.get('item').refund_details
deduction_details = item.get('item').deduction_details

# Banked Cash
for d in item['banked_dates']:
index = 0
Expand Down Expand Up @@ -213,6 +218,7 @@ def generate_items_csv(system,start,end,banked_start,banked_end,region=None,dist
item[source] -= D(v)
banked_date_amounts[date_amount_index]['amounts'][source] -= D(v)


# Other transactions
for d in oracle_codes[code]:
index = 0
Expand Down Expand Up @@ -349,7 +355,7 @@ def generate_trans_csv(system,start,end,region=None,district=None):
invoices = Invoice.objects.filter(system=system)
if invoices:
strIO = StringIO()
fieldnames = ['Created', 'Payment Method', 'Transaction Type', 'Amount', 'Approved', 'Source', 'Product Names',
fieldnames = ['Created','Settlement Date', 'Payment Method', 'Transaction Type', 'Amount', 'Approved', 'Source', 'Product Names',
'Product Codes', 'Invoice']
writer = csv.DictWriter(strIO, fieldnames=fieldnames)
writer.writeheader()
Expand All @@ -374,17 +380,18 @@ def generate_trans_csv(system,start,end,region=None,district=None):
}'''
cash = i.cash_transactions.filter(created__gte=start, created__lte=end, district=district)
if not district:
bpoint = i.bpoint_transactions.filter(created__gte=start, created__lte=end)
bpoint = i.bpoint_transactions.filter(settlement_date__gte=start, settlement_date__lte=end)
bpay = i.bpay_transactions.filter(p_date__gte=start, p_date__lte=end)
# Write out the cash transactions
for c in cash:
if c.type not in ['move_in','move_out']:
cash_info = {
'Created': c.created.strftime('%Y-%m-%d'),
'Created': c.created.astimezone(PERTH_TIMEZONE).strftime('%d/%m/%Y %H:%M:%S'),
'Settlement Date': c.created.strftime('%d/%m/%Y'),
'Invoice': c.invoice.reference,
'Payment Method': 'Cash',
'Transaction Type': c.type.lower(),
'Amount': c.amount,
'Amount': c.amount if c.type not in ['refund','move_out'] else '-{}'.format(c.amount),
'Approved': 'True',
'Source': c.source,
'Product Names': item_names,
Expand All @@ -395,11 +402,12 @@ def generate_trans_csv(system,start,end,region=None,district=None):
# Write out all bpay transactions
for b in bpay:
bpay_info = {
'Created': b.created.strftime('%Y-%m-%d'),
'Created': b.created.astimezone(PERTH_TIMEZONE).strftime('%d/%m/%Y %H:%M:%S'),
'Settlement Date': b.p_date.strftime('%d/%m/%Y'),
'Invoice': b.crn,
'Payment Method': 'BPAY',
'Transaction Type': b.get_p_instruction_code_display(),
'Amount': b.amount,
'Amount': b.amount if b.p_instruction_code == '05' and b.type == '399' else '-{}'.format(b.amount),
'Approved': b.approved,
'Source': 'N/A',
'Product Names': item_names,
Expand All @@ -409,11 +417,12 @@ def generate_trans_csv(system,start,end,region=None,district=None):
# Write out all bpoint transactions
for bpt in bpoint:
bpoint_info = {
'Created': bpt.created.strftime('%Y-%m-%d'),
'Created': bpt.created.astimezone(PERTH_TIMEZONE).strftime('%d/%m/%Y %H:%M:%S'),
'Settlement Date': bpt.settlement_date.strftime('%d/%m/%Y'),
'Invoice': bpt.crn1,
'Payment Method': 'BPOINT',
'Transaction Type': bpt.action.lower(),
'Amount': bpt.amount,
'Amount': bpt.amount if bpt.action not in ['refund'] else '-{}'.format(bpt.amount),
'Approved': bpt.approved,
'Source': 'N/A',
'Product Names': item_names,
Expand Down
46 changes: 39 additions & 7 deletions ledger/payments/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ def oracle_parser(date,system,system_name,override=False):
ois = OracleInterfaceSystem.objects.get(system_id=system)
except OracleInterfaceSystem.DoesNotExist:
raise Exception('No system with id {} exists for integration with oracle'.format(system))
if not ois.enabled:
raise Exception('The oracle job is not enabled for {}'.format(ois.system_name))
with transaction.atomic():
op,created = OracleParser.objects.get_or_create(date_parsed=date)
bpoint_txns = []
Expand Down Expand Up @@ -475,7 +477,7 @@ def update_payments(invoice_reference):
refunded_amount = line.refunded
deducted_amount = line.deducted
amount = line.line_price_incl_tax
total_paid = i.payment_amount
total_paid = i.total_payment_amount
total_refund = i.refund_amount
total_deductions = i.deduction_amount
paid += paid_amount
Expand Down Expand Up @@ -649,19 +651,49 @@ def update_payments(invoice_reference):
first_item = i.order.lines.first()
# Bpoint
for b in i.bpoint_transactions:
if b.payment_allocated < b.amount:
if b.payment_allocated < b.amount and b.action == 'payment':
if first_item.payment_details['card'].get(str(b.id)):
first_item.payment_details['card'][str(b.id)] = str(D(first_item.payment_details['card'][str(b.id)]) + (b.amount - b.payment_allocated))
first_item.payment_details['card'][str(b.id)] = str(D(first_item.payment_details['card'][str(b.id)]) + (b.amount - b.payment_allocated))
else:
first_item.payment_details['card'][str(b.id)] = str(b.amount - b.payment_allocated)
# Bpay
for b in i.bpay_transactions:
if b.payment_allocated < b.amount:
if b.payment_allocated < b.amount and b.p_instruction_code == '05' and b.type == '399':
if first_item.payment_details['bpay'].get(str(b.id)):
first_item.payment_details['card'][str(b.id)] = str(D(first_item.payment_details['bpay'][str(b.id)]) + (b.amount - b.payment_allocated))
first_item.payment_details['bpay'][str(b.id)] = str(D(first_item.payment_details['bpay'][str(b.id)]) + (b.amount - b.payment_allocated))
else:
first_item.payment_details['bpay'][str(b.id)] = str(b.amount - b.payment_allocated)
# Cash
for b in i.cash_transactions.all():
if b.payment_allocated < b.amount:
if b.payment_allocated < b.amount and b.type in ['payment','move_in']:
if first_item.payment_details['cash'].get(str(b.id)):
first_item.payment_details['card'][str(b.id)] = str(D(first_item.payment_details['cash'][str(b.id)]) + (b.amount - b.payment_allocated))
first_item.payment_details['cash'][str(b.id)] = str(D(first_item.payment_details['cash'][str(b.id)]) + (b.amount - b.payment_allocated))
else:
first_item.payment_details['cash'][str(b.id)] = str(b.amount - b.payment_allocated)
first_item.save()
if i.refund_amount > refunded:
first_item = i.order.lines.first()
# Bpoint
for b in i.bpoint_transactions:
if b.refund_allocated < b.amount and b.action == 'refund':
if first_item.refund_details['card'].get(str(b.id)):
first_item.refund_details['card'][str(b.id)] = str(D(first_item.refund_details['card'][str(b.id)]) + (b.amount - b.refund_allocated))
else:
first_item.refund_details['card'][str(b.id)] = str(b.amount - b.refund_allocated)
# Bpay
for b in i.bpay_transactions:
if b.refund_allocated < b.amount and b.p_instruction_code == '25' and b.type == '699':
if first_item.refund_details['bpay'].get(str(b.id)):
first_item.refund_details['bpay'][str(b.id)] = str(D(first_item.refund_details['bpay'][str(b.id)]) + (b.amount - b.refund_allocated))
else:
first_item.refund_details['bpay'][str(b.id)] = str(b.amount - b.refund_allocated)
# Cash
for b in i.cash_transactions.all():
if b.refund_allocated < b.amount and b.type == 'refund':
if first_item.refund_details['cash'].get(str(b.id)):
first_item.refund_details['cash'][str(b.id)] = str(D(first_item.refund_details['cash'][str(b.id)]) + (b.amount - b.refund_allocated))
else:
first_item.refund_details['cash'][str(b.id)] = str(b.amount - b.refund_allocated)
first_item.save()
except:
print(traceback.print_exc())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<div class="col-lg-12">
<h3 class="text-primary">Campsite Booking</h3>
<p>
Click <a href="https://parks-oim.dpaw.wa.gov.au/park-stay">here</a> to open the map of the campground to help you select the preferred campsite
Click <a target="_blank" :href="campground.campground_map">here</a> to open the map of the campground to help you select the preferred campsite
</p>
<ul class="nav nav-tabs">
<li :class="{active:campground.site_type == 0}" v-show="campground.site_type == 0" ><a data-toggle="tab" href="#campsite-booking" @click.prevent="booking_type=booking_types.CAMPSITE">Campsite</a></li>
Expand Down
2 changes: 1 addition & 1 deletion parkstay/static/parkstay/js/parkstay.js

Large diffs are not rendered by default.

51 changes: 26 additions & 25 deletions parkstay/static/parkstay/js/vendor.js

Large diffs are not rendered by default.

0 comments on commit 20b586f

Please sign in to comment.