changes to import added activity entity
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user