Skip to content

Commit

Permalink
Merge 8ca40ac into dd09703
Browse files Browse the repository at this point in the history
  • Loading branch information
FatemehMoghadam committed Jul 11, 2018
2 parents dd09703 + 8ca40ac commit daf9912
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.
4 changes: 4 additions & 0 deletions parkstay/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,8 @@ def list(self, request, *args, **kwargs):
bk['lastname'] = booking.details.get('last_name','')
if booking.override_reason:
bk['override_reason'] = booking.override_reason.text
if booking.override_reason_info:
bk['override_reason_info'] = booking.override_reason_info
if booking.override_price:
discount = booking.discount
if not booking.paid:
Expand Down Expand Up @@ -1685,6 +1687,7 @@ def create(self, request, format=None):
regos = request.data['regos']
override_price = serializer.validated_data.get('override_price', None)
override_reason = serializer.validated_data.get('override_reason', None)
override_reason_info = serializer.validated_data.get('override_reason_info', None)
overridden_by = None if (override_price is None) else request.user
try:
emailUser = request.data['customer']
Expand Down Expand Up @@ -1716,6 +1719,7 @@ def create(self, request, format=None):
'cost_total' : costs['total'],
'override_price' : override_price,
'override_reason' : override_reason,
'override_reason_info' : override_reason_info,
'overridden_by': overridden_by,
'customer' : customer,
'first_name': emailUser['first_name'],
Expand Down
10 changes: 8 additions & 2 deletions parkstay/frontend/parkstay/src/components/booking/addbooking.vue
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,13 @@
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-group" v-if="overrideCharge">
<div class="form-group" v-if="overrideCharge">
<reason type="discount" name="overrideReason" v-model="booking.override_reason" :required="overrideCharge"></reason>
</div>
</div>
<div class="form-group" v-if="overrideCharge">
<label class="control-label" >Override reason detail:</label>
<textarea id="reason_details" class="form-control" v-model="booking.override_reason_info"/>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -373,6 +377,7 @@ export default {
price:"0",
override_price:"0",
override_reason:"",
override_reason_info:"",
parkEntry:{
vehicles:0,
},
Expand Down Expand Up @@ -945,6 +950,7 @@ export default {
},
override_price:vm.booking.override_price,
override_reason:vm.booking.override_reason,
override_reason_info:vm.booking.override_reason_info,
customer:{
email:vm.booking.email,
first_name:vm.booking.firstname,
Expand Down
10 changes: 8 additions & 2 deletions parkstay/frontend/parkstay/src/components/campsites/campsite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" v-if="campground.site_type == 0">
<label class="control-label" >Maximum Number of Vehicles</label>
<input type="number" name="max_vehicles" class="form-control" v-model="campsite.max_vehicles" required :disabled="selected_campsite_class_url() != ''"/>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">

</div>
<div class="col-sm-6">
<div class="row">

<div class="form-group">
<div class="col-sm-6 col-xs-8">
<button @click.prevent="addCampsite" type="button" v-show="createCampsite" class="btn btn-primary btn-create">Create</button>
Expand All @@ -80,7 +85,6 @@
<button type="button" v-show="!createCampsite" style="margin-right:5px" @click="updateCampsite" class="btn btn-primary">Update</button>
<button type="button" class="btn btn-default pull-right" @click="goBack">Back</button>
</div>

</div>
</div>
</div>
Expand Down Expand Up @@ -170,6 +174,7 @@ export default {
caravan:false,
min_people: '',
max_people:'',
max_vehicles:''
},
campsite_classes: [],
ph_options: {
Expand Down Expand Up @@ -253,6 +258,7 @@ export default {
vm.campsite.max_people = sel_class.max_people;
vm.campsite.min_people= sel_class.min_people;
vm.campsite.description = sel_class.description;
vm.campsite.max_vehicles = sel_class.max_vehicles;
vm.$refs.descriptionEditor.updateContent(vm.campsite.description);
}
Expand Down
9 changes: 3 additions & 6 deletions parkstay/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ class Campsite(models.Model):
caravan = models.BooleanField(default=False)
min_people = models.SmallIntegerField(default=1)
max_people = models.SmallIntegerField(default=12)
max_vehicles = models.PositiveIntegerField(default=1)
description = models.TextField(null=True)

def __str__(self):
Expand Down Expand Up @@ -882,6 +883,7 @@ class Booking(models.Model):
cost_total = models.DecimalField(max_digits=8, decimal_places=2, default='0.00')
override_price = models.DecimalField(max_digits=8, decimal_places=2, blank=True, null=True)
override_reason = models.ForeignKey('DiscountReason', null=True, blank=True)
override_reason_info = models.TextField(blank=True, null=True)
overridden_by = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.PROTECT, blank=True, null=True, related_name='overridden_bookings')
campground = models.ForeignKey('Campground', null=True)
is_canceled = models.BooleanField(default=False)
Expand Down Expand Up @@ -1089,12 +1091,7 @@ def __check_payment_status(self):

if amount == 0:
return 'unpaid'
# if self.cost_total < amount:
# return 'over_paid'
# elif self.cost_total > amount:
# return 'partially_paid'
# else:return "paid"


if self.override_price:
if self.override_price < amount:
return 'over_paid'
Expand Down
4 changes: 2 additions & 2 deletions parkstay/serialisers.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ class CampsiteSerialiser(serializers.ModelSerializer):
name = serializers.CharField(default='default',required=False)
class Meta:
model = Campsite
fields = ('id','campground', 'name', 'type','campsite_class','price','features','wkb_geometry','campground_open','active','current_closure', 'current_closure_id', 'can_add_rate','tent','campervan','caravan','min_people','max_people','description',)
fields = ('id','campground', 'name', 'type','campsite_class','price','features','wkb_geometry','campground_open','active','current_closure', 'current_closure_id', 'can_add_rate','tent','campervan','caravan','min_people','max_people','description','max_vehicles')

def __init__(self, *args, **kwargs):
try:
Expand Down Expand Up @@ -444,7 +444,7 @@ class BookingSerializer(serializers.ModelSerializer):
regos = BookingRegoSerializer(many=True,read_only=True)
class Meta:
model = Booking
fields = ('id','legacy_id','legacy_name','arrival','departure','details','cost_total','override_price','override_reason','campground','campground_name','campground_region','campground_site_type','campsites','invoices','is_canceled','guests','regos','vehicle_payment_status','refund_status','amount_paid')
fields = ('id','legacy_id','legacy_name','arrival','departure','details','cost_total','override_price','override_reason','override_reason_info','campground','campground_name','campground_region','campground_site_type','campsites','invoices','is_canceled','guests','regos','vehicle_payment_status','refund_status','amount_paid')
read_only_fields = ('vehicle_payment_status','refund_status','campground_name','campground_region','campground_site_type')


Expand Down
2 changes: 1 addition & 1 deletion parkstay/static/parkstay/js/parkstay.js

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions parkstay/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def create_booking_by_class(campground_id, campsite_class_id, start_date, end_da
return booking


def create_booking_by_site(sites_qs, start_date, end_date, num_adult=0, num_concession=0, num_child=0, num_infant=0, cost_total=0, override_price=None, override_reason=None, overridden_by=None, customer=None, updating_booking=False, override_checks=False):
def create_booking_by_site(sites_qs, start_date, end_date, num_adult=0, num_concession=0, num_child=0, num_infant=0, cost_total=0, override_price=None, override_reason=None, override_reason_info=None, overridden_by=None, customer=None, updating_booking=False, override_checks=False):
"""Create a new temporary booking in the system for a set of specific campsites."""

# the CampsiteBooking table runs the risk of a race condition,
Expand Down Expand Up @@ -139,6 +139,7 @@ def create_booking_by_site(sites_qs, start_date, end_date, num_adult=0, num_conc
cost_total = cost_total,
override_price = Decimal(override_price) if (override_price is not None) else None,
override_reason = override_reason,
override_reason_info = override_reason_info,
overridden_by = overridden_by,
expiry_time=timezone.now()+timedelta(seconds=settings.BOOKING_TIMEOUT),
campground=campsite_qs[0].campground,
Expand Down Expand Up @@ -418,9 +419,6 @@ def get_available_campsites_list_booking(campsite_qs,request, start_date, end_da
if ('booked' not in av or camp in booking.campsite_id_list):
if ('closed' not in av):
available.append(CampsiteSerialiser(Campsite.objects.filter(id = camp),many=True,context={'request':request}).data[0])

#complete = [CampsiteSerialiser(Campsite.objects.filter(id = camp),many=True,context={'request':request}).data[0]]

return available

def get_campsite_current_rate(request,campsite_id,start_date,end_date):
Expand Down Expand Up @@ -577,13 +575,13 @@ 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

# Create line item for Override price
if booking.override_price is not None:
if booking.override_reason is not None:
reason = booking.override_reason
invoice_lines.append({
'ledger_description': '{}'.format(reason.text),
'ledger_description': '{} - {}'.format(reason.text, booking.override_reason_info),
'quantity': 1,
'price_incl_tax': str(total_price - booking.discount),
'oracle_code': booking.campground.oracle_code
Expand Down Expand Up @@ -837,6 +835,7 @@ def create_or_update_booking(request,booking_details,updating=False,override_che
cost_total=booking_details['cost_total'],
override_price=booking_details['override_price'],
override_reason=booking_details['override_reason'],
override_reason_info=booking_details['override_reason_info'],
overridden_by=booking_details['overridden_by'],
customer=booking_details['customer'],
override_checks=override_checks
Expand Down

0 comments on commit daf9912

Please sign in to comment.