diff --git a/mooringlicensing/components/approvals/admin.py b/mooringlicensing/components/approvals/admin.py
index 10aa13679..9308080d6 100644
--- a/mooringlicensing/components/approvals/admin.py
+++ b/mooringlicensing/components/approvals/admin.py
@@ -6,7 +6,7 @@
@admin.register(models.Sticker)
class StickerAdmin(admin.ModelAdmin):
- list_display = ['id', 'number', 'status', 'approval', 'dcv_permit', 'printing_date', 'mailing_date', 'fee_season',]
+ list_display = ['id', 'number', 'status', 'approval', 'dcv_permit', 'printing_date', 'mailing_date', 'fee_season', 'date_created', 'date_updated',]
search_fields = ['id', 'number', 'approval__lodgement_number',]
list_filter = ['status',]
list_display_links = ['id', 'number',]
diff --git a/mooringlicensing/components/approvals/api.py b/mooringlicensing/components/approvals/api.py
index d61facc33..5a3fb30b0 100755
--- a/mooringlicensing/components/approvals/api.py
+++ b/mooringlicensing/components/approvals/api.py
@@ -1230,7 +1230,7 @@ def get_queryset(self):
if debug:
qs = Sticker.objects.all()
else:
- qs = Sticker.objects.filter(status__in=Sticker.EXPOSED_STATUS)
+ qs = Sticker.objects.filter(status__in=Sticker.EXPOSED_STATUS).order_by('-date_updated', '-date_created')
return qs
diff --git a/mooringlicensing/components/approvals/email.py b/mooringlicensing/components/approvals/email.py
index a838ed967..d6552b54e 100755
--- a/mooringlicensing/components/approvals/email.py
+++ b/mooringlicensing/components/approvals/email.py
@@ -933,10 +933,10 @@ def send_reissue_aap_after_sale_recorded_email(approval, request, vessel_ownersh
_log_user_email(msg, approval.submitter_obj, proposal.submitter_obj, sender=sender)
-def send_sticker_replacement_email(request, old_sticker, new_sticker, invoice_reference):
+def send_sticker_replacement_email(request, old_sticker_numbers, approval, invoice_reference):
# 36
# email to licence/permit holder when sticker replacement request has been submitted (with payment)
- approval = new_sticker.approval
+ # approval = new_sticker.approval
proposal = approval.current_proposal
email = TemplateEmailBase(
@@ -954,7 +954,7 @@ def send_sticker_replacement_email(request, old_sticker, new_sticker, invoice_re
url = f'{settings.LEDGER_API_URL}/ledgergw/invoice-pdf/{settings.LEDGER_API_KEY}/{invoice_reference}'
invoice_pdf = requests.get(url=url)
if invoice_pdf.status_code == 200:
- attachment = ('invoice#{}.pdf'.format(proposal.invoice.reference), invoice_pdf.content, 'application/pdf')
+ attachment = ('invoice#{}.pdf'.format(invoice_reference), invoice_pdf.content, 'application/pdf')
# url = get_invoice_url(invoice.reference, request)
# invoice_pdf = requests.get(url=url)
@@ -965,7 +965,7 @@ def send_sticker_replacement_email(request, old_sticker, new_sticker, invoice_re
context = {
'public_url': get_public_url(request),
'recipient': approval.submitter_obj,
- 'sticker': old_sticker,
+ 'old_sticker_numbers': ','.join(old_sticker_numbers),
'dashboard_external_url': get_public_url(request),
}
@@ -975,7 +975,9 @@ def send_sticker_replacement_email(request, old_sticker, new_sticker, invoice_re
if cc_list:
all_ccs = [cc_list]
- msg = email.send(proposal.submitter_obj.email, cc=all_ccs, context=context, attachments=attachments)
+ bcc = proposal.assessor_recipients
+
+ msg = email.send(proposal.submitter_obj.email, cc=all_ccs, bcc=bcc, context=context, attachments=attachments)
if msg:
sender = request.user if request else settings.DEFAULT_FROM_EMAIL
_log_approval_email(msg, approval, sender=sender, attachments=attachments)
diff --git a/mooringlicensing/components/approvals/models.py b/mooringlicensing/components/approvals/models.py
index 0424845f2..2eada7a21 100755
--- a/mooringlicensing/components/approvals/models.py
+++ b/mooringlicensing/components/approvals/models.py
@@ -2808,10 +2808,12 @@ class Sticker(models.Model):
vessel_ownership = models.ForeignKey('VesselOwnership', blank=True, null=True, on_delete=models.SET_NULL)
proposal_initiated = models.ForeignKey('Proposal', blank=True, null=True, on_delete=models.SET_NULL) # This propposal created this sticker object. Can be None when sticker created by RequestNewSticker action or so.
sticker_to_replace = models.ForeignKey('self', null=True, blank=True, on_delete=models.SET_NULL) # This sticker object replaces the sticker_to_replace for renewal
+ date_created = models.DateTimeField(blank=True, null=True, auto_now_add=True)
+ date_updated = models.DateTimeField(blank=True, null=True, auto_now=True)
class Meta:
app_label = 'mooringlicensing'
- ordering = ['-number']
+ ordering = ['-date_updated', '-date_created', '-number',]
def get_invoices(self):
invoices = []
diff --git a/mooringlicensing/components/approvals/serializers.py b/mooringlicensing/components/approvals/serializers.py
index 115931cdf..90480bd57 100755
--- a/mooringlicensing/components/approvals/serializers.py
+++ b/mooringlicensing/components/approvals/serializers.py
@@ -1232,6 +1232,7 @@ def validate(self, data):
class StickerSerializerSimple(serializers.ModelSerializer):
invoices = serializers.SerializerMethodField()
+ vessel_rego_no = serializers.SerializerMethodField()
class Meta:
model = Sticker
@@ -1240,6 +1241,7 @@ class Meta:
'number',
'mailing_date',
'invoices',
+ 'vessel_rego_no',
)
def get_invoices(self, obj):
@@ -1250,6 +1252,12 @@ def get_invoices(self, obj):
serializer = InvoiceSerializer(invoices, many=True)
return serializer.data
+ def get_vessel_rego_no(self, obj):
+ if obj.vessel_ownership and obj.vessel_ownership.vessel:
+ return obj.vessel_ownership.vessel.rego_no
+ else:
+ return ''
+
class StickerSerializer(serializers.ModelSerializer):
status = serializers.SerializerMethodField()
@@ -1286,6 +1294,8 @@ class Meta:
'fee_season',
'invoices',
'can_view_payment_details',
+ 'date_created',
+ 'date_updated',
)
datatables_always_serialize = (
'id',
@@ -1304,6 +1314,8 @@ class Meta:
'fee_season',
'invoices',
'can_view_payment_details',
+ 'date_created',
+ 'date_updated',
)
def get_fee_season(self, obj):
diff --git a/mooringlicensing/components/payments_ml/models.py b/mooringlicensing/components/payments_ml/models.py
index a9a627a4c..411439969 100644
--- a/mooringlicensing/components/payments_ml/models.py
+++ b/mooringlicensing/components/payments_ml/models.py
@@ -193,7 +193,7 @@ class StickerActionFee(Payment):
def __str__(self):
stickers = []
for sticker_action_detail in self.sticker_action_details.all():
- stickers. append(sticker_action_detail.sticker.number)
+ stickers.append(sticker_action_detail.sticker.number)
return 'Sticker(s): [{}] : Invoice {}'.format(','.join(stickers), self.invoice_reference)
class Meta:
diff --git a/mooringlicensing/components/payments_ml/views.py b/mooringlicensing/components/payments_ml/views.py
index d8f6c4c88..68f2034a2 100644
--- a/mooringlicensing/components/payments_ml/views.py
+++ b/mooringlicensing/components/payments_ml/views.py
@@ -260,6 +260,7 @@ def post(self, request, *args, **kwargs):
request.user,
lines,
return_url=request.build_absolute_uri(reverse('sticker_replacement_fee_success', kwargs={"uuid": sticker_action_fee.uuid})),
+ return_preload_url=settings.MOORING_LICENSING_EXTERNAL_URL + reverse("sticker_replacement_fee_success_preload", kwargs={"uuid": sticker_action_fee.uuid}),
booking_reference=str(sticker_action_fee.uuid),
invoice_text='{}'.format(application_type.description),
)
@@ -306,15 +307,21 @@ def get(self, request, uuid, format=None):
sticker_action_fee.expiry_time = None
sticker_action_fee.save()
- # for sticker_action_detail in sticker_action_details.all():
- # old_sticker = sticker_action_detail.sticker
- # new_sticker = old_sticker.request_replacement(Sticker.STICKER_STATUS_LOST)
- sticker_action_detail = sticker_action_details.first()
- old_sticker = sticker_action_detail.sticker
- new_sticker = old_sticker.request_replacement(Sticker.STICKER_STATUS_LOST)
+
+ old_sticker_numbers = []
+ for sticker_action_detail in sticker_action_details.all():
+ old_sticker = sticker_action_detail.sticker
+ new_sticker = old_sticker.request_replacement(Sticker.STICKER_STATUS_LOST)
+ old_sticker_numbers.append(old_sticker.number)
+ # Send email with the invoice
+ send_sticker_replacement_email(request, old_sticker_numbers, new_sticker.approval, invoice.reference)
+
+ # sticker_action_detail = sticker_action_details.first()
+ # old_sticker = sticker_action_detail.sticker
+ # new_sticker = old_sticker.request_replacement(Sticker.STICKER_STATUS_LOST)
# Send email with the invoice
- send_sticker_replacement_email(request, old_sticker, new_sticker, invoice.reference)
+ # send_sticker_replacement_email(request, old_sticker, new_sticker, invoice.reference)
logger.info(
"Returning status.HTTP_200_OK. Order created successfully.",
@@ -338,7 +345,7 @@ def get(self, request, uuid):
# invoice_url = get_invoice_url(invoice.reference, request)
# api_key = settings.LEDGER_API_KEY
# invoice_url = settings.LEDGER_API_URL+'/ledgergw/invoice-pdf/'+api_key+'/' + self.invoice.reference
- invoice_url = f'/ledger-toolkit-api/invoice-pdf/{self.invoice.reference}/'
+ invoice_url = f'/ledger-toolkit-api/invoice-pdf/{invoice.reference}/'
# invoice_pdf = requests.get(url=url)
submitter = retrieve_email_userro(sticker_action_fee.created_by) if sticker_action_fee.created_by else ''
diff --git a/mooringlicensing/frontend/mooringlicensing/src/components/common/table_approvals.vue b/mooringlicensing/frontend/mooringlicensing/src/components/common/table_approvals.vue
index e4d5d8e39..7a5e656aa 100644
--- a/mooringlicensing/frontend/mooringlicensing/src/components/common/table_approvals.vue
+++ b/mooringlicensing/frontend/mooringlicensing/src/components/common/table_approvals.vue
@@ -260,6 +260,7 @@ export default {
'Start Date',
'Expiry Date',
'Vessel Rego',
+ 'Mooring',
'Action',
'Approval letter',
'Sticker replacement',
@@ -364,6 +365,7 @@ export default {
}
},
columnMooring: function(){
+ let vm = this
return {
data: "id",
orderable: true,
@@ -372,7 +374,11 @@ export default {
'render': function(row, type, full){
let links = ''
for (let mooring of full.moorings){
- links += `${mooring.mooring_name}
`;
+ if (vm.is_internal){
+ links += `${mooring.mooring_name}
`
+ } else {
+ links += `${mooring.mooring_name}
`
+ }
}
return links
},
@@ -641,9 +647,7 @@ export default {
'render': function(row, type, full){
let ret_str = ''
for (let sticker of full.stickers){
- console.log('sticker')
- console.log(sticker)
- ret_str += sticker.number + '
'
+ ret_str += sticker.number + ' (' + sticker.vessel_rego_no + ')
'
}
return ret_str
},
@@ -780,6 +784,7 @@ export default {
vm.columnExpiryDate,
// vm.columnVesselRegistration,
vm.columnVesselRegos,
+ vm.columnMooring,
vm.columnAction,
vm.columnApprovalLetter,
vm.columnStickerReplacement,
diff --git a/mooringlicensing/frontend/mooringlicensing/src/components/common/table_stickers.vue b/mooringlicensing/frontend/mooringlicensing/src/components/common/table_stickers.vue
index c935b7a88..4ebe1445d 100644
--- a/mooringlicensing/frontend/mooringlicensing/src/components/common/table_stickers.vue
+++ b/mooringlicensing/frontend/mooringlicensing/src/components/common/table_stickers.vue
@@ -117,7 +117,7 @@ export default {
return []
}
if (this.is_internal){
- return ['id', 'Number', 'Permit or Licence', 'Vessel rego', 'Date sent / printed / mailed', 'Status', 'Season', 'Invoice', 'Action']
+ return ['id', 'Date Updated', 'Number', 'Permit or Licence', 'Vessel rego', 'Date sent / printed / mailed', 'Status', 'Season', 'Invoice', 'Action']
}
},
column_id: function(){
@@ -132,6 +132,17 @@ export default {
}
}
},
+ column_date_updated: function(){
+ return {
+ data: "date_updated",
+ orderable: true,
+ searchable: false,
+ visible: this.debug,
+ 'render': function(row, type, full){
+ return full.date_updated
+ }
+ }
+ },
column_vessel_rego_no: function(){
return {
// 2. Number
@@ -296,6 +307,7 @@ export default {
if(vm.is_internal){
columns = [
vm.column_id,
+ vm.column_date_updated,
vm.column_number,
vm.column_permit_or_licence,
vm.column_vessel_rego_no,
diff --git a/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue b/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue
index cdc99472b..40bb89dcf 100755
--- a/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue
+++ b/mooringlicensing/frontend/mooringlicensing/src/components/common/vessels.vue
@@ -236,12 +236,13 @@ export default {
regoReadonly: function () {
let readonly = false;
//if (this.proposal && this.proposal.approval_reissued && !this.proposal.approval_vessel_rego_no &&
- if (this.proposal && !this.proposal.approval_vessel_rego_no && !this.proposal.current_vessels_rego_list && !this.readonly) {
+ if (!this.vesselOwnershipExists){
+ readonly = false
+ } else if (this.proposal && !this.proposal.approval_vessel_rego_no && !this.proposal.current_vessels_rego_list && !this.readonly) {
readonly = false;
} else if ((this.proposal && this.keep_current_vessel && ['amendment', 'renewal'].includes(this.proposal.proposal_type.code)) ||
this.readonly ||
- (this.proposal.pending_amendment_request && ['wla', 'aaa'].includes(this.proposal.application_type_code))
- ) {
+ (this.proposal.pending_amendment_request && ['wla', 'aaa'].includes(this.proposal.application_type_code))) {
readonly = true;
}
return readonly;
diff --git a/mooringlicensing/frontend/mooringlicensing/src/components/external/proposal.vue b/mooringlicensing/frontend/mooringlicensing/src/components/external/proposal.vue
index 07665b44d..1d6039cbb 100755
--- a/mooringlicensing/frontend/mooringlicensing/src/components/external/proposal.vue
+++ b/mooringlicensing/frontend/mooringlicensing/src/components/external/proposal.vue
@@ -207,24 +207,9 @@ export default {
disableSubmit: function() {
console.log('%cdisableSubmit() is being called...', 'color: #FF0000')
let disable = false;
- // if (this.proposal && this.proposal.proposal_type.code ==='amendment' && this.missingVessel) {
- // console.log('%cHere1', 'color: #FF0000')
- // disable = true;
- // } else if (this.proposal && this.proposal.proposal_type.code ==='amendment') {
- // if (['aaa', 'mla'].includes(this.proposal.application_type_code) && !this.vesselChanged) {
- // console.log('%cHere2', 'color: #FF0000')
- // disable = true;
- // } else if (this.proposal.application_type_code === 'wla' && !this.vesselChanged && !this.mooringPreferenceChanged) {
- // console.log('%cHere3', 'color: #FF0000')
- // disable = true;
- // } else if (this.proposal.application_type_code === 'aua' && !this.vesselChanged && !this.mooringOptionsChanged) {
- // console.log('%cHere4', 'color: #FF0000')
- // disable = true;
- // }
- // }
if (this.proposal){
if (this.proposal.proposal_type.code ==='amendment'){
- if (this.missingVessel){
+ if (this.missingVessel && ['aaa', 'aua'].includes(this.proposal.application_type_code)){
disable = true;
} else {
if (['aaa', 'mla'].includes(this.proposal.application_type_code)){
diff --git a/mooringlicensing/migrations/0331_auto_20230922_1042.py b/mooringlicensing/migrations/0331_auto_20230922_1042.py
new file mode 100644
index 000000000..cebe9781d
--- /dev/null
+++ b/mooringlicensing/migrations/0331_auto_20230922_1042.py
@@ -0,0 +1,27 @@
+# Generated by Django 3.2.20 on 2023-09-22 02:42
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('mooringlicensing', '0330_remove_companyownership_status'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='sticker',
+ options={'ordering': ['-date_updated', '-date_created']},
+ ),
+ migrations.AddField(
+ model_name='sticker',
+ name='date_created',
+ field=models.DateTimeField(auto_now_add=True, null=True),
+ ),
+ migrations.AddField(
+ model_name='sticker',
+ name='date_updated',
+ field=models.DateTimeField(auto_now=True, null=True),
+ ),
+ ]
diff --git a/mooringlicensing/templates/mooringlicensing/emails_2/email_36.html b/mooringlicensing/templates/mooringlicensing/emails_2/email_36.html
index 756681ec2..cf46dec57 100755
--- a/mooringlicensing/templates/mooringlicensing/emails_2/email_36.html
+++ b/mooringlicensing/templates/mooringlicensing/emails_2/email_36.html
@@ -2,7 +2,7 @@
{% block content_body %}
{% include "mooringlicensing/emails_2/salutation.html" %}
-
Your request to replace {{ sticker.number }} has been received. Please find attached to this email your invoice as proof of payment.
+Your request to replace sticker(s): {{ old_sticker_numbers }} has been received. Please find attached to this email your invoice as proof of payment.
Your replacement sticker(s) will be posted to you in the coming days. Once received, you must ensure it is displayed on your vessel at all times whilst within the limits of the Reserve.
{% include "mooringlicensing/emails/signature-rottnest.html" %} {% endblock %} diff --git a/mooringlicensing/templates/mooringlicensing/emails_2/email_36.txt b/mooringlicensing/templates/mooringlicensing/emails_2/email_36.txt index e367327ec..bca7e25e3 100755 --- a/mooringlicensing/templates/mooringlicensing/emails_2/email_36.txt +++ b/mooringlicensing/templates/mooringlicensing/emails_2/email_36.txt @@ -2,7 +2,7 @@ {% block content_body %} {% include "mooringlicensing/emails_2/salutation.txt" %} -Your request to replace {{ sticker.number }} has been received. Please find attached to this email your invoice as proof of payment. +Your request to replace sticker(s): {{ old_sticker_numbers }} has been received. Please find attached to this email your invoice as proof of payment. Your replacement sticker(s) will be posted to you in the coming days. Once received, you must ensure it is displayed on your vessel at all times whilst within the limits of the Reserve. {% include "mooringlicensing/emails/signature-rottnest.txt" %} {% endblock %}