Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,27 @@
class ContainerInterchange(Document):
def before_submit(self):
self.validate_shipping_line_deposit()
self.validate_final_eir_against_delivery_note()

def validate_final_eir_against_delivery_note(self):
if not self.clearing_file:
return

has_linked_delivery_note = bool(
frappe.db.exists(
"CF Delivery Note",
{"container_interchange": self.name, "docstatus": ["<", 2]},
)
)
if not has_linked_delivery_note:
return

if not self.final or not self.eir_number_reference or not self.eir_date:
frappe.throw(
_("Final EIR is required (Has Final EIR, EIR Number Reference, EIR Date) before submitting.")
)

def validate_shipping_line_deposit(self):
"""Block submission if no container deposit is recorded in the Shipping Line Clearance,
or if a deposit exists but the refund has not been updated on this Container Interchange."""
if not self.clearing_file:
return

Expand All @@ -24,12 +41,7 @@ def validate_shipping_line_deposit(self):
)

if not flt(deposit_amount):
frappe.throw(
_(
"Cannot submit Container Interchange because no Container Deposit Amount "
"is recorded in the Shipping Line Clearance for Clearing File {0}."
).format(self.clearing_file)
)
return

if not self.refund or not flt(self.refund_amount) or not self.refund_date:
frappe.throw(
Expand Down
Loading