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.
29 lines
908 B
PHP
29 lines
908 B
PHP
<?php
|
|
session_start();
|
|
require_once '../../../assets/utils/db_auth.php';
|
|
require_app_access('asset');
|
|
require_once '../../../assets/utils/classes_as/AssetManager.php';
|
|
|
|
try {
|
|
$assets = new AssetManager($pdo2, $company_id);
|
|
|
|
if (($data['action'] ?? '') === 'line') {
|
|
$answer['output'] = $assets->getInvoiceLine((int)($data['invoice_id'] ?? 0), (int)($data['item_id'] ?? 0));
|
|
} else {
|
|
$answer['output'] = $assets->getCapitalizableLines(
|
|
(string)($data['date_from'] ?? ''),
|
|
(string)($data['date_to'] ?? '')
|
|
);
|
|
}
|
|
$answer['success'] = 1;
|
|
} catch (PDOException $e) {
|
|
error_log('[asset invoice lines] ' . $e->getMessage());
|
|
$answer['message'] = 'Database error, please try again.';
|
|
http_response_code(500);
|
|
} catch (Exception $e) {
|
|
$answer['message'] = $e->getMessage();
|
|
http_response_code(400);
|
|
}
|
|
|
|
exit(json_encode($answer));
|