Add Asset Management app
Assets from purchase invoice lines, straight-line depreciation/amortization with salvage value, disposals, and [Asset Mgmt] sources in Batch GL Entries. Green third workspace with an app access guard.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../classes_as/AssetPosting.php';
|
||||
|
||||
class GlQueryManager
|
||||
{
|
||||
private PDO $pdo;
|
||||
@@ -6,8 +8,10 @@ class GlQueryManager
|
||||
|
||||
private array $invoiceTypes = ['invoice', 'credit_note', 'purchase_invoice', 'supplier_credit_note'];
|
||||
private array $mappingTypes = ['invoice', 'credit_note', 'purchase_invoice', 'supplier_credit_note', 'purchase_order'];
|
||||
private array $postingTypes = ['invoice', 'credit_note', 'purchase_invoice', 'supplier_credit_note', 'receipt', 'payment', 'purchase_order'];
|
||||
private array $journalTypes = ['invoice', 'credit_note', 'purchase_invoice', 'supplier_credit_note', 'receipt', 'payment', 'manual', 'purchase_order', 'reversal'];
|
||||
private array $postingTypes = ['invoice', 'credit_note', 'purchase_invoice', 'supplier_credit_note', 'receipt', 'payment', 'purchase_order',
|
||||
'asset_capitalization', 'asset_depreciation', 'asset_amortization', 'asset_disposal'];
|
||||
private array $journalTypes = ['invoice', 'credit_note', 'purchase_invoice', 'supplier_credit_note', 'receipt', 'payment', 'manual', 'purchase_order', 'reversal',
|
||||
'asset_capitalization', 'asset_depreciation', 'asset_amortization', 'asset_disposal'];
|
||||
|
||||
public function __construct(PDO $pdo, int $company_id)
|
||||
{
|
||||
@@ -25,6 +29,11 @@ class GlQueryManager
|
||||
throw new Exception('Invalid doc_type.');
|
||||
}
|
||||
|
||||
// Asset Management sources have no formula; accounts come from the asset category.
|
||||
if (AssetPosting::isAssetSource($doc_type)) {
|
||||
return (new AssetPosting($this->pdo, $this->companyId))->getPostableDocuments($doc_type, $date_from, $date_to);
|
||||
}
|
||||
|
||||
if (in_array($doc_type, $this->invoiceTypes, true)) {
|
||||
$rows = $this->getInvoicePostableDocuments($doc_type, $date_from, $date_to, $formula_id);
|
||||
} elseif ($doc_type === 'receipt') {
|
||||
@@ -82,6 +91,10 @@ class GlQueryManager
|
||||
WHEN 'payment' THEN p.payment_number
|
||||
WHEN 'manual' THEN IF(g.reference != '', g.reference, CONCAT('MJE-', g.id))
|
||||
WHEN 'purchase_order' THEN po.po_number
|
||||
WHEN 'asset_capitalization' THEN g.reference
|
||||
WHEN 'asset_depreciation' THEN g.reference
|
||||
WHEN 'asset_amortization' THEN g.reference
|
||||
WHEN 'asset_disposal' THEN g.reference
|
||||
ELSE i.invoice_number
|
||||
END AS doc_number,
|
||||
COALESCE(
|
||||
@@ -90,6 +103,10 @@ class GlQueryManager
|
||||
WHEN 'payment' THEN cp.contact_name
|
||||
WHEN 'manual' THEN g.description
|
||||
WHEN 'purchase_order' THEN cpo.contact_name
|
||||
WHEN 'asset_capitalization' THEN g.description
|
||||
WHEN 'asset_depreciation' THEN g.description
|
||||
WHEN 'asset_amortization' THEN g.description
|
||||
WHEN 'asset_disposal' THEN g.description
|
||||
ELSE ci.contact_name
|
||||
END, ''
|
||||
) AS contact_name,
|
||||
@@ -101,7 +118,8 @@ class GlQueryManager
|
||||
LEFT JOIN td_gl_item gi
|
||||
ON gi.company_id = g.company_id AND gi.gl_id = g.id
|
||||
LEFT JOIN td_invoice i
|
||||
ON g.source_type NOT IN ('receipt','payment','manual','purchase_order')
|
||||
ON g.source_type NOT IN ('receipt','payment','manual','purchase_order',
|
||||
'asset_capitalization','asset_depreciation','asset_amortization','asset_disposal')
|
||||
AND i.company_id = g.company_id AND i.id = g.source_id
|
||||
LEFT JOIN md_contact ci
|
||||
ON ci.company_id = g.company_id AND ci.id = i.contact_id
|
||||
|
||||
Reference in New Issue
Block a user