Remove debugging code from calculation system
Cleaned up: - Removed error_log statements from getAccountAmounts() - Removed debugging from calculateCA3Amounts() - Calculation system is working correctly - Ready for production use with real accounting data
This commit is contained in:
parent
a363c301ff
commit
ca8b50241b
@ -190,19 +190,14 @@ class DeclarationTVA
|
|||||||
*/
|
*/
|
||||||
public function calculateCA3Amounts($declaration_id, $period)
|
public function calculateCA3Amounts($declaration_id, $period)
|
||||||
{
|
{
|
||||||
error_log("DeclarationTVA: Starting calculation for declaration $declaration_id");
|
|
||||||
error_log("DeclarationTVA: Period: " . $period['start_date'] . " to " . $period['end_date']);
|
|
||||||
|
|
||||||
// Get account mappings
|
// Get account mappings
|
||||||
$mappings = $this->getAccountMappings();
|
$mappings = $this->getAccountMappings();
|
||||||
error_log("DeclarationTVA: Found " . count($mappings) . " account mappings");
|
|
||||||
|
|
||||||
$total_vat_collected = 0;
|
$total_vat_collected = 0;
|
||||||
$total_vat_deductible = 0;
|
$total_vat_deductible = 0;
|
||||||
|
|
||||||
// Process each CA-3 line
|
// Process each CA-3 line
|
||||||
foreach ($mappings as $mapping) {
|
foreach ($mappings as $mapping) {
|
||||||
error_log("DeclarationTVA: Processing mapping: " . $mapping['ca3_line'] . " -> " . $mapping['account_code']);
|
|
||||||
$amounts = $this->getAccountAmounts($mapping['account_code'], $period['start_date'], $period['end_date']);
|
$amounts = $this->getAccountAmounts($mapping['account_code'], $period['start_date'], $period['end_date']);
|
||||||
|
|
||||||
// Create CA-3 line record
|
// Create CA-3 line record
|
||||||
@ -216,8 +211,6 @@ class DeclarationTVA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error_log("DeclarationTVA: Totals - Collected: $total_vat_collected, Deductible: $total_vat_deductible");
|
|
||||||
|
|
||||||
// Calculate net amounts
|
// Calculate net amounts
|
||||||
$net_vat_due = $total_vat_collected - $total_vat_deductible;
|
$net_vat_due = $total_vat_collected - $total_vat_deductible;
|
||||||
$vat_credit = $net_vat_due < 0 ? abs($net_vat_due) : 0;
|
$vat_credit = $net_vat_due < 0 ? abs($net_vat_due) : 0;
|
||||||
@ -246,25 +239,17 @@ class DeclarationTVA
|
|||||||
AND doc_date >= '" . $this->db->escape($start_date) . "'
|
AND doc_date >= '" . $this->db->escape($start_date) . "'
|
||||||
AND doc_date <= '" . $this->db->escape($end_date) . "'";
|
AND doc_date <= '" . $this->db->escape($end_date) . "'";
|
||||||
|
|
||||||
// Debug: Log the query
|
|
||||||
error_log("DeclarationTVA: Querying account $account_code from $start_date to $end_date");
|
|
||||||
error_log("DeclarationTVA: SQL: $sql");
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result && $this->db->num_rows($result) > 0) {
|
if ($result && $this->db->num_rows($result) > 0) {
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
$total_amount = $obj->total_debit - $obj->total_credit;
|
$total_amount = $obj->total_debit - $obj->total_credit;
|
||||||
|
|
||||||
error_log("DeclarationTVA: Found amounts for $account_code: debit=$obj->total_debit, credit=$obj->total_credit, net=$total_amount");
|
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'base_amount' => $total_amount,
|
'base_amount' => $total_amount,
|
||||||
'vat_amount' => $total_amount,
|
'vat_amount' => $total_amount,
|
||||||
'total_amount' => $total_amount
|
'total_amount' => $total_amount
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
error_log("DeclarationTVA: No data found for account $account_code");
|
|
||||||
return array('base_amount' => 0, 'vat_amount' => 0, 'total_amount' => 0);
|
return array('base_amount' => 0, 'vat_amount' => 0, 'total_amount' => 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user