F4: keep function history in its temporal ledger
This commit is contained in:
@@ -8,8 +8,7 @@ import { DataSource, EntityManager } from 'typeorm';
|
||||
import { administrationAuditContext } from '../administration/common/administration-audit';
|
||||
import { AuditService } from '../audit/audit.service';
|
||||
import type { AuthPrincipal, RequestWithContext } from '../common/http/request-context';
|
||||
import { AuditAction, AssetVersionChangeType } from '../database/entities';
|
||||
import { AssetHistoryService } from './asset-history.service';
|
||||
import { AuditAction } from '../database/entities';
|
||||
import type {
|
||||
ChangeInventoryFunctionDto,
|
||||
CreateInventoryFunctionDto,
|
||||
@@ -65,7 +64,6 @@ export class InventoryFunctionService {
|
||||
constructor(
|
||||
private readonly dataSource: DataSource,
|
||||
private readonly audit: AuditService,
|
||||
private readonly history: AssetHistoryService,
|
||||
) {}
|
||||
|
||||
async list(includeInactive = false): Promise<{ data: InventoryFunctionRow[] }> {
|
||||
@@ -207,13 +205,6 @@ export class InventoryFunctionService {
|
||||
await manager.query(`
|
||||
UPDATE assets SET updated_by=$2,updated_at=CURRENT_TIMESTAMP WHERE id=$1
|
||||
`, [assetId, principal.userId]);
|
||||
const versionNumber = await this.history.capture(
|
||||
manager,
|
||||
assetId,
|
||||
AssetVersionChangeType.FUNCTION_CHANGED,
|
||||
principal,
|
||||
request,
|
||||
);
|
||||
const after = await this.getForAssetWithManager(manager, assetId);
|
||||
await this.audit.record({
|
||||
...administrationAuditContext(principal, request),
|
||||
@@ -236,8 +227,8 @@ export class InventoryFunctionService {
|
||||
metadata: {
|
||||
inventoryCode: asset.code,
|
||||
inventoryName: asset.name,
|
||||
versionNumber,
|
||||
temporal: true,
|
||||
historySource: 'inventory_function_assignments',
|
||||
},
|
||||
}, manager);
|
||||
return after;
|
||||
|
||||
Reference in New Issue
Block a user