{% extends 'auth/dashboard.html' %} {% load static %} {% load humanize %} {% block title %}Group Contract #{{ contract.id }} - Bomabest Agriservices{% endblock %} {% block content %}

Group Contract #{{ contract.id }}

Created: {{ contract.created_at|date:"Y-m-d H:i" }} {% if contract.created_by %} • By: {{ contract.created_by.get_full_name }}{% endif %}

{{ contract.get_status_display }} Back

Group

{{ contract.group.name }}

{{ contract.group.registration_number }}

{{ contract.group.location }}

Contract

Type: {{ contract.get_type_display }}

Payment Term: {{ contract.get_payment_term_display }}

Months: {{ contract.months_for_payment }}

Grace (days): {{ contract.grace_period }}

Deposit: KES {{ contract.deposit_amount|floatformat:0|intcomma }}

Approval

Approved: {{ contract.is_approved|yesno:"Yes,No" }}

{% if contract.approved_by %}

By: {{ contract.approved_by.get_full_name }}

{% endif %} {% if contract.approved_at %}

At: {{ contract.approved_at|date:"Y-m-d H:i" }}

{% endif %}

Quick Actions

Use these to keep the workflow moving.
{% if is_admin %} {% if contract.status == 'DRAFT' %} {% endif %} {% if contract.status == 'DEPOSIT_PAID' and can_show_activate_button %} {% endif %} {% endif %} {% if is_signatory and can_show_deposit_button %} Pay Deposit {% endif %}
{% if contract.status == 'DEPOSIT_PAID' and not can_show_activate_button %}
Deposit paid ✅
Awaiting activation by admin/field officer.
{% endif %}

Workflow

Green shows completed steps. Yellow shows current step.
1
Drafted
Created by signatory / admin.
{% if contract.status == 'DRAFT' %}
2
Approved
Admin/Field officer approval.
{% else %}
2
Approved
Admin/Field officer approval.
{% endif %} {% if contract.status == 'APPROVED' or contract.status == 'PARTIALLY_SIGNED' %}
3
Signing
{% if is_fully_signed %} Fully signed ✅ ({{ signed_count }}/3) {% else %} In progress ({{ signed_count }}/3) {% endif %}
{% elif contract.status == 'FULLY_SIGNED' or contract.status == 'DEPOSIT_PAID' or contract.status == 'ACTIVE' or contract.status == 'COMPLETED' %}
3
Signing
Fully signed ✅ ({{ signed_count }}/3)
{% else %}
3
Signing
Pending signatures ({{ signed_count }}/3)
{% endif %} {% if contract.status == 'FULLY_SIGNED' %}
4
Deposit
Pay deposit after full signing
{% elif contract.status == 'DEPOSIT_PAID' or contract.status == 'ACTIVE' or contract.status == 'COMPLETED' %}
4
Deposit
Deposit paid ✅
{% else %}
4
Deposit
Pay deposit after full signing
{% endif %} {% if contract.status == 'DEPOSIT_PAID' %}
5
Activation
Issue product / activate contract.
{% elif contract.status == 'ACTIVE' or contract.status == 'COMPLETED' %}
5
Activation
Activated ✅
{% else %}
5
Activation
Issue product / activate contract.
{% endif %} {% if contract.status == 'ACTIVE' %}
6
Installments
Ongoing payments…
{% elif contract.status == 'COMPLETED' %}
6
Installments
Completed ✅
{% else %}
6
Installments
Starts after activation
{% endif %}
{% if contract.status == 'CANCELLED' or contract.status == 'DEFAULTED' %}
Attention: {{ contract.get_status_display }}
This contract is not progressing through the normal workflow.
{% endif %}

Signatories

Signed: {{ signed_count }}/3 {% if is_fully_signed %} Fully signed ✅ {% else %} Pending signatures {% endif %}
{% for r in signatory_rows %}
{{ r.role }}
{{ r.user.get_full_name }}
{% if r.user.phone_number %}
{{ r.user.phone_number }}
{% endif %}
{% if r.signed %} Signed ✅ {% else %} Pending {% endif %}
{% if r.signed and r.signed_at %}
Signed at: {{ r.signed_at|date:"Y-m-d H:i" }}
{% endif %} {% if is_signatory and user_role == r.role %}
{% if user_has_signed %}
You have signed as {{ user_role }}. ✅
{% else %} {% if user_can_sign %} Sign as {{ user_role }} {% else %}
{{ sign_disabled_reason|default:"You cannot sign at the moment." }}
{% endif %} {% endif %}
{% endif %}
{% endfor %}
{% if show_pending_signatures_banner %}
Waiting for signatures from:
{{ pending_roles|join:", " }}
{% endif %}
{% if messages %}
{% for message in messages %}
{{ message }}
{% endfor %}
{% endif %}

Inputs

{% for item in inputs %} {% empty %} {% endfor %}
Package Qty Unit Price Line Total
{{ item.input }} {{ item.quantity }} KES {{ item.unit_price|floatformat:0|intcomma }} KES {{ item.total_price|floatformat:0|intcomma }}
No inputs found.

Payment Schedule

{% if contract.payment_schedules.exists %} Total schedules: {{ contract.payment_schedules.count }} {% endif %}
{% if not contract.payment_schedules.exists %}
Payment schedules not generated yet.
Schedules are expected to be generated once the last signatory signs (and also ensured after deposit success).
{% else %}
{% for s in contract.payment_schedules.all %} {% with due=s.amount_due paid=s.amount_paid bal=s.balance %} {% endwith %} {% empty %} {% endfor %}
# Due Date Amount Due Paid Balance Progress Status Action
#{{ s.installment_number }} {{ s.due_date|date:"M d, Y" }} KES {{ due|floatformat:0|intcomma }} KES {{ paid|floatformat:0|intcomma }} KES {{ bal|floatformat:0|intcomma }} {% if due > 0 %} {% widthratio paid due 100 as pct %} {% else %} {% widthratio 0 1 100 as pct %} {% endif %}
{{ pct }}%
{{ s.get_status_display }} {% if s.status != 'PAID' %} {% if is_signatory or is_admin %} Pay {% else %} {% endif %} {% else %} Paid ✅ {% endif %}
No payment schedule generated yet.
{% endif %}
{% if is_admin and contract.status == 'DRAFT' %} {% endif %} {% if contract.status == 'DEPOSIT_PAID' and can_show_activate_button %} {% endif %} {% endblock %}