fix date in payment and imporove contract page.
This commit is contained in:
parent
af40e169ae
commit
204b0aa48e
14 changed files with 295 additions and 74 deletions
|
@ -172,18 +172,24 @@ def create_quote(request, instance_id, step_id):
|
|||
quote.status = 'draft'
|
||||
quote.save(update_fields=['status'])
|
||||
|
||||
if next_step:
|
||||
next_step_instance = instance.step_instances.filter(step=next_step).first()
|
||||
if next_step_instance and next_step_instance.status == 'completed':
|
||||
next_step_instance.status = 'in_progress'
|
||||
next_step_instance.completed_at = None
|
||||
next_step_instance.save(update_fields=['status', 'completed_at'])
|
||||
# Reset ALL subsequent completed steps to in_progress
|
||||
subsequent_steps = instance.process.steps.filter(order__gt=step.order)
|
||||
for subsequent_step in subsequent_steps:
|
||||
subsequent_step_instance = instance.step_instances.filter(step=subsequent_step).first()
|
||||
if subsequent_step_instance and subsequent_step_instance.status == 'completed':
|
||||
# Bypass validation by using update() instead of save()
|
||||
instance.step_instances.filter(step=subsequent_step).update(
|
||||
status='in_progress',
|
||||
completed_at=None
|
||||
)
|
||||
# Clear previous approvals if the step requires re-approval
|
||||
try:
|
||||
next_step_instance.approvals.all().delete()
|
||||
subsequent_step_instance.approvals.all().delete()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Set current step to the next step
|
||||
if next_step:
|
||||
instance.current_step = next_step
|
||||
instance.save(update_fields=['current_step'])
|
||||
|
||||
|
@ -524,6 +530,26 @@ def add_quote_payment(request, instance_id, step_id):
|
|||
si.approvals.all().delete()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Reset ALL subsequent completed steps to in_progress
|
||||
try:
|
||||
subsequent_steps = instance.process.steps.filter(order__gt=step.order)
|
||||
for subsequent_step in subsequent_steps:
|
||||
subsequent_step_instance = instance.step_instances.filter(step=subsequent_step).first()
|
||||
if subsequent_step_instance and subsequent_step_instance.status == 'completed':
|
||||
# Bypass validation by using update() instead of save()
|
||||
instance.step_instances.filter(step=subsequent_step).update(
|
||||
status='in_progress',
|
||||
completed_at=None
|
||||
)
|
||||
# Clear previous approvals if the step requires re-approval
|
||||
try:
|
||||
subsequent_step_instance.approvals.all().delete()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# If current step is ahead of this step, reset it back to this step
|
||||
try:
|
||||
if instance.current_step and instance.current_step.order > step.order:
|
||||
|
@ -572,6 +598,26 @@ def delete_quote_payment(request, instance_id, step_id, payment_id):
|
|||
si.approvals.all().delete()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Reset ALL subsequent completed steps to in_progress
|
||||
try:
|
||||
subsequent_steps = instance.process.steps.filter(order__gt=step.order)
|
||||
for subsequent_step in subsequent_steps:
|
||||
subsequent_step_instance = instance.step_instances.filter(step=subsequent_step).first()
|
||||
if subsequent_step_instance and subsequent_step_instance.status == 'completed':
|
||||
# Bypass validation by using update() instead of save()
|
||||
instance.step_instances.filter(step=subsequent_step).update(
|
||||
status='in_progress',
|
||||
completed_at=None
|
||||
)
|
||||
# Clear previous approvals if the step requires re-approval
|
||||
try:
|
||||
subsequent_step_instance.approvals.all().delete()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# If current step is ahead of this step, reset it back to this step
|
||||
try:
|
||||
if instance.current_step and instance.current_step.order > step.order:
|
||||
|
@ -1000,6 +1046,25 @@ def add_final_payment(request, instance_id, step_id):
|
|||
si.save()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Reset ALL subsequent completed steps to in_progress
|
||||
try:
|
||||
subsequent_steps = instance.process.steps.filter(order__gt=step.order)
|
||||
for subsequent_step in subsequent_steps:
|
||||
subsequent_step_instance = instance.step_instances.filter(step=subsequent_step).first()
|
||||
if subsequent_step_instance and subsequent_step_instance.status == 'completed':
|
||||
# Bypass validation by using update() instead of save()
|
||||
instance.step_instances.filter(step=subsequent_step).update(
|
||||
status='in_progress',
|
||||
completed_at=None
|
||||
)
|
||||
# Clear previous approvals if the step requires re-approval
|
||||
try:
|
||||
subsequent_step_instance.approvals.all().delete()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
return JsonResponse({
|
||||
'success': True,
|
||||
'redirect': reverse('invoices:final_settlement_step', args=[instance.id, step_id]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue