# Project Enhancement Requirement - Account Wise Approval Workflow

## Overview

This document describes the proposed changes to the existing **Payment
Letter Approval Workflow**. The objective is to replace the current
**project-level approval hierarchy** with an **account-level approval
hierarchy**, while keeping the overall payment letter workflow
unchanged.

------------------------------------------------------------------------

# Current System

## Existing Module Structure

Currently, every **Project** contains a predefined approval hierarchy.

### Workflow

1.  A payment letter is created under a project.
2.  The payment letter follows the approval levels configured for that
    project.
3.  Each approval level contains a single approver.
4.  After all approvals are completed, the remaining payment letter
    process continues as implemented.

### Current Limitation

Every payment letter within a project follows the same approval
hierarchy regardless of the department or account responsible for
raising it.

------------------------------------------------------------------------

# Proposed Module Structure

## Account (Department / Section)

Each project can contain multiple accounts (departments), such as:

-   Diesel
-   Sub Contractor
-   Stationery
-   Labour
-   Machinery
-   Transport

Each account acts as an independent department responsible for raising
payment letters.

------------------------------------------------------------------------

# Account Incharge

Each account will have one or more **Account Incharges**.

### Responsibilities

-   Raise payment letters for the assigned account.
-   View payment letters belonging to their assigned account(s).
-   Initiate the approval workflow.

An account may have one or multiple Account Incharges.

------------------------------------------------------------------------

# Approval Workflow Changes

## Existing Flow

``` text
Project
    ↓
Project Approval Levels
    ↓
Payment Letter Approval
```

## Proposed Flow

``` text
Project
    ↓
Account / Department
    ↓
Account Specific Approval Levels
    ↓
Payment Letter Approval
```

Each account maintains its own approval hierarchy.

Example:

### Diesel Account

-   Level 1 → User A
-   Level 2 → User B
-   Level 3 → User C

### Stationery Account

-   Level 1 → User D
-   Level 2 → User E

### Sub Contractor Account

-   Level 1 → User F
-   Level 2 → User G
-   Level 3 → User H

------------------------------------------------------------------------

# Multiple Approvers Per Level

Unlike the existing implementation, a single approval level can contain
multiple approvers.

Example:

### Diesel Account

**Level 1**

-   User A
-   User B
-   User C

**Level 2**

-   User D
-   User E

## Recommended Approval Logic

-   The payment letter is assigned to all users in the current level.
-   Approval from **any one** user completes that level.
-   The request automatically moves to the next level.
-   Remaining users at the completed level can no longer approve that
    payment letter.

> **Optional:** This can later be made configurable if unanimous
> approval is required.

------------------------------------------------------------------------

# Payment Letter Flow

``` text
Account Incharge
        ↓
Raise Payment Letter
        ↓
Account Approval Level 1
        ↓
Account Approval Level 2
        ↓
...
        ↓
Final Approval
        ↓
Existing Payment Processing Flow
```

Only the approval source changes from **Project** to **Account**.

------------------------------------------------------------------------

# Functional Requirements

## 1. Account Management

-   Create multiple accounts under a project.
-   Edit account details.
-   Activate/Deactivate accounts.
-   Assign multiple Account Incharges.

## 2. Approval Configuration

Each account should support:

-   Multiple approval levels.
-   Configurable approval sequence.
-   Multiple approvers per level.
-   Activation/Deactivation of approval levels.

## 3. Payment Letter Creation

-   User selects the project.
-   User selects the account.
-   System validates the user is an Account Incharge.
-   System loads the account-specific approval hierarchy.
-   Approval starts from Level 1.

## 4. Approval Processing

The system should:

-   Identify the current approval level.
-   Notify all users mapped to that level.
-   Accept approval from an authorized approver.
-   Move to the next level until completion.

------------------------------------------------------------------------

# Database Impact

## Suggested Entities

### Account

-   Account ID
-   Project ID
-   Account Name
-   Description
-   Status

### Account Incharge Mapping

-   Mapping ID
-   Account ID
-   User ID

### Account Approval Levels

-   Level ID
-   Account ID
-   Level Number
-   Status

### Account Approval Users

-   Mapping ID
-   Approval Level ID
-   User ID

------------------------------------------------------------------------

# Business Rules

1.  Every account belongs to a project.
2.  Every account must have at least one Account Incharge.
3.  Every account must have at least one approval level.
4.  Every approval level must contain at least one approver.
5.  Different accounts may have completely different approval
    hierarchies.
6.  Multiple users can exist within the same approval level.
7.  Payment letters always follow the selected account's approval
    hierarchy.
8.  Apart from the approval hierarchy source, the remaining payment
    letter flow remains unchanged.

------------------------------------------------------------------------

# Benefits

-   Department-specific approval workflows.
-   Flexible approval configuration.
-   Multiple approvers per level.
-   Easier maintenance.
-   Better scalability.
-   Minimal impact on the existing payment processing flow.

------------------------------------------------------------------------

# Summary

This enhancement introduces an **Account-wise Approval Workflow** where
every account within a project maintains its own approval hierarchy.
Multiple Account Incharges can raise payment letters, and each approval
level can have multiple approvers. The rest of the payment letter
lifecycle remains unchanged.
