Back to ER Diagram
Contract Management

Contract Management System

Comprehensive documentation of the contract lifecycle management system including framework agreements, rate contracts, amendments, milestones, and compliance tracking.

PostgreSQL
6 Tables
Auto-Renewal Support
Schema v2.4

Contract Types

ProKure supports various types of vendor contracts to accommodate different procurement scenarios.

FRAMEWORK

Master agreement with multiple vendors for same items

RATE_CONTRACT

Fixed pricing for items over a period

SERVICE

Service-based contracts with milestones

BLANKET

Pre-approved spend limit with vendor

AMC

Annual Maintenance Contracts

Contract Lifecycle

DRAFT
PENDING_APPROVAL
ACTIVE
EXPIRED
RENEWED
ACTIVE
TERMINATED
Status Description Actions Allowed
DRAFT Contract being created, not yet submitted Edit, Delete, Submit for Approval
PENDING_APPROVAL Awaiting approval from authorized users Approve, Reject, Request Changes
ACTIVE Contract is in effect, POs can reference it Amend, Create PO, Track Compliance
EXPIRED Contract end date has passed Renew, Archive
TERMINATED Manually terminated before expiry View Only, Audit

Contract Tables

contract.contracts (Header)

  • contract_number - Unique contract identifier (auto-generated)
  • vendor_id - Vendor party to the contract
  • contract_type - FRAMEWORK, RATE_CONTRACT, SERVICE, BLANKET, AMC
  • start_date / end_date - Contract validity period
  • contract_value - Total contract value (for blanket types)
  • utilized_value - Amount already used from contract
  • auto_renew - Automatic renewal flag
  • renewal_notice_days - Days before expiry to notify

contract.contract_items

  • item_id - Reference to inventory.items
  • unit_price - Contracted price per unit
  • price_type - FIXED, VARIABLE, INDEXED, TIERED
  • min_quantity / max_quantity - Order quantity limits
  • ordered_quantity - Total ordered against this line
  • effective_from / effective_until - Price validity period

contract.contract_amendments

  • amendment_number - Sequential amendment counter
  • amendment_type - VALUE_CHANGE, EXTENSION, SCOPE_CHANGE, PRICE_REVISION
  • old_value / new_value - JSONB before/after snapshots
  • value_change - Net change in contract value
  • end_date_change - New end date if extended

contract.contract_milestones

  • milestone_name - Milestone description
  • planned_date / actual_date - Schedule tracking
  • due_amount / paid_amount - Payment tracking
  • deliverables - Expected deliverables text
  • acceptance_criteria - Completion criteria
  • status - PENDING, IN_PROGRESS, COMPLETED, DELAYED

contract.contract_compliance

  • compliance_type - DELIVERY, QUALITY, DOCUMENTATION, INSURANCE, LICENSE
  • is_compliant - Pass/fail status
  • non_compliance_details - Issue description
  • corrective_action - Required remediation
  • severity - LOW, MEDIUM, HIGH, CRITICAL
  • risk_score - Numeric risk assessment

Purchase Order Linking

Purchase Orders can reference active contracts to automatically apply negotiated pricing and terms.

Create PO
Select Vendor
Check Active Contracts
Contract Found?
Apply Contract Pricing
Update utilized_value
-- Query to find applicable contract for a vendor-item combination
SELECT
    c.contract_number,
    c.contract_name,
    ci.unit_price,
    ci.discount_percent,
    (c.contract_value - c.utilized_value) AS remaining_value
FROM contract.contracts c
JOIN contract.contract_items ci ON c.id = ci.contract_id
WHERE
    c.vendor_id = :vendor_id
    AND ci.item_id = :item_id
    AND c.status = 'ACTIVE'
    AND CURRENT_DATE BETWEEN c.start_date AND c.end_date
    AND CURRENT_DATE BETWEEN ci.effective_from AND ci.effective_until
    AND ci.is_active = true
ORDER BY ci.unit_price ASC
LIMIT 1;

Automatic Utilization Tracking

When a PO is created against a contract, the system automatically updates utilized_value on the contract header and ordered_quantity on the contract item. This prevents over-ordering beyond contract limits.

Amendment Process

1

Initiate Amendment

User creates amendment request specifying the type of change (value change, extension, scope change, or price revision).

Amendment Types

  • VALUE_CHANGE - Increase or decrease contract value
  • EXTENSION - Extend contract end date
  • SCOPE_CHANGE - Add/remove items or modify quantities
  • PRICE_REVISION - Adjust unit prices
  • TERMINATION - Early termination of contract
2

Capture Before/After State

System captures the current contract state in old_value JSONB field and proposed changes in new_value.

-- Example amendment record
{
  "old_value": {
    "contract_value": 500000,
    "end_date": "2026-12-31"
  },
  "new_value": {
    "contract_value": 750000,
    "end_date": "2027-06-30"
  },
  "value_change": 250000,
  "end_date_change": "2027-06-30"
}
3

Approval Workflow

Amendment follows the standard approval matrix. Value-based approvals apply to the amendment value, not the full contract value.

4

Apply Amendment

Upon approval, the amendment is applied to the contract. All changes are audited with full before/after state preservation.

Auto-Renewal Logic

Configuration

  • auto_renew - Enable/disable auto-renewal
  • renewal_period_months - Duration of renewal
  • renewal_notice_days - Days before expiry to notify
  • max_renewals - Maximum renewal count
  • current_renewal - Current renewal counter

Scheduled Jobs

  • Daily job checks for expiring contracts
  • Sends notification at renewal_notice_days
  • Creates renewal amendment if auto_renew=true
  • Increments current_renewal counter
  • Updates end_date by renewal_period_months
-- Scheduled job: Check contracts expiring within notice period
SELECT
    c.id,
    c.contract_number,
    c.end_date,
    c.renewal_notice_days,
    c.owner_id
FROM contract.contracts c
WHERE
    c.status = 'ACTIVE'
    AND c.end_date BETWEEN CURRENT_DATE
        AND CURRENT_DATE + (c.renewal_notice_days || ' days')::INTERVAL
    AND NOT EXISTS (
        -- Avoid duplicate notifications
        SELECT 1 FROM config.notifications n
        WHERE n.entity_type = 'CONTRACT'
        AND n.entity_id = c.id
        AND n.notification_type = 'EXPIRY_REMINDER'
        AND n.created_at > CURRENT_DATE - INTERVAL '7 days'
    );

Renewal Limits

When current_renewal >= max_renewals, auto-renewal is disabled for that contract. The owner receives a notification indicating manual intervention is required for continued service.

Compliance Tracking

Contract compliance tracks vendor adherence to contractual obligations across multiple dimensions.

DELIVERY

On-time delivery performance

QUALITY

Product quality standards

DOCUMENTATION

Required document submissions

INSURANCE

Valid insurance coverage

LICENSE

Valid licenses/certifications

-- Query non-compliant contracts with severity
SELECT
    c.contract_number,
    c.vendor_id,
    v.vendor_name,
    cc.compliance_type,
    cc.compliance_item,
    cc.severity,
    cc.action_due_date,
    CASE
        WHEN cc.action_due_date < CURRENT_DATE THEN 'OVERDUE'
        WHEN cc.action_due_date <= CURRENT_DATE + 7 THEN 'DUE_SOON'
        ELSE 'ON_TRACK'
    END AS urgency
FROM contract.contract_compliance cc
JOIN contract.contracts c ON cc.contract_id = c.id
JOIN vendor.vendors v ON c.vendor_id = v.id
WHERE
    cc.is_compliant = false
    AND cc.action_completed_date IS NULL
    AND c.status = 'ACTIVE'
ORDER BY
    CASE cc.severity
        WHEN 'CRITICAL' THEN 1
        WHEN 'HIGH' THEN 2
        WHEN 'MEDIUM' THEN 3
        ELSE 4
    END,
    cc.action_due_date;

Best Practices

Define Clear Milestones

For service contracts, define milestones with specific deliverables and acceptance criteria. This enables objective completion tracking and payment scheduling.

Set Appropriate Notice Periods

Configure renewal_notice_days based on contract complexity. Simple rate contracts may need 30 days; complex service agreements may need 90+ days for renegotiation.

Monitor Utilization

Set up alerts when utilized_value reaches 80% of contract_value. This provides time to negotiate amendments or new contracts before limits are reached.

Regular Compliance Reviews

Schedule periodic compliance reviews (monthly/quarterly) for critical contracts. Use the compliance table to track findings and corrective actions systematically.