Skip to content

Commit

Permalink
Merge pull request #675 from xzzy/master
Browse files Browse the repository at this point in the history
Latest Mooring Bug Fixes
  • Loading branch information
dbca-asi committed Aug 2, 2019
2 parents df10555 + ab7ff29 commit e143778
Show file tree
Hide file tree
Showing 27 changed files with 1,842 additions and 338 deletions.
2 changes: 1 addition & 1 deletion commercialoperator/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
EMAIL_FROM = DEFAULT_FROM_EMAIL

OSCAR_BASKET_COOKIE_OPEN = 'cols_basket'
os.environ['LEDGER_CUSTOM_PRODUCT_LIST'] = "('ledger_description','quantity','price_incl_tax','price_excl_tax','oracle_code')"
os.environ['LEDGER_PRODUCT_CUSTOM_FIELDS'] = "('ledger_description','quantity','price_incl_tax','price_excl_tax','oracle_code')"

BASE_URL=env('BASE_URL')

Expand Down
18 changes: 10 additions & 8 deletions ledger/checkout/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,21 +374,23 @@ def createCustomBasket(product_list, owner, system,vouchers=None, force_flush=Tr
basket.strategy = selector.strategy(user=owner)
basket.custom_ledger = True
# Check if there are products to be added to the cart and if they are valid products
ledger_custom_product_list = env('LEDGER_CUSTOM_PRODUCT_LIST', None)
defaults = ('ledger_description','quantity','price_incl_tax','oracle_code')
# EXAMPLE config for settings.py: os.environ['LEDGER_CUSTOM_PRODUCT_LIST'] = "('ledger_description','quantity','price_incl_tax','price_excl_tax','oracle_code','line_status')"
# you can import def calculate_excl_gst and use this funcation to calculate the mount with out gst on line items that have gst component.
ledger_product_custom_fields = env('LEDGER_PRODUCT_CUSTOM_FIELDS', None)
ledger_product_default_fields = ('ledger_description','quantity','price_incl_tax','oracle_code')

UPDATE_PAYMENT_ALLOCATION = env('UPDATE_PAYMENT_ALLOCATION', False)
if UPDATE_PAYMENT_ALLOCATION is True:
defaults = ('ledger_description','quantity','price_incl_tax','oracle_code','line_status')
ledger_product_default_fields = ('ledger_description','quantity','price_incl_tax','oracle_code','line_status')

if ledger_custom_product_list:
defaults = ledger_custom_product_list
if ledger_product_custom_fields:
ledger_product_default_fields = ledger_product_custom_fields

for p in product_list:
if not all(d in p for d in defaults):
if not all(d in p for d in ledger_product_default_fields):
raise ValidationError('Please make sure that the product format is valid')
if ledger_custom_product_list:
if 'price_excl_tax' in ledger_custom_product_list:
if ledger_product_custom_fields:
if 'price_excl_tax' in ledger_product_custom_fields:
# dont calculate tax as this should be included in the product list
pass
else:
Expand Down
2 changes: 2 additions & 0 deletions ledger/payments/static/payments/js/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,12 @@ $(function(){
var balance = '$'+formatMoney(invoice_obj.balance);
var amount_paid = '$'+formatMoney(invoice_obj.payment_amount);
var refundable_amount = '$'+formatMoney(invoice_obj.refundable_amount);
var invoice_date = invoice_obj.created;
// Top banner
$('#invoice_status').html(formatStatus(status));
$('#invoice_balance').html(balance);
$('#invoice_paid').html(amount_paid);
$('#invoice_date').html(invoice_date);
$('.refundable_amount').html(refundable_amount);
// Individual Invoice
$("strong.invoice_status[data-reference='"+invoice+"']").html(formatStatus(status));
Expand Down
16 changes: 10 additions & 6 deletions ledger/payments/templates/dpaw_payments/invoice/payment.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
{% endfor %}
</select>
</div>
<div class="float-right status"> Status: <strong id="invoice_status">{{invoices.0.payment_status}}</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Amount Outstanding: <strong id="invoice_balance">${{invoices.0.balance}}</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Amount
Paid: <strong id="invoice_paid">${{invoices.0.payment_amount}}</strong></div>
<div class="float-right status"> Status: <strong id="invoice_status">{{invoices.0.payment_status}}</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Amount Outstanding: <strong id="invoice_balance">${{invoices.0.balance}}</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Amount Paid: <strong id="invoice_paid">${{invoices.0.payment_amount}}</strong>&nbsp;&nbsp;Invoice Date: <strong id='invoice_date'>{{invoices.0.created }}</strong></div>
</div>
</div>
</div>
Expand All @@ -107,8 +106,7 @@
<div class="row">
<div class="columns small-12">
<div class="primary callout" data-closable="slide-out-right">
<p class="text-center invoice_details" data-reference={{invoice.reference}}>Invoice <strong>{{invoice.reference}}</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Status: <strong class="invoice_status" data-reference={{invoice.reference}}>{{invoice.payment_status}}</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Amount
Outstanding: <strong class="invoice_balance" data-reference={{invoice.reference}}>${{invoice.balance}}</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Amount Paid: <strong class="invoice_paid" data-reference={{invoice.reference}}>${{invoice.payment_amount}}</strong></p>
<p class="text-center invoice_details" data-reference={{invoice.reference}}>Invoice <strong>{{invoice.reference}}</strong>&nbsp;&nbsp;&nbsp;&nbsp;Status: <strong class="invoice_status" data-reference={{invoice.reference}}>{{invoice.payment_status}}</strong>&nbsp;&nbsp;&nbsp;&nbsp;Amount Outstanding: <strong class="invoice_balance" data-reference={{invoice.reference}}>${{invoice.balance}}</strong>&nbsp;&nbsp;&nbsp;&nbsp;Amount Paid: <strong class="invoice_paid" data-reference={{invoice.reference}}>${{invoice.payment_amount}}</strong>&nbsp;&nbsp;Invoice Date: <strong>{{invoice.created }}</strong></p>
</div>
</div>
</div>
Expand Down Expand Up @@ -214,7 +212,7 @@
<div class="columns large-12">
<form id="other_form" class="{% if invoices.0.payment_status == 'paid' or invoices.0.payment_status == 'over_paid' or invoices.0.voided %}hide{% endif %}">
<h3> Record Payment</h3>
<label>
<label>
Amount
<input class="money" id="other_amount" name="other_amount" type="text" value=""/>
</label>
Expand Down Expand Up @@ -264,6 +262,7 @@ <h3> Record Payment</h3>
</form>
</div>
</div>
<!-- START Refund Interface -->
<div class="large reveal" id="refundModal" data-reveal>
<div id="refundLoader">
<p class="text-center"><i class="fa fa-spin fa-spinner fa-2x"></i><br />Loading...</p>
Expand Down Expand Up @@ -336,6 +335,8 @@ <h3 class="text-center">Refund</h3>
</div>
</form>
</div>
<!-- END Refund Interface -->

<div class="row">
<div class="large-12 columns">
<h3>Received Payments</h3>
Expand All @@ -359,7 +360,10 @@ <h3>Received Payments</h3>
</table>
<div class="row align-right">
<div class="large-4 columns">
<button id="refund_btn" class="{% if not invoices.0.refundable%}hide{% endif %} button float-right">Refund</button>
{% if payment_allocation == True %}
{% else %}
<button id="refund_btn" class="{% if not invoices.0.refundable%}hide{% endif %} button float-right">Refund</button>
{% endif %}
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions ledger/payments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from ledger.payments.models import Invoice
from ledger.payments.mixins import InvoiceOwnerMixin
#
from confy import env
#

class InvoicePDFView(InvoiceOwnerMixin,generic.View):
def get(self, request, *args, **kwargs):
Expand Down Expand Up @@ -69,6 +71,8 @@ def year_choices(self):
def get_context_data(self, **kwargs):
ctx = super(InvoicePaymentView, self).get_context_data(**kwargs)
invoices = []
UPDATE_PAYMENT_ALLOCATION = env('UPDATE_PAYMENT_ALLOCATION', False)
ctx['payment_allocation'] = UPDATE_PAYMENT_ALLOCATION
ctx['bpay_allowed'] = settings.BPAY_ALLOWED
ctx['months'] = self.month_choices
ctx['years'] = self.year_choices
Expand Down
Loading

0 comments on commit e143778

Please sign in to comment.