Merge remote-tracking branch 'origin/master' into Development
This commit is contained in:
@@ -175,6 +175,29 @@ public function run(): void
|
||||
],
|
||||
'ui' => ['order' => 9],
|
||||
],
|
||||
[
|
||||
'key' => 'activities',
|
||||
'canonical_root' => 'activity',
|
||||
'label' => 'Activities',
|
||||
'fields' => ['note', 'due_date', 'amount', 'action_id', 'decision_id', 'contract_id', 'client_case_id', 'user_id'],
|
||||
'field_aliases' => [
|
||||
'opis' => 'note',
|
||||
'datum' => 'due_date',
|
||||
'rok' => 'due_date',
|
||||
'znesek' => 'amount',
|
||||
],
|
||||
'aliases' => ['activity', 'activities', 'opravilo', 'opravila'],
|
||||
'rules' => [
|
||||
['pattern' => '/^(aktivnost|activity|note|opis)\b/i', 'field' => 'note'],
|
||||
['pattern' => '/^(rok|due|datum|date)\b/i', 'field' => 'due_date'],
|
||||
['pattern' => '/^(znesek|amount|vrednost|value)\b/i', 'field' => 'amount'],
|
||||
['pattern' => '/^(akcija|action)\b/i', 'field' => 'action_id'],
|
||||
['pattern' => '/^(odlocitev|odločitev|decision)\b/i', 'field' => 'decision_id'],
|
||||
['pattern' => '/^(pogodba|contract)\b/i', 'field' => 'contract_id'],
|
||||
['pattern' => '/^(primer|case)\b/i', 'field' => 'client_case_id'],
|
||||
],
|
||||
'ui' => ['order' => 10],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($defs as $d) {
|
||||
|
||||
@@ -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