diff --git a/app/ac_dashboard/index.php b/app/ac_dashboard/index.php
index 1822968..228eee5 100644
--- a/app/ac_dashboard/index.php
+++ b/app/ac_dashboard/index.php
@@ -199,7 +199,11 @@
supplier_credit_note: 'Supplier Credit Note',
receipt: 'Receipt',
payment: 'Payment',
- manual: 'Manual'
+ manual: 'Manual',
+ asset_capitalization: 'Asset Mgmt · Capitalization',
+ asset_depreciation: 'Asset Mgmt · Depreciation',
+ asset_amortization: 'Asset Mgmt · Amortization',
+ asset_disposal: 'Asset Mgmt · Disposal'
};
var source_badges = {
@@ -209,7 +213,11 @@
supplier_credit_note: 'bg-secondary-subtle text-secondary',
receipt: 'bg-info-subtle text-info',
payment: 'bg-danger-subtle text-danger',
- manual: 'bg-dark-subtle text-dark'
+ manual: 'bg-dark-subtle text-dark',
+ asset_capitalization: 'bg-success text-white',
+ asset_depreciation: 'bg-success text-white',
+ asset_amortization: 'bg-success text-white',
+ asset_disposal: 'bg-success text-white'
};
function fmt_num(n) {
diff --git a/app/accounting/api/engine/post_gl_entry.php b/app/accounting/api/engine/post_gl_entry.php
index aad8114..c1c5ddc 100644
--- a/app/accounting/api/engine/post_gl_entry.php
+++ b/app/accounting/api/engine/post_gl_entry.php
@@ -11,6 +11,7 @@ require_once '../../../assets/utils/classes_ac/posting/SupplierCreditNotePosting
require_once '../../../assets/utils/classes_ac/posting/ReceiptPosting.php';
require_once '../../../assets/utils/classes_ac/posting/PaymentPosting.php';
require_once '../../../assets/utils/classes_ac/posting/PurchasePosting.php';
+require_once '../../../assets/utils/classes_as/AssetPosting.php';
require_role($user_role, ['owner', 'admin']);
require_once '../../../assets/utils/notify_node.php';
@@ -29,19 +30,31 @@ $posting_map = [
'purchase_order' => PurchasePosting::class,
];
-if (!isset($posting_map[$doc_type]) || $id <= 0) {
+$is_asset_source = AssetPosting::isAssetSource($doc_type);
+
+if ((!isset($posting_map[$doc_type]) && !$is_asset_source) || $id <= 0) {
$answer['message'] = 'Invalid doc_type or id.';
exit(json_encode($answer));
}
try {
- $posting_class = $posting_map[$doc_type];
- $posting = new $posting_class($pdo2, $company_id);
- $built = $posting->build($id, $formula_id);
+ if ($is_asset_source) {
+ // Asset Management entries carry their own reference and "[Asset Mgmt]" description.
+ $built = (new AssetPosting($pdo2, $company_id))->build($doc_type, $id);
+ $meta = [
+ 'journal_date' => $built['doc_date'],
+ 'reference' => $built['reference'],
+ 'description' => $built['description'],
+ ];
+ } else {
+ $posting_class = $posting_map[$doc_type];
+ $posting = new $posting_class($pdo2, $company_id);
+ $built = $posting->build($id, $formula_id);
+ $meta = ['journal_date' => $built['doc_date'] ?? null];
+ }
$guard = new PostingWindowGuard($pdo1, $company_id);
$gl = new GlManager($pdo2, $company_id, $guard);
- $meta = ['journal_date' => $built['doc_date'] ?? null];
$pdo2->beginTransaction();
diff --git a/app/accounting/gl_entries.php b/app/accounting/gl_entries.php
index 9e7d7ca..38bbc1e 100644
--- a/app/accounting/gl_entries.php
+++ b/app/accounting/gl_entries.php
@@ -39,6 +39,22 @@
Payment
+
+
+ Asset Management
+
+
+ Capitalization
+
+
+ Depreciation
+
+
+ Amortization
+
+
+ Disposal
+
@@ -60,6 +76,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -76,9 +104,17 @@
'purchase_invoice': 'purchase_invoice',
'supplier_credit_note': 'supplier_credit_note',
'receipt': 'receipt',
- 'payment': 'payment'
+ 'payment': 'payment',
+ 'asset_capitalization': 'asset_capitalization',
+ 'asset_depreciation': 'asset_depreciation',
+ 'asset_amortization': 'asset_amortization',
+ 'asset_disposal': 'asset_disposal'
};
+ // Prepared in Asset Management: no GL formula, accounts come from the asset category.
+ var ASSET_TYPES = ['asset_capitalization', 'asset_depreciation', 'asset_amortization', 'asset_disposal'];
+ function is_asset_type(doc_type) { return ASSET_TYPES.indexOf(doc_type) !== -1; }
+
var _gl_loaded = {}; // doc_type → [ids] (flat, used by single-formula run)
var _gl_rows = {}; // doc_type → [rows]
var _gl_failed = {}; // doc_type → failed items from last run
@@ -91,11 +127,13 @@
if (_inited[doc_type]) return;
_inited[doc_type] = true;
- load_formula_options('gl-formula-' + doc_type, doc_type, null, function(formulas) {
- var $sel = $('#gl-formula-' + doc_type);
- $sel.prepend('');
- $sel.val('all');
- });
+ if (!is_asset_type(doc_type)) {
+ load_formula_options('gl-formula-' + doc_type, doc_type, null, function(formulas) {
+ var $sel = $('#gl-formula-' + doc_type);
+ $sel.prepend('');
+ $sel.val('all');
+ });
+ }
var today = new Date();
var firstDay = new Date(today.getFullYear(), today.getMonth(), 1);
@@ -117,7 +155,7 @@
// ── load documents ────────────────────────────────────────────────────────
function load_gl_tab(doc_type) {
- var formula_id = $('#gl-formula-' + doc_type).val();
+ var formula_id = is_asset_type(doc_type) ? '0' : $('#gl-formula-' + doc_type).val();
if (!formula_id) { bootbox.alert('Please select a GL formula first.'); return; }
if (formula_id === 'all') {
@@ -256,7 +294,9 @@
var status_badge = r.gl_status == 1
? 'Posted'
: 'Unposted';
- var mapping_badge = product_mapping_badge(r);
+ var mapping_badge = is_asset_type(doc_type)
+ ? 'Asset category'
+ : product_mapping_badge(r);
html +=
'' +
'| ' + escape_html(r.doc_number) + ' | ' +
@@ -302,11 +342,15 @@
purchase_invoice: 'Purchase Invoice',
supplier_credit_note: 'Supplier Credit Note',
receipt: 'Receipt',
- payment: 'Payment'
+ payment: 'Payment',
+ asset_capitalization: '[Asset Mgmt] Capitalization',
+ asset_depreciation: '[Asset Mgmt] Depreciation',
+ asset_amortization: '[Asset Mgmt] Amortization',
+ asset_disposal: '[Asset Mgmt] Disposal'
};
function run_gl_batch(doc_type) {
- var formula_id = $('#gl-formula-' + doc_type).val();
+ var formula_id = is_asset_type(doc_type) ? '0' : $('#gl-formula-' + doc_type).val();
if (formula_id === 'all') {
run_all_formula_batches(doc_type);
@@ -393,7 +437,7 @@
// ── core batch processor ──────────────────────────────────────────────────
function _start_gl_batch(doc_type, ids, onComplete, formula_id_override) {
- var formula_id = formula_id_override || $('#gl-formula-' + doc_type).val();
+ var formula_id = formula_id_override || (is_asset_type(doc_type) ? 0 : $('#gl-formula-' + doc_type).val());
var $msg = $('#gl-msg-' + doc_type);
set_btn_state('#gl-btn-load-' + doc_type, false);
@@ -516,10 +560,34 @@