Skip to content

[Core]: Finish create import for Excel #80

Description

@nielsdrost7

SMART Plan — [Core] Excel file support for bulk imports

Part of the import/export epic: #85. See also: #139 (import catalogs/pricelists), #140 (import products from CSV/Excel), #141 (import clients).

Specific

Ensure that the Filament ImportAction used across modules (Products, Clients, etc.) accepts .xlsx files in addition to CSV, using Filament's built-in Excel support via maatwebsite/laravel-excel. An Excel file with the same column structure as the CSV template should import identically.

Measurable

  • The ImportAction on ListProducts, ListRelations, etc. accepts .xlsx MIME types.
  • An Excel file with 100 valid rows inserts exactly 100 records.
  • Invalid rows report the same validation errors as their CSV counterparts.

Achievable

  1. Add maatwebsite/laravel-excel as a Composer dependency if not already present.
  2. In each module's Importer class, specify accepted file types: ->acceptedFileTypes(['text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']).
  3. Confirm that Filament's ImportAction row processing works identically for both file types.
  4. Add a PHPUnit test that uploads a .xlsx file and asserts the import count.

Relevant

Many companies manage their data in Excel rather than CSV. Requiring a CSV conversion before import adds friction during onboarding and data migration.

Time-bound

Sprint 6.


Arrange · Act · Assert

// Modules/Products/Tests/Feature/ProductsTest.php

#[Test]
public function it_imports_products_from_an_excel_file(): void
{
    /* Arrange */
    // Create a minimal .xlsx file with a header row and 2 data rows
    $file = UploadedFile::fake()->create('products.xlsx', 10, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');

    /* Act */
    $component = Livewire::actingAs($this->user)
        ->test(ListProducts::class, ['tenant' => Str::lower($this->company->search_code)])
        ->callAction('import', ['file' => $file]);

    /* Assert */
    $component->assertSuccessful();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    refinedRefined with SMART plan / test suggestions

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions