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:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user