changes to import added activity entity

This commit is contained in:
Simon Pocrnjič
2025-12-16 19:35:51 +01:00
parent aa40ebed5c
commit a596177a68
9 changed files with 946 additions and 72 deletions
+37
View File
@@ -155,5 +155,42 @@ public function run(): void
'options' => $map['options'] ?? null,
]);
}
// Activities linked to contracts demo
$activities = ImportTemplate::query()->firstOrCreate([
'name' => 'Activities CSV (contract linked)',
], [
'uuid' => (string) Str::uuid(),
'description' => 'Activities import linked to existing contracts via reference.',
'source_type' => 'csv',
'default_record_type' => 'activity',
'sample_headers' => ['contract_reference', 'note', 'due_date', 'amount', 'action', 'decision', 'user_email'],
'is_active' => true,
'meta' => [
'delimiter' => ',',
'enclosure' => '"',
'escape' => '\\',
],
]);
$activityMappings = [
['source_column' => 'contract_reference', 'target_field' => 'contract.reference', 'position' => 1],
['source_column' => 'note', 'target_field' => 'activity.note', 'position' => 2],
['source_column' => 'due_date', 'target_field' => 'activity.due_date', 'position' => 3],
['source_column' => 'amount', 'target_field' => 'activity.amount', 'position' => 4],
['source_column' => 'action', 'target_field' => 'activity.action_id', 'position' => 5],
['source_column' => 'decision', 'target_field' => 'activity.decision_id', 'position' => 6],
];
foreach ($activityMappings as $map) {
ImportTemplateMapping::firstOrCreate([
'import_template_id' => $activities->id,
'source_column' => $map['source_column'],
], [
'target_field' => $map['target_field'],
'position' => $map['position'],
'options' => $map['options'] ?? null,
]);
}
}
}