Skip to content

Commit

Permalink
Merge pull request #521 from NishantPhour/main
Browse files Browse the repository at this point in the history
(conflict resolved) Insurance document of previous application shown in amend/renew application if keeping existing vessel
  • Loading branch information
xzzy authored Jan 17, 2025
2 parents ff7eecb + 9ff7494 commit a32ce0c
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 11 deletions.
14 changes: 13 additions & 1 deletion mooringlicensing/components/proposals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ def copy_signed_licence_agreement_documents(self, proposal):
if link_item.enabled:
# Create link to the proposal only when the doc is not deleted.
ProposalSignedLicenceAgreementDocument.objects.create(proposal=proposal, signed_licence_agreement_document=doc)

def copy_insurance_document(self, proposal):
old_insurance_doc = InsuranceCertificateDocument.objects.filter(proposal=self).last()
if old_insurance_doc:
new_insurance_doc = old_insurance_doc
new_insurance_doc.id = None
new_insurance_doc.proposal = proposal
new_insurance_doc.save()


def copy_vessel_registration_documents(self, proposal):
doc_list = VesselRegistrationDocument.objects.filter(proposal=self)
if doc_list.count() > 0:
Expand Down Expand Up @@ -1990,6 +2000,7 @@ def renew_approval(self,request):
self.copy_mooring_report_documents(proposal)
self.copy_written_proof_documents(proposal)
self.copy_signed_licence_agreement_documents(proposal)
self.copy_insurance_document(proposal)

req=self.requirements.all().exclude(is_deleted=True)
from copy import deepcopy
Expand Down Expand Up @@ -2043,6 +2054,7 @@ def amend_approval(self,request):
self.copy_mooring_report_documents(proposal)
self.copy_written_proof_documents(proposal)
self.copy_signed_licence_agreement_documents(proposal)
self.copy_insurance_document(proposal)

req=self.requirements.all().exclude(is_deleted=True)
from copy import deepcopy
Expand Down Expand Up @@ -3555,7 +3567,7 @@ def update_or_create_approval(self, current_datetime, request=None):
self.proposal.refresh() # so that the approval doc field is updated by the doc generated above

# Email
send_application_approved_or_declined_email(self, 'approved_paid', request, stickers_to_be_returned)
send_application_approved_or_declined_email(self.proposal, 'approved_paid', request, stickers_to_be_returned)

# Email to ML holder when new moorings added
for mooring_licence in mls_to_be_emailed:
Expand Down
7 changes: 7 additions & 0 deletions mooringlicensing/components/proposals/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
CompanyOwnership,
Mooring, MooringLicenceApplication, AuthorisedUserApplication,
ProposalSiteLicenseeMooringRequest,
InsuranceCertificateDocument,
)
from mooringlicensing.ledger_api_utils import retrieve_email_userro
from mooringlicensing.components.approvals.models import MooringLicence, MooringOnApproval, Approval
Expand Down Expand Up @@ -137,6 +138,7 @@ class BaseProposalSerializer(serializers.ModelSerializer):
uuid = serializers.SerializerMethodField()
amendment_requests = serializers.SerializerMethodField()
site_licensee_moorings = serializers.SerializerMethodField()
previous_application_insurance_choice = serializers.SerializerMethodField()

class Meta:
model = Proposal
Expand Down Expand Up @@ -193,6 +195,7 @@ class Meta:
'previous_application_id',
'previous_application_vessel_details_id',
'previous_application_preferred_bay_id',
'previous_application_insurance_choice',
'current_vessels_rego_list',
'approval_lodgement_number',
'approval_vessel_rego_no',
Expand Down Expand Up @@ -375,6 +378,10 @@ def get_invoices(self, obj):

return invoice_data
return ''

def get_previous_application_insurance_choice(self, obj):
if (obj.previous_application and obj.previous_application.insurance_choice):
return obj.previous_application.insurance_choice

