Add receipt logo upload and redesign thermal receipt header.
Deploy Ladill POS / deploy (push) Successful in 1m32s
Deploy Ladill POS / deploy (push) Successful in 1m32s
Per-location logo in settings with remove/replace support; receipt template reserves space at the top when a logo is set. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,7 +8,9 @@ use App\Models\PosProduct;
|
||||
use App\Models\PosSale;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PosHardwareTest extends TestCase
|
||||
@@ -135,4 +137,70 @@ class PosHardwareTest extends TestCase
|
||||
$sale = PosSale::where('owner_ref', $user->public_id)->firstOrFail();
|
||||
$response->assertRedirect(route('pos.sales.receipt', ['sale' => $sale, 'autoprint' => 1]));
|
||||
}
|
||||
|
||||
public function test_settings_accepts_receipt_logo_upload(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
|
||||
$user = $this->user();
|
||||
PosLocation::create([
|
||||
'owner_ref' => $user->public_id,
|
||||
'name' => 'Main register',
|
||||
'currency' => 'GHS',
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->put(route('pos.settings.update'), [
|
||||
'name' => 'Main register',
|
||||
'currency' => 'GHS',
|
||||
'service_style' => 'retail',
|
||||
'printer_paper_mm' => 80,
|
||||
'receipt_logo' => UploadedFile::fake()->image('logo.png', 120, 120),
|
||||
])
|
||||
->assertRedirect();
|
||||
|
||||
$location = PosLocation::where('owner_ref', $user->public_id)->firstOrFail();
|
||||
$this->assertNotNull($location->receipt_logo_path);
|
||||
Storage::disk('public')->assertExists($location->receipt_logo_path);
|
||||
}
|
||||
|
||||
public function test_receipt_page_shows_uploaded_logo(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
|
||||
$user = $this->user();
|
||||
$logoPath = 'pos/receipt-logos/'.$user->public_id.'/logo.png';
|
||||
Storage::disk('public')->put($logoPath, UploadedFile::fake()->image('logo.png', 120, 120)->getContent());
|
||||
|
||||
$location = PosLocation::create([
|
||||
'owner_ref' => $user->public_id,
|
||||
'name' => 'Main register',
|
||||
'currency' => 'GHS',
|
||||
'receipt_header' => 'Acme Shop',
|
||||
'receipt_logo_path' => $logoPath,
|
||||
'printer_paper_mm' => 80,
|
||||
]);
|
||||
$sale = PosSale::create([
|
||||
'owner_ref' => $user->public_id,
|
||||
'location_id' => $location->id,
|
||||
'reference' => 'POS-LOGO',
|
||||
'currency' => 'GHS',
|
||||
'status' => 'paid',
|
||||
'payment_method' => 'cash',
|
||||
'total_minor' => 1000,
|
||||
]);
|
||||
$sale->lines()->create([
|
||||
'name' => 'Tea',
|
||||
'unit_price_minor' => 1000,
|
||||
'quantity' => 1,
|
||||
'line_total_minor' => 1000,
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('pos.sales.receipt', $sale))
|
||||
->assertOk()
|
||||
->assertSee('brand-logo', false)
|
||||
->assertSee('Acme Shop')
|
||||
->assertSee('POS-LOGO');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user