Skip to content

Commit

Permalink
Fix: Import of department kfs data was padding even non-existent acco…
Browse files Browse the repository at this point in the history
…unts and object codes to 0000
  • Loading branch information
coolsam726 committed Oct 12, 2023
1 parent f61d1a6 commit 1326d49
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/AccessPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public function register(Panel $panel): void
->discoverPages(in: __DIR__ . '/../Filament/Pages', for: 'Savannabits\\Saas\\Access\\Filament\\Pages')
->navigationGroups([
NavigationGroup::make(static::getNavGroupLabel())->collapsible()->collapsed(),
])->plugin(FilamentShieldPlugin::make());
])->plugin(FilamentShieldPlugin::make()
->resourceCheckboxListColumns(['sm' => 2,'lg' => 3,'xl' => 6]));
if ($this->isRegisterResources()) {
$panel->resources([
// UserResource::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public function importRecord(array $data)
if ($model) {
$model->update([
'chart_code' => Str::of($data['chart_code'])->toString(),
'object_code' => Str::of($data['object_code'])->padLeft(4,'0'),
'account_number' => Str::of($data['account_number'])->padLeft(7,'0'),
'object_code' => ($chartCode = $data['object_code']) ? Str::of($chartCode)->padLeft(4,'0'): $chartCode,
'account_number' => ($acNo = $data['account_number']) ? Str::of($acNo)->padLeft(7,'0') : $acNo,
]);
}
return $model;
Expand Down
4 changes: 2 additions & 2 deletions src/Helpers/Framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public function calculate(string $mathExpression, array $variables = []): mixed
return eval($math);
}

public function substitute(string $expression, array $substitutions = []): string
public function substitute(string $expression, array $substitutions = [], string $substitutionIdentifier = ':'): string
{
$keys = collect($substitutions)->keys()->map(fn ($key) => ":$key");
$keys = collect($substitutions)->keys()->map(fn ($key) => "{$substitutionIdentifier}{$key}");
$values = collect($substitutions)->values();

return Str::of($expression)->replace($keys->toArray(), $values->toArray())->toString();
Expand Down

0 comments on commit 1326d49

Please sign in to comment.