class ListProposalSiteLicenseeMooringRequestSerializer(serializers.ModelSerializer):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
:isRepeatable="true"
:documentActionUrl="insuranceCertificateDocumentUrl"
:replace_button_by_text="true"
:keepCurrentVessel="keepCurrentVessel"
/>
</div>
</div>
Expand Down Expand Up @@ -51,9 +52,24 @@ from '@/utils/hooks'
},
readonly:{
type: Boolean,
default: true,
default: true,
},
keepCurrentVessel:{
type: Boolean,
default: true,
},
},
watch: {
keepCurrentVessel: {
handler: function() {
if(!this.keepCurrentVessel){
this.selectedOption = null;
$('input[name="insuranceChoice"]').prop('checked', false).trigger('change');
}
}
}
},
data:function () {
return {
selectedOption: null,
Expand Down Expand Up @@ -103,6 +119,12 @@ from '@/utils/hooks'
let selected = $('#' + vm.selectedOption);
selected.prop('checked', true).trigger('change');
}
//selecting insurance choice of previous application
else if (this.proposal.previous_application_id && this.keepCurrentVessel){
this.selectedOption = this.proposal.previous_application_insurance_choice
let selected = $('#' + vm.selectedOption);
selected.prop('checked', true).trigger('change');
}
});
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
id="insurance"
ref="insurance"
:readonly="readonly"
:keepCurrentVessel="keepCurrentVessel"
/>
</div>
<div class="tab-pane fade" id="pills-confirm" role="tabpanel" aria-labelledby="pills-confirm-tab">
Expand Down Expand Up @@ -146,6 +147,10 @@
type: Boolean,
default: true
},
keepCurrentVessel:{
type: Boolean,
default: true,
},
},
data:function () {
return{
Expand Down Expand Up @@ -227,7 +232,7 @@
if (!this.keepCurrentVessel) {
this.showInsuranceTab = true;
} else {
this.showInsuranceTab = false;
// this.showInsuranceTab = false;
}
// payment
if (this.higherVesselCategory) {
Expand All @@ -246,7 +251,7 @@
await this.$emit("updateSubmitText", "Pay / Submit");
} else {
this.showPaymentTab = true;
this.showInsuranceTab = false;
// this.showInsuranceTab = false;
await this.$emit("updateSubmitText", "Pay / Submit");
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
id="insurance"
ref="insurance"
:readonly="readonly"
:keepCurrentVessel="keepCurrentVessel"
/>
</div>
<div class="tab-pane fade" id="pills-mooring" role="tabpanel" aria-labelledby="pills-mooring-tab">
Expand Down Expand Up @@ -176,6 +177,10 @@
type: Boolean,
default: true,
},
keepCurrentVessel:{
type: Boolean,
default: true,
},
},
data:function () {
return{
Expand Down Expand Up @@ -319,7 +324,7 @@
this.$emit("updateSubmitText", "Submit");
} else {
this.showPaymentTab = false;
this.showInsuranceTab = false;
// this.showInsuranceTab = false;
this.$emit("updateSubmitText", "Submit");
}
if (this.proposal.null_vessel_on_create && this.$refs.vessels.vessel.rego_no){
Expand All @@ -337,15 +342,15 @@
this.$nextTick(() => {
if (this.proposal.vessel_on_proposal && this.keepCurrentVessel && !this.higherVesselCategory && !this.changeMooring) {
this.showPaymentTab = true;
this.showInsuranceTab = false;
// this.showInsuranceTab = false;
this.$emit("updateSubmitText", "Pay / Submit");
} else if (!this.keepCurrentVessel) {
this.showPaymentTab = false;
this.showInsuranceTab = true;
this.$emit("updateSubmitText", "Submit");
} else {
this.showPaymentTab = false;
this.showInsuranceTab = false;
// this.showInsuranceTab = false;
this.$emit("updateSubmitText", "Submit");
}
// auto approve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
id="insurance"
ref="insurance"
:readonly="readonly"
:keepCurrentVessel="keepCurrentVessel"
/>
</div>
<div class="tab-pane fade" id="pills-documents" role="tabpanel" aria-labelledby="pills-documents-tab">
Expand Down Expand Up @@ -160,6 +161,14 @@
type: Boolean,
default: true,
},
keepCurrentVessel:{
type: Boolean,
default: true,
},
// add_vessel: {
// type: Boolean,
// default: false,
// },
},
data:function () {
return{
Expand Down Expand Up @@ -297,7 +306,7 @@
this.$emit("updateSubmitText", "Submit");
} else {
this.showPaymentTab = false;
this.showInsuranceTab = false;
// this.showInsuranceTab = false;
this.$emit("updateSubmitText", "Submit");
}
// auto approve
Expand All @@ -311,7 +320,7 @@
this.$nextTick(() => {
if (this.proposal.vessel_on_proposal && this.keepCurrentVessel && !this.higherVesselCategory) {
this.showPaymentTab = true;
this.showInsuranceTab = false;
// this.showInsuranceTab = false;
this.$emit("updateSubmitText", "Pay / Submit");
this.$emit("updateAutoRenew", true);
} else if (!this.keepCurrentVessel) {
Expand All @@ -321,7 +330,7 @@
this.$emit("updateAutoRenew", false);
} else {
this.showPaymentTab = false;
this.showInsuranceTab = false;
// this.showInsuranceTab = false;
this.$emit("updateSubmitText", "Submit");
this.$emit("updateAutoRenew", false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ export default {
text_string: {
type: String,
default: 'Attach Document'
}
},
keepCurrentVessel:{
type: Boolean,
default: true,
},
},
data:function(){
return {
Expand Down Expand Up @@ -115,6 +119,13 @@ export default {
await this.$emit('update-parent');
},
deep: true
},
keepCurrentVessel: {
handler: function() {
if(!this.keepCurrentVessel){
this.delete_all_documents();
}
},
},
temporaryDocumentCollectionId: function() {
// read in prop value
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.9 on 2025-01-17 04:23

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('mooringlicensing', '0382_sticker_invoice_property_cache'),
]

operations = [
migrations.AddField(
model_name='insurancecertificatedocument',
name='copied',
field=models.BooleanField(default=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.9 on 2025-01-17 04:27

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('mooringlicensing', '0383_insurancecertificatedocument_copied'),
]

operations = [
migrations.RemoveField(
model_name='insurancecertificatedocument',
name='copied',
),
]

0 comments on commit a32ce0c

Please sign in to comment.