# VAT Settings + RFQ Per-Item Vatable Checkbox — Implementation Plan > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** Add a global VAT rate setting and per-item vatable checkboxes on the supplier RFQ portal, with live VAT breakdown in totals. **Architecture:** Global VAT rate stored in existing `settings` key/value table. Per-item `is_vatable` flag added to `supplier_quote_items`. RFQ portal view updated with checkbox column and three-row footer (subtotal / VAT / grand total). New `VatSettingController` + `settings/vat` page added under the Admin-only System sidebar section. **Tech Stack:** Laravel 12, PHP 8.2, SQLite, Blade, Alpine-free vanilla JS, Tailwind (inline styles per project convention) --- ### Task 1: Migration — add `is_vatable` to `supplier_quote_items` **Files:** - Modify: `database/migrations/2026_06_01_090734_add_is_vatable_to_supplier_quote_items.php` - Modify: `app/Models/SupplierQuoteItem.php` - [ ] **Step 1: Write the migration** Replace the generated migration body with: ```php boolean('is_vatable')->default(false)->after('total_price'); }); } public function down(): void { Schema::table('supplier_quote_items', function (Blueprint $table) { $table->dropColumn('is_vatable'); }); } }; ``` - [ ] **Step 2: Run migration** ```bash php artisan migrate ``` Expected: `Migrating: 2026_06_01_090734_add_is_vatable_to_supplier_quote_items` then `Migrated`. - [ ] **Step 3: Update SupplierQuoteItem model** In `app/Models/SupplierQuoteItem.php`, update `$fillable`: ```php protected $fillable = [ 'supplier_quote_id', 'description', 'unit', 'quantity', 'unit_price', 'total_price', 'is_vatable', ]; protected $casts = [ 'is_vatable' => 'boolean', ]; ``` - [ ] **Step 4: Commit** ```bash git add database/migrations/2026_06_01_090734_add_is_vatable_to_supplier_quote_items.php app/Models/SupplierQuoteItem.php git commit -m "feat: add is_vatable column to supplier_quote_items" ``` --- ### Task 2: VatSettingController + route + view **Files:** - Create: `app/Http/Controllers/Settings/VatSettingController.php` - Create: `resources/views/settings/vat.blade.php` - Modify: `routes/web.php` - [ ] **Step 1: Create VatSettingController** Create `app/Http/Controllers/Settings/VatSettingController.php`: ```php validate([ 'vat_rate' => ['required', 'numeric', 'min:0', 'max:100'], ]); Setting::set('vat_rate', (string) $validated['vat_rate']); return response()->json(['message' => 'VAT rate saved.', 'vat_rate' => $validated['vat_rate']]); } } ``` - [ ] **Step 2: Add routes** In `routes/web.php`, after the integrations routes (around line 148), add: ```php // VAT settings Route::get('settings/vat', [VatSettingController::class, 'index'])->name('settings.vat'); Route::post('settings/vat', [VatSettingController::class, 'update'])->name('settings.vat.update'); ``` Also add the import at the top of the file with the other Settings controllers: ```php use App\Http\Controllers\Settings\VatSettingController; ``` - [ ] **Step 3: Create the VAT settings view** Create `resources/views/settings/vat.blade.php`: ```blade @extends('layouts.app') @section('title', 'Settings — VAT') @section('content')

VAT Settings

Set the global VAT rate applied to vatable items on supplier quotes.

VAT Configuration
%

Enter 0 to disable VAT. Suppliers will see the VAT checkbox on their quote form when this is greater than 0.

@endsection ``` - [ ] **Step 4: Commit** ```bash git add app/Http/Controllers/Settings/VatSettingController.php resources/views/settings/vat.blade.php routes/web.php git commit -m "feat: add VAT settings page and controller" ``` --- ### Task 3: Add VAT link to sidebar **Files:** - Modify: `resources/views/layouts/app.blade.php` - [ ] **Step 1: Add sidebar link** In `resources/views/layouts/app.blade.php`, after the Integrations `` tag (around line 198, just before `@endrole`), add: ```blade VAT Settings ``` - [ ] **Step 2: Commit** ```bash git add resources/views/layouts/app.blade.php git commit -m "feat: add VAT Settings link to sidebar" ``` --- ### Task 4: Update RfqPortalController — load VAT rate and store is_vatable **Files:** - Modify: `app/Http/Controllers/Purchase/RfqPortalController.php` - [ ] **Step 1: Update show() to pass VAT rate** Add `use App\Models\Setting;` at the top of the file. Update the `show()` method — add before the `return view(...)` line: ```php $vatRate = (float) Setting::get('vat_rate', 0); ``` Update the return to: ```php return view('rfq.show', compact('invitation', 'purchaseRequest', 'items', 'confirmCode', 'vatRate')); ``` - [ ] **Step 2: Update submit() to store is_vatable and calculate VAT-inclusive total** Add `'items.*.is_vatable' => ['nullable', 'boolean']` to the validation rules array. Replace the items loop and total calculation: ```php $subtotal = 0; $vatAmount = 0; $vatRate = (float) Setting::get('vat_rate', 0); foreach ($purchaseItems as $i => $item) { $unitPrice = (float)($validated['items'][$i]['unit_price'] ?? 0); $qty = (float)$item->quantity_required; $totalPrice = round($unitPrice * $qty, 3); $isVatable = !empty($validated['items'][$i]['is_vatable']); $subtotal += $totalPrice; if ($isVatable && $vatRate > 0) { $vatAmount += round($totalPrice * $vatRate / 100, 3); } SupplierQuoteItem::create([ 'supplier_quote_id' => $quote->id, 'description' => $item->description, 'unit' => $item->unit ?? '', 'quantity' => $qty, 'unit_price' => $unitPrice, 'total_price' => $totalPrice, 'is_vatable' => $isVatable, ]); } $grand = round($subtotal + $vatAmount, 3); $quote->update(['total_amount' => $grand]); ``` - [ ] **Step 3: Commit** ```bash git add app/Http/Controllers/Purchase/RfqPortalController.php git commit -m "feat: load VAT rate and store is_vatable in RFQ portal" ``` --- ### Task 5: Update rfq/show.blade.php — checkbox column + VAT footer + JS **Files:** - Modify: `resources/views/rfq/show.blade.php` - [ ] **Step 1: Add VAT rate JS variable** At the start of the `