Skip to content

Commit

Permalink
Merge 3def709 into 6282185
Browse files Browse the repository at this point in the history
  • Loading branch information
scottp-dpaw committed Mar 29, 2018
2 parents 6282185 + 3def709 commit b76fa76
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 68 deletions.
2 changes: 2 additions & 0 deletions ledger/checkout/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def validate_ledger(self,details):
except ValidationError as e:
raise e
self.checkout_session.set_last_check(details.get('check_url'))
else:
self.checkout_session.set_last_check('')
return True

def __validate_send_email(self, details):
Expand Down
5 changes: 5 additions & 0 deletions ledger/payments/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ def create(self, request):
'checkoutWithToken', 'bpay_format', 'icrn_format', 'invoice_text', 'check_url'
]
url_args = {f: six.text_type(serializer.validated_data[f]).encode('utf8') for f in fields if f in serializer.validated_data and serializer.validated_data[f] is not None}
# bodges for nullable fields
for f in ['basket_owner', 'check_url', 'return_preload_url']:
if f not in url_args:
url_args[f] = ''

redirect = HttpResponseRedirect(reverse('checkout:index')+'?'+six.moves.urllib.parse.urlencode(url_args))
# inject the current basket into the redirect response cookies
# or else, anonymous users will be directionless
Expand Down
1 change: 1 addition & 0 deletions parkstay/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@ class OutstandingBookingRecipient(admin.ModelAdmin):
admin.site.register(models.Region)
admin.site.register(models.District)
admin.site.register(models.PromoArea)
admin.site.register(models.DiscountReason)
77 changes: 33 additions & 44 deletions parkstay/frontend/parkstay/src/components/booking/addbooking.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<thead>
<tr>
<th class="site">Campsite</th>
<th class="numBook">Number of sites to book</th>
<th class="numBook">Sites to book</th>
</tr>
</thead>
<tbody><template v-for="campsite in booking.campsites">
Expand All @@ -100,7 +100,7 @@
<div class="col-lg-12">
<div id="campsite-class-booking" v-if="(campground.site_type == 1) || (campground.site_type == 2)">
<div class="row">
<div v-show="campsite_classes.length < 1" class="col-lg-12 text-center">
<div v-show="booking.campsite_classes.length < 1" class="col-lg-12 text-center">
<h2>No Campsites Available For The Provided Dates</h2>
</div>
</div>
Expand All @@ -109,7 +109,7 @@
</div>
<div class="row">
<div class="col-sm-12">
<div v-show="campsite_classes.length > 1">
<div v-show="booking.campsite_classes.length > 1">
<div class="column table-scroll">
<table class="hover table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%" name="campsite-type" v-model="selected_campsite_class">
<thead>
Expand All @@ -119,12 +119,12 @@
<th class="numBook">Number of sites to book</th>
</tr>
</thead>
<tbody><template v-for="c in campsite_classes">
<tbody><template v-for="c in booking.campsite_classes">
<tr>
<td class="site"> {{c.name}} <span v-if="c.class"> - {{ classes[c.class] }}</span></td>
<td class="book"> {{ c.campsites.length }} available </td>
<td class="numBook">
<input type="number" name="campsite-type" class="form-control" v-model="c.selected_campsite_class">
<input type="number" name="campsite-type" class="form-control" v-model="c.selected_campsite_class" @change="updatePrices()">
</td>
</tr></template>
</tbody>
Expand Down Expand Up @@ -366,6 +366,7 @@ export default {
},
campground:"",
campsites: [],
campsite_classes:[],
email:"",
firstname:"",
surname:"",
Expand Down Expand Up @@ -468,7 +469,6 @@ export default {
stayHistory:[],
arrivalPicker: {},
departurePicker: {},
campsite_classes:[],
selected_campsite_class:-1,
booking_type:"campsite",
booking_types:{
Expand All @@ -494,11 +494,21 @@ export default {
},
selected_campsites: function () {
let vm = this;
return vm.booking.campsites.filter(function (el) {
return el.is_selected;
}).map(function (el) {
return el.id
});
if (vm.booking_type == vm.booking_types.CAMPSITE) {
return vm.booking.campsites.filter(function (el) {
return el.is_selected;
}).map(function (el) {
return el.id
});
}else{
var results = [];
vm.booking.campsite_classes.forEach(function (el) {
for (var i=0; i<el.selected_campsite_class; i++) {
results.push(el.campsites[i]);
}
});
return results;
}
}
},
filters: {
Expand All @@ -519,7 +529,7 @@ export default {
},
selected_campsite_class:function () {
let vm =this;
vm.selected_campsite =vm.campsite_classes[vm.selected_campsite_class].campsites[0];
vm.selected_campsite =vm.booking.campsite_classes[vm.selected_campsite_class].campsites[0];
},
selected_arrival:function () {
let vm = this;
Expand Down Expand Up @@ -561,7 +571,6 @@ export default {
},
updatePrices:function () {
let vm = this;
vm.booking.campsite = vm.selected_campsite;
vm.booking.price = 0;
console.log(vm.selected_campsites)
var campsite_ids = vm.selected_campsites;
Expand All @@ -585,22 +594,6 @@ export default {
},(error)=>{
console.log(error);
});
}else{
vm.$http.post(
api_endpoints.campsites_current_price(),
{
campsites: campsite_ids,
arrival: arrival.format("YYYY-MM-DD"),
departure: departure.format("YYYY-MM-DD")
},
{headers: {'X-CSRFToken': helpers.getCookie('csrftoken')}}
).then((response)=>{
vm.priceHistory = null;
vm.priceHistory = response.body;
vm.generateBookingPrice();
},(error)=>{
console.log(error);
});
}
}
},
Expand Down Expand Up @@ -639,10 +632,14 @@ export default {
let vm = this;
if(vm.selected_arrival && vm.selected_departure){
vm.loading.push('fetching campsite classes');
vm.$http.get(api_endpoints. available_campsite_classes(vm.booking.campground,vm.booking.arrival,vm.booking.departure)).then((response)=>{
vm.campsite_classes = response.body;
if (vm.campsite_classes.length >0) {
vm.selected_campsite =vm.campsite_classes[0].campsites[0];
vm.$http.get(api_endpoints. available_campsite_classes(
vm.booking.campground,
Moment(vm.booking.arrival, "YYYY-MM-DD").format("YYYY/MM/DD"),
Moment(vm.booking.departure, "YYYY-MM-DD").format("YYYY/MM/DD")
)).then((response)=>{
vm.booking.campsite_classes = response.body;
if (vm.booking.campsite_classes.length >0) {
vm.selected_campsite =vm.booking.campsite_classes[0].campsites[0];
vm.selected_campsite_class = 0;
}
vm.loading.splice('fetching campsite classes',1);
Expand Down Expand Up @@ -793,21 +790,13 @@ export default {
},
generateBookingPrice:function () {
let vm =this;
vm.booking.price = 0;
var campsite_count = vm.booking.campsites.reduce(function (acc, el) {
if (el.is_selected) {
return acc + 1;
}
return acc;
}, 0)
console.log('campsite count is')
console.log(campsite_count)
vm.booking.price = 0;
if (vm.park.entry_fee_required){
vm.fetchParkPrices(function(){
$.each(vm.priceHistory,function (i,price) {
for (var guest in vm.booking.guests) {
if (vm.booking.guests.hasOwnProperty(guest)) {
vm.booking.price += vm.booking.guests[guest] * price.rate[guest] * campsite_count;
vm.booking.price += vm.booking.guests[guest] * price.rate[guest];
}
}
});
Expand All @@ -818,7 +807,7 @@ export default {
$.each(vm.priceHistory,function (i,price) {
for (var guest in vm.booking.guests) {
if (vm.booking.guests.hasOwnProperty(guest)) {
vm.booking.price += vm.booking.guests[guest] * price.rate[guest] * campsite_count;
vm.booking.price += vm.booking.guests[guest] * price.rate[guest];
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion parkstay/static/parkstay/js/parkstay.js

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions parkstay/static/parkstay/js/vendor.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions parkstay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,15 +549,15 @@ def price_or_lineitems(request,booking,campsite_list,lines=True,old_booking=None
else:
price = Decimal(park_entry_rate[k]) * v.count()
total_price += price
if lines:
return invoice_lines
else:
return total_price
# Create line items for Discount
# Create line items overrude_price
if lines:
total_price = booking.override_price - booking.cost_total
reason = booking.discount_reason
reason = booking.override_reason
invoice_lines.append({'ledger_description':'{}'.format(reason), "Total": total_price, "oracle_code":booking.campground.oracle_code})
return total_price

if lines:
return invoice_lines

def check_date_diff(old_booking,new_booking):
if old_booking.arrival == new_booking.arrival and old_booking.departure == new_booking.departure:
Expand Down

0 comments on commit b76fa76

Please sign in to comment.