Projectreportdetail Documentation

Project Detailed Financial Report Controller Documentation

File: /controllers/projectreportControllerdetail.php

Purpose: Generate comprehensive financial analysis with detailed breakdowns for individual projects

Last Updated: 2024-12-20

---

๐Ÿ“‹ Overview

Primary Functions

Related Controllers

---

๐Ÿ—„๏ธ Database Tables

Primary Tables

All tables from projectReportController.php plus detailed material breakdowns

---

๐Ÿ”ง Key Functions

1. Financial Analysis Engine

Purpose: Comprehensive financial breakdown with detailed material tracking

Business Logic:

Client Payments Analysis:

$clientdebtchangeData = R::getAll("SELECT * FROM clientdebtchange WHERE clientdebtchange.del = 0 and paySerialNo > 0 and clientdebtchange.clientid = $projectData->clientid");
$clientdebtchangeamount = R::getCell("SELECT sum(clientdebtchangeamount) FROM clientdebtchange WHERE clientdebtchange.del = 0 and paySerialNo > 0 and clientdebtchange.clientid = $projectData->clientid");
$clientdebtchangeamountint = abs($clientdebtchangeamount);

Income Analysis:

$incomeData = R::getAll("SELECT * FROM `income` left join incometype on income.incomeTypeId = incometype.incomeTypeId WHERE income.conditions = 0 and income.costcenterid = $projectData->costcenterid");
$allincomeValue = R::getCell("SELECT sum(incomeValue) FROM `income` left join incometype on income.incomeTypeId = incometype.incomeTypeId WHERE income.conditions = 0 and income.costcenterid = $projectData->costcenterid");

Material Cost Analysis:

$projectexchmaterial = R::findAll('projectexchmaterial'," WHERE projectexchmaterial.projectid = $projectId");
foreach($projectexchmaterial as $projecte) {
    $projectepro = R::getAll("SELECT * FROM projectexchmaterialdetail left join product on projectexchmaterialdetail.productId = product.productId WHERE projectexchmaterialdetail.projectexchid = $projecte->id");
    $projecte->proname = $projectepro;
}
$projectexchmaterialtotal = R::getRow("SELECT sum(totalbuyprice) as totals, sum(finalsupervision) as finalsupervisions FROM projectexchmaterial WHERE projectexchmaterial.projectid = $projectId");

Supervision Fee Calculation:

$finalsupervisions = ($sumexpenseexchanges['finalsupervisions'] + $projectexchmaterialtotal['finalsupervisions']) - $projectexchmaterialreturntotal['finalsupervisions'];

Final Position Calculation:

$proMasrofat = $clientdebtchangeamountint + $allincomeValue;
$clientPaids = $projectexchmaterialtotal['totals'] - $projectexchmaterialreturntotal['totals'] + $allexpensesValue + $allsupplierdebtchangeamount + $finalsupervisions;

$operation = abs($clientPaids) - $proMasrofat;

if($proMasrofat < abs($clientPaids)) {
    $txt = 'ุตุงููŠ ู…ุฏูŠูˆู†ูŠุฉ'; // Net Debt
} else {
    $txt = 'ุตุงููŠ ุฑุตูŠุฏ'; // Net Credit
}

---

๐Ÿ“Š Financial Components

Revenue Streams

1. Client Payments: Direct payments with serial numbers

2. Project Income: Additional income by cost center

3. Total Revenue: Sum of all income sources

Cost Components

1. Material Costs: Net materials (issued - returned)

2. Direct Expenses: Operating expenses by cost center

3. Supervision Fees: Project management fees

4. Total Costs: Sum of all project costs

Financial Position Analysis

Total Revenue = Client Payments + Project Income
Total Costs = Material Costs + Expenses + Supervision
Net Position = |Total Costs| - Total Revenue

If Revenue > Costs: Net Credit Balance
If Costs > Revenue: Net Debt Position

---

๐ŸŽฏ URL Routes & Actions

Action (`?do=`)MethodDescriptionView Template
(empty)GET/POSTGenerate detailed financial reportreportdetail.html
---

๐Ÿ“ Notes

Important Features

Report Components Displayed

---

๐Ÿ“š Related Documentation