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

shibaken/main to dbca-wa/main #374

Merged
merged 6 commits into from
Nov 21, 2023
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
7 changes: 5 additions & 2 deletions mooringlicensing/components/approvals/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1197,13 +1197,16 @@ def record_lost(self, request, *args, **kwargs):
def request_replacement(self, request, *args, **kwargs):
# internal
sticker = self.get_object()
data = request.data
# data = request.data
data = {}

# Update Sticker action
data['sticker'] = sticker.id
data['action'] = 'Request replacement'
data['user'] = request.user.id
serializer = StickerActionDetailSerializer(data=request.data)
data['waive_the_fee'] = request.data.get('waive_the_fee', False)
data['reason'] = request.data.get('details', {}).get('reason', '')
serializer = StickerActionDetailSerializer(data=data)
serializer.is_valid(raise_exception=True)
details = serializer.save()

Expand Down
21 changes: 13 additions & 8 deletions mooringlicensing/components/proposals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,9 @@ def get_previous_vessel_ownerships(self):

while True:
if proposal.previous_application:
if proposal.previous_application.vessel_ownership.excludable(proposal):
vessel_ownerships.append(proposal.previous_application.vessel_ownership)
if proposal.previous_application.vessel_ownership:
if proposal.previous_application.vessel_ownership.excludable(proposal):
vessel_ownerships.append(proposal.previous_application.vessel_ownership)

if get_out_of_loop:
break
Expand Down Expand Up @@ -2077,6 +2078,16 @@ def renew_approval(self,request):
proposal.previous_application = self
proposal.proposed_issuance_approval= None

from mooringlicensing.components.approvals.models import MooringLicence
if self.approval.child_obj.code == MooringLicence.code:
proposal.allocated_mooring = self.approval.child_obj.mooring

# Copy links to the documents so that the documents are shown on the amendment application form
self.copy_proof_of_identity_documents(proposal)
self.copy_mooring_report_documents(proposal)
self.copy_written_proof_documents(proposal)
self.copy_signed_licence_agreement_documents(proposal)

req=self.requirements.all().exclude(is_deleted=True)
from copy import deepcopy
if req:
Expand All @@ -2091,12 +2102,6 @@ def renew_approval(self,request):
r.id = None
r.district_proposal=None
r.save()
# Create a log entry for the proposal
# self.log_user_action(ProposalUserAction.ACTION_RENEW_PROPOSAL.format(self.id), request)

# Create a log entry for the organisation
# applicant_field = getattr(self, self.applicant_field)
# applicant_field.log_user_action(ProposalUserAction.ACTION_RENEW_PROPOSAL.format(self.id), request)

#Log entry for approval
from mooringlicensing.components.approvals.models import ApprovalUserAction
Expand Down
34 changes: 21 additions & 13 deletions mooringlicensing/components/proposals/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from mooringlicensing.components.users.serializers import UserAddressSerializer
from rest_framework import serializers
from mooringlicensing.helpers import is_internal
from mooringlicensing.settings import PROPOSAL_TYPE_NEW
from mooringlicensing.settings import PROPOSAL_TYPE_AMENDMENT, PROPOSAL_TYPE_NEW, PROPOSAL_TYPE_RENEWAL

# logger = logging.getLogger('mooringlicensing')
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -760,32 +760,40 @@ class Meta:
read_only_fields=('id',)

def validate(self, data):
logger.info(f'Validating the proposal: [{self.instance}]...')
custom_errors = {}
#ignore_insurance_check=self.context.get("ignore_insurance_check")
proposal = Proposal.objects.get(id=self.context.get("proposal_id"))
ignore_insurance_check = data.get("keep_existing_vessel") and proposal.proposal_type.code != 'new'
ignore_insurance_check = data.get("keep_existing_vessel") and proposal.proposal_type.code != PROPOSAL_TYPE_NEW

if self.context.get("action") == 'submit':
if ignore_insurance_check:
pass
else:
insurance_choice = data.get("insurance_choice")
vessel_length = proposal.vessel_details.vessel_applicable_length
if not insurance_choice:
custom_errors["Insurance Choice"] = "You must make an insurance selection"
elif vessel_length > Decimal("6.4") and insurance_choice not in ['ten_million', 'over_ten']:
custom_errors["Insurance Choice"] = "Insurance selected is insufficient for your nominated vessel"
#if not data.get("insurance_choice"):
# custom_errors["Insurance Choice"] = "You must make an insurance selection"
if not self.instance.insurance_certificate_documents.all():
custom_errors["Insurance Certificate"] = "Please attach"
renewal_or_amendment_application_with_vessel = proposal.proposal_type.code in [PROPOSAL_TYPE_RENEWAL, PROPOSAL_TYPE_AMENDMENT,] and proposal.vessel_details
new_application = proposal.proposal_type.code == PROPOSAL_TYPE_NEW
if renewal_or_amendment_application_with_vessel or new_application:
logger.info(f'This proposal: [{self.instance}] is a new proposal or a renewal/amendment proposal with a vessel.')
insurance_choice = data.get("insurance_choice")
vessel_length = proposal.vessel_details.vessel_applicable_length
if not insurance_choice:
custom_errors["Insurance Choice"] = "You must make an insurance selection"
elif vessel_length > Decimal("6.4") and insurance_choice not in ['ten_million', 'over_ten']:
custom_errors["Insurance Choice"] = "Insurance selected is insufficient for your nominated vessel"
if not self.instance.insurance_certificate_documents.all():
custom_errors["Insurance Certificate"] = "Please attach"
else:
logger.info(f'This proposal: [{self.instance}] is a renewal/amendment proposal without a vessel.')
pass
# electoral roll validation
if 'silent_elector' not in data.keys():
custom_errors["Electoral Roll"] = "You must complete this section"
elif data.get("silent_elector"):
if not self.instance.electoral_roll_documents.all():
custom_errors["Silent Elector"] = "You must provide evidence of this"

if custom_errors.keys():
raise serializers.ValidationError(custom_errors)

return data


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,18 @@
</div>
</div>
<div slot="footer">
<button type="button" v-if="processing" disabled class="btn btn-default" @click="ok"><i class="fa fa-spinner fa-spin"></i> Processing</button>
<button type="button" v-else class="btn btn-default" @click="ok" :disabled="!okButtonEnabled">Ok</button>
<button type="button" class="btn btn-default" @click="cancel">Cancel</button>
<div class="row">
<div class="col-md-7">
<span v-if="showWaiveFeeCheckbox">
<strong><input type="checkbox" v-model="waive_the_fee" /> Waive the fee</strong>
</span>
</div>
<div class="col-md-5">
<button type="button" v-if="processing" disabled class="btn btn-default" @click="ok"><i class="fa fa-spinner fa-spin"></i> Processing</button>
<button type="button" v-else class="btn btn-default" @click="ok" :disabled="!okButtonEnabled">Ok</button>
<button type="button" class="btn btn-default" @click="cancel">Cancel</button>
</div>
</div>
</div>
</modal>
</div>
Expand Down Expand Up @@ -70,6 +79,7 @@ export default {
errorString: '',
//successString: '',
//success:false,
waive_the_fee: false,
}
},
computed: {
Expand Down Expand Up @@ -108,6 +118,13 @@ export default {
return '---'
}
},
showWaiveFeeCheckbox: function(){
let show = false
if (this.action === 'request_replacement'){
show = true
}
return show
},
showDateOfLost: function(){
if (this.action === 'record_lost'){
return true
Expand Down Expand Up @@ -137,6 +154,7 @@ export default {
"details": vm.details,
"sticker": vm.sticker,
"action": vm.action,
"waive_the_fee": vm.waive_the_fee,
})
},
cancel:function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,31 @@
<div class="col-sm-9">
<div class="row">
<div class="col-sm-9">
<input @change="clearOrgName" :disabled="readonly" type="radio"
id="registered_owner_current_user" name="registered_owner" :value="true"
v-model="vessel.vessel_ownership.individual_owner" required />
<input
@change="clearOrgName"
:disabled="readonly"
type="radio"
id="registered_owner_current_user"
name="registered_owner"
:value="true"
v-model="vessel.vessel_ownership.individual_owner"
required
/>
<label for="registered_owner_current_user" class="control-label">{{ profileFullName }}</label>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<input :disabled="readonly" type="radio" id="registered_owner_company" name="registered_owner"
:value="false" v-model="vessel.vessel_ownership.individual_owner" required="" />
<input
@change="clearOrgName"
:disabled="readonly"
type="radio"
id="registered_owner_company"
name="registered_owner"
:value="false"
v-model="vessel.vessel_ownership.individual_owner"
required=""
/>
<label for="registered_owner_company" class="control-label">Your company</label>
</div>
</div>
Expand All @@ -52,7 +67,8 @@
<input :readonly="readonly" type="number" step="1" min="25" max="100" class="form-control"
id="ownership_percentage" placeholder="" v-model="vessel.vessel_ownership.percentage" required="" />
</div>
<div v-else-if="companyOwner" class="col-sm-2">
<!-- <div v-else-if="companyOwner" class="col-sm-2"> -->
<div v-else class="col-sm-2">
<input :readonly="readonly" type="number" step="1" min="25" max="100" class="form-control"
id="ownership_percentage_company" placeholder="" :key="companyOwnershipName"
v-model="vessel.vessel_ownership.company_ownership.percentage" required=""
Expand All @@ -63,8 +79,15 @@
<div class="row form-group">
<label for="" class="col-sm-3 control-label">Name as shown on DoT registration papers</label>
<div class="col-sm-9">
<input :readonly="readonly" type="text" class="col-sm-9 form-control" id="dot_name" placeholder=""
v-model="vessel.vessel_ownership.dot_name" required="" />
<input
:readonly="readonly"
type="text"
class="col-sm-9 form-control"
id="dot_name"
placeholder=""
v-model="vessel.vessel_ownership.dot_name"
required=""
/>
</div>
</div>

Expand Down Expand Up @@ -334,13 +357,13 @@ export default {
return retVal;
},
companyOwner: function () {
if (this.vessel && this.vessel.vessel_ownership && this.vessel.vessel_ownership.individual_owner === false) {
if (this.vessel && this.vessel.vessel_ownership && this.vessel.vessel_ownership.individual_owner == false) {
return true;
}
return false
},
individualOwner: function () {
if (this.vessel && this.vessel.vessel_ownership && this.vessel.vessel_ownership.individual_owner) {
if (this.vessel && this.vessel.vessel_ownership && this.vessel.vessel_ownership.individual_owner == true) {
return true;
}
return false
Expand Down Expand Up @@ -418,9 +441,18 @@ export default {
await this.$nextTick(() => {
// do not perform check if no previous application vessel
if (!this.previousApplicationVesselDetails || !this.previousApplicationVesselOwnership) {
return
if (
Number(this.vesselDetails.vessel_draft) ||
Number(this.vesselDetails.vessel_length) ||
(this.vesselDetails.vessel_name && this.vesselDetails.vessel_name.trim()) ||
this.vesselDetails.vessel_type ||
Number(this.vesselDetails.vessel_weight) ||
Number(this.vesselOwnership.percentage) ||
this.vessel.new_vessel
) {
vesselChanged = true;
}
} else {

if (
Number(this.vesselDetails.vessel_draft) != Number(this.previousApplicationVesselDetails.vessel_draft) ||
Number(this.vesselDetails.vessel_length) != Number(this.previousApplicationVesselDetails.vessel_length) ||
Expand All @@ -438,23 +470,20 @@ export default {
if (this.vesselOwnership.individual_owner) {
// Company ownership --> Individual ownership
vesselOwnershipChanged = true
console.log('%cCompanyOwnership --> IndividualOwnership', consoleColour)
} else {
if (this.vesselOwnership.company_ownership) {
if (this.previousApplicationVesselOwnership.company_ownership.company && this.vesselOwnership.company_ownership.company) {
if (this.previousApplicationVesselOwnership.company_ownership.company.name && this.vesselOwnership.company_ownership.company.name) {
if (this.previousApplicationVesselOwnership.company_ownership.company.name.trim() !== this.vesselOwnership.company_ownership.company.name.trim()) {
// Company name changed
vesselOwnershipChanged = true
console.log('%cCompany name changed', consoleColour)
}
}
}
if (this.previousApplicationVesselOwnership.company_ownership && this.previousApplicationVesselOwnership.company_ownership.percentage && this.vesselOwnership.company_ownership.percentage) {
if (Number(this.previousApplicationVesselOwnership.company_ownership.percentage) !== Number(this.vesselOwnership.company_ownership.percentage)) {
// Company percentage changed
vesselOwnershipChanged = true
console.log('%cCompanyOwnership percentage changed', consoleColour)
}
}
}
Expand All @@ -463,34 +492,26 @@ export default {
if (!this.vesselOwnership.individual_owner) {
// Individual ownership --> Company ownership
vesselOwnershipChanged = true
console.log('%c IndividualOwnership --> CompanyOwnership', consoleColour)
}
}
}
console.log('vesselChanged: ' + vesselChanged)
console.log('vesselOwnershipChanged: ' + vesselOwnershipChanged)
})
console.log("%cemit vesselChanged from the vessels.vue", consoleColour)
await this.$emit("vesselChanged", vesselChanged)

const missingVessel = this.vessel.rego_no ? false : true;
await this.$emit("noVessel", missingVessel)

console.log('%cemit updateVesselOwnershipChanged from the vessels.vue', consoleColour)
await this.$emit("updateVesselOwnershipChanged", vesselOwnershipChanged)
//return vesselChanged;
},
addToTemporaryDocumentCollectionList(temp_doc_id) {
console.log('in addToTemporaryDocumentCollectionList')
console.log({ temp_doc_id })
this.temporary_document_collection_id = temp_doc_id;
},
/*
resetCurrentVessel: function() {
},
*/
retrieveIndividualOwner: async function () {
console.log("in retrieveIndividualOwner()")
if (this.individualOwner && this.vessel.id) {
const url = api_endpoints.lookupIndividualOwnership(this.vessel.id);
const res = await this.$http.post(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<input v-else type="button" @click.prevent="save" class="btn btn-primary" value="Save and Continue" :disabled="saveExitProposal || paySubmitting"/>

<button v-if="paySubmitting || !terms_and_conditions_checked" type="button" class="btn btn-primary" disabled>
{{ submitText }}&nbsp;
{{ submitText }}&nbsp;
<i v-show="terms_and_conditions_checked" class="fa fa-circle-o-notch fa-spin fa-fw"></i>
</button>
<input v-else
Expand Down Expand Up @@ -205,8 +205,8 @@ export default {
// },
computed: {
disableSubmit: function() {
console.log('%cdisableSubmit() is being called...', 'color: #FF0000')
let disable = false;
let disable = false

if (this.proposal){
if (this.proposal.proposal_type.code ==='amendment'){
if (this.missingVessel && ['aaa', 'aua'].includes(this.proposal.application_type_code)){
Expand Down
Loading