Pub 946 Compliance
This commit is contained in:
@@ -29,6 +29,7 @@ const assetColumns = [
|
||||
'condition',
|
||||
'new_or_used',
|
||||
'listed_property',
|
||||
'passenger_auto',
|
||||
'business_use_percent',
|
||||
'investment_use_percent',
|
||||
'disposal_date',
|
||||
@@ -62,6 +63,7 @@ function assetFromRow(row) {
|
||||
return {
|
||||
...row,
|
||||
listed_property: Boolean(row.listed_property),
|
||||
passenger_auto: Boolean(row.passenger_auto),
|
||||
custom_fields: parseJson(row.custom_fields, {}),
|
||||
books: row.books ? parseJson(row.books, []) : undefined
|
||||
};
|
||||
@@ -213,6 +215,7 @@ function normalizeAssetInput(body) {
|
||||
input.investment_use_percent = Number(input.investment_use_percent || 0);
|
||||
input.custom_fields = json(input.custom_fields || {});
|
||||
input.listed_property = input.listed_property ? 1 : 0;
|
||||
input.passenger_auto = input.passenger_auto ? 1 : 0;
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -267,6 +270,7 @@ function listAssets(query = {}) {
|
||||
}
|
||||
|
||||
function createAsset(body, userId, companyId) {
|
||||
require('./midQuarter').clearCache(); // asset set changed → recompute the mid-quarter determination
|
||||
const created = now();
|
||||
const input = normalizeAssetInput(body);
|
||||
if (companyId) input.entity_id = companyId; // new assets belong to the active company
|
||||
@@ -289,6 +293,7 @@ function createAsset(body, userId, companyId) {
|
||||
}
|
||||
|
||||
function updateAsset(id, body, userId, companyId) {
|
||||
require('./midQuarter').clearCache();
|
||||
const before = hydrateAsset(id);
|
||||
if (!before) return null;
|
||||
if (companyId && before.entity_id !== companyId) return null; // belongs to another company
|
||||
@@ -323,6 +328,7 @@ function updateAsset(id, body, userId, companyId) {
|
||||
}
|
||||
|
||||
function deleteAsset(id, userId, companyId) {
|
||||
require('./midQuarter').clearCache();
|
||||
const before = hydrateAsset(id);
|
||||
if (!before) return false;
|
||||
if (companyId && before.entity_id !== companyId) return false; // belongs to another company
|
||||
@@ -332,6 +338,7 @@ function deleteAsset(id, userId, companyId) {
|
||||
}
|
||||
|
||||
function massUpdateAssets(ids, changes, userId, companyId) {
|
||||
require('./midQuarter').clearCache();
|
||||
const allowed = ['status', 'location', 'department', 'group_name', 'in_service_date', 'useful_life_months', 'condition', 'disposal_date'];
|
||||
const columns = allowed.filter((column) => Object.prototype.hasOwnProperty.call(changes, column));
|
||||
// Restrict to assets in the active company so a forged id list can't touch another company's data.
|
||||
|
||||
Reference in New Issue
Block a user