diff --git a/app/Filament/Admin/Resources/CustomerReportResource.php b/app/Filament/Admin/Resources/CustomerReportResource.php index 76e340c..e3f7a6b 100644 --- a/app/Filament/Admin/Resources/CustomerReportResource.php +++ b/app/Filament/Admin/Resources/CustomerReportResource.php @@ -11,7 +11,6 @@ use Filament\Tables\Columns\Summarizers\Summarizer; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Query\Builder; class CustomerReportResource extends Resource { @@ -45,14 +44,13 @@ public static function table(Table $table): Table Tables\Columns\TextColumn::make('subtotal') ->money() - ->summarize(Summarizer::make()->using(function (Builder $query, Table $table) { - return '$'. - number_format( - round(Invoice::whereBetween('date', [ - $table->getFilter('created_at')->getState()['created_at'] ?? '1900-01-01', - $table->getFilter('created_until')->getState()['created_until'] ?? '2100-01-01', - ])->sum('subtotal'), 2), 2, '.', ','); + ->summarize(Summarizer::make()->using(function ($query, Table $table) { + $createdAt = $table->getfilter('created_at')->getstate()['created_at'] ?? '1900-01-01'; + $createdUntil = $table->getfilter('created_until')->getstate()['created_until'] ?? '2100-01-01'; + $invoiceSum = invoice::wherebetween('date', [$createdAt, $createdUntil])->sum('subtotal'); + + return '$'.number_format(round($invoiceSum, 2), 2, '.', ','); })) ->alignRight() ->getStateUsing(function (Table $table, Model $record) { @@ -77,23 +75,23 @@ public static function table(Table $table): Table ->label('PST') ->money() ->alignRight() - ->getStateUsing(function (Table $table, Model $record) { - return $record->getPstAttribute( - $table->getFilter('created_at')->getState()['created_at'], - $table->getFilter('created_until')->getState()['created_until'] - ); + ->getStateUsing(function (Table $table, Customer $record) { + // return $record->invoices()->; + // return $record->getPstAttribute( + // $table->getFilter('created_at')->getState()['created_at'], + // $table->getFilter('created_until')->getState()['created_until'] + // ); }), Tables\Columns\TextColumn::make('total') ->money() - ->summarize(Summarizer::make()->using(function (Builder $query, Table $table) { - return '$'. - number_format( - round(Invoice::whereBetween('date', [ - $table->getFilter('created_at')->getState()['created_at'] ?? '1900-01-01', - $table->getFilter('created_until')->getState()['created_until'] ?? '2100-01-01', - ])->sum('total'), 2), 2, '.', ','); + ->summarize(summarizer::make()->using(function ($query, table $table) { + $createdAt = $table->getfilter('created_at')->getstate()['created_at'] ?? '1900-01-01'; + $createdUntil = $table->getfilter('created_until')->getstate()['created_until'] ?? '2100-01-01'; + $invoiceSum = invoice::wherebetween('date', [$createdAt, $createdUntil])->sum('total'); + + return '$'.number_format(round($invoiceSum, 2), 2, '.', ','); })) ->weight('bold') ->alignRight() diff --git a/app/Filament/Admin/Resources/InvoiceResource.php b/app/Filament/Admin/Resources/InvoiceResource.php index 1d14fab..28ff208 100644 --- a/app/Filament/Admin/Resources/InvoiceResource.php +++ b/app/Filament/Admin/Resources/InvoiceResource.php @@ -70,8 +70,9 @@ public static function form(Form $form): Form Grid::make(1) ->schema([ - ToggleButtons::make('gst') - ->boolean() + ToggleButtons::make('has_gst') + ->label('GST') + ->boolean('On', 'Off') ->default(true) ->inline() ->colors([ @@ -79,8 +80,9 @@ public static function form(Form $form): Form 'false' => 'info', ]), - ToggleButtons::make('pst') - ->boolean() + ToggleButtons::make('has_pst') + ->label('PST') + ->boolean('On', 'Off') ->default(false) ->inline() ->colors([ @@ -94,13 +96,21 @@ public static function form(Form $form): Form Section::make() ->schema([ + Placeholder::make('Id') + ->label('ID') + ->content(fn (Invoice $record): ?string => $record->internal_id), + + Placeholder::make('Tax Rates') + ->content(fn (Invoice $record): ?string => $record->gst_rate.'% GST, '.$record->pst_rate.'% PST'), + Placeholder::make('created_at') - ->label('Created at') + ->label('Created') ->content(fn (Invoice $record): ?string => $record->created_at?->diffForHumans()), Placeholder::make('updated_at') - ->label('Last modified at') + ->label('Last modified') ->content(fn (Invoice $record): ?string => $record->updated_at?->diffForHumans()), + ]) ->columnSpan(1) ->hidden(fn (?Invoice $record) => $record === null), @@ -143,17 +153,25 @@ public static function table(Table $table): Table ->money() ->alignRight(), - TextColumn::make('gst_amount') + TextColumn::make('has_gst') ->label('GST') - ->formatStateUsing(function ($state) { - return $state == 0 ? '-' : '$'.number_format($state, 2); + ->formatStateUsing(function (Invoice $record) { + if ($record->has_gst) { + return '$'.$record->gst_amount; + } + + return '-'; }) ->alignRight(), - TextColumn::make('pst_amount') + TextColumn::make('has_pst') ->label('PST') - ->formatStateUsing(function ($state) { - return $state == 0 ? '-' : '$'.number_format($state, 2); + ->formatStateUsing(function (Invoice $record) { + if ($record->has_pst) { + return '$'.$record->pst_amount; + } + + return '-'; }) ->alignRight(), TextColumn::make('total') diff --git a/app/Filament/Admin/Resources/OrderResource/Pages/EditOrder.php b/app/Filament/Admin/Resources/OrderResource/Pages/EditOrder.php index 3f892a0..569e5e0 100644 --- a/app/Filament/Admin/Resources/OrderResource/Pages/EditOrder.php +++ b/app/Filament/Admin/Resources/OrderResource/Pages/EditOrder.php @@ -3,6 +3,7 @@ namespace App\Filament\Admin\Resources\OrderResource\Pages; use App\Enums\OrderAttributes; +use App\Enums\OrderStatus; use App\Filament\Admin\Resources\OrderResource; use App\Models\Order; use App\Models\OrderProduct; @@ -148,7 +149,9 @@ protected function getHeaderActions(): array ->label('Save changes') ->action('save') ->icon('lucide-save'), + Actions\ReplicateAction::make() + ->label('Duplicate') ->icon('lucide-copy') ->color('info') ->mutateRecordDataUsing(function (array $data): array { @@ -157,12 +160,27 @@ protected function getHeaderActions(): array return $data; }) - ->beforeReplicaSaved(function (Model $replica): void {}) + ->beforeReplicaSaved(function (Order $replica): void { + $replica->customer_po = 'Repeat of '.$replica->customer_po; + $replica->status = OrderStatus::DRAFT; + $replica->printed = false; + $replica->pre_production = false; + $replica->order_date = today(); + $replica->due_date = today()->addDays(10); + $replica->save(); + }) ->successRedirectUrl(fn (Model $replica): string => OrderResource::getUrl('edit', [$replica])), + + // Action::make('invoice') + // ->visible(fn () => auth()->user()->is_admin) + // ->label('To Invoice') + // ->icon('lucide-receipt-text'), + // Action::make('print') ->icon('lucide-printer') ->url(fn (Order $record) => route('orders.pdf', $record)) ->openUrlInNewTab(), + Actions\DeleteAction::make() ->icon('lucide-trash-2'), ]; diff --git a/app/Filament/Admin/Resources/TaxRateResource.php b/app/Filament/Admin/Resources/TaxRateResource.php new file mode 100644 index 0000000..b5f3468 --- /dev/null +++ b/app/Filament/Admin/Resources/TaxRateResource.php @@ -0,0 +1,100 @@ +<?php + +namespace App\Filament\Admin\Resources; + +use App\Filament\Admin\Resources\TaxRateResource\Pages; +use App\Models\TaxRate; +use Filament\Forms\Components\Placeholder; +use Filament\Forms\Components\Section; +use Filament\Forms\Components\TextInput; +use Filament\Forms\Form; +use Filament\Resources\Resource; +use Filament\Support\Enums\FontWeight; +use Filament\Tables; +use Filament\Tables\Columns\TextColumn; +use Filament\Tables\Table; + +class TaxRateResource extends Resource +{ + protected static ?string $model = TaxRate::class; + + protected static ?string $navigationIcon = 'lucide-circle-dollar-sign'; + + protected static ?string $navigationGroup = 'Settings'; + + protected static ?int $navigationSort = 11; + + public static function form(Form $form): Form + { + return $form + ->schema([ + Section::make([ + TextInput::make('name') + ->disabledOn('edit'), + TextInput::make('value') + ->label('Value in percentage') + ->numeric() + ->prefix('%'), + ]) + ->columns(1) + ->columnSpan(2), + + Section::make() + ->schema([ + Placeholder::make('created_at') + ->label('Created') + ->content(fn (TaxRate $record): ?string => $record->created_at?->diffForHumans()), + + Placeholder::make('updated_at') + ->label('Last modified') + ->content(fn (TaxRate $record): ?string => $record->updated_at?->diffForHumans()), + ]) + ->columnSpan(1) + ->hidden(fn (?TaxRate $record) => $record === null), + ])->columns(3); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('name') + ->weight(FontWeight::Bold), + TextColumn::make('value') + ->extraHeaderAttributes(['class' => 'w-full']) + ->suffix(' %'), + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + ]), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function canAccess(): bool + { + return auth()->user()->is_admin; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListTaxRates::route('/'), + 'create' => Pages\CreateTaxRate::route('/create'), + 'edit' => Pages\EditTaxRate::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Admin/Resources/TaxRateResource/Pages/CreateTaxRate.php b/app/Filament/Admin/Resources/TaxRateResource/Pages/CreateTaxRate.php new file mode 100644 index 0000000..ac778a6 --- /dev/null +++ b/app/Filament/Admin/Resources/TaxRateResource/Pages/CreateTaxRate.php @@ -0,0 +1,11 @@ +<?php + +namespace App\Filament\Admin\Resources\TaxRateResource\Pages; + +use App\Filament\Admin\Resources\TaxRateResource; +use Filament\Resources\Pages\CreateRecord; + +class CreateTaxRate extends CreateRecord +{ + protected static string $resource = TaxRateResource::class; +} diff --git a/app/Filament/Admin/Resources/TaxRateResource/Pages/EditTaxRate.php b/app/Filament/Admin/Resources/TaxRateResource/Pages/EditTaxRate.php new file mode 100644 index 0000000..6d9f375 --- /dev/null +++ b/app/Filament/Admin/Resources/TaxRateResource/Pages/EditTaxRate.php @@ -0,0 +1,19 @@ +<?php + +namespace App\Filament\Admin\Resources\TaxRateResource\Pages; + +use App\Filament\Admin\Resources\TaxRateResource; +use Filament\Actions; +use Filament\Resources\Pages\EditRecord; + +class EditTaxRate extends EditRecord +{ + protected static string $resource = TaxRateResource::class; + + protected function getHeaderActions(): array + { + return [ + Actions\DeleteAction::make(), + ]; + } +} diff --git a/app/Filament/Admin/Resources/TaxRateResource/Pages/ListTaxRates.php b/app/Filament/Admin/Resources/TaxRateResource/Pages/ListTaxRates.php new file mode 100644 index 0000000..e8b1bc2 --- /dev/null +++ b/app/Filament/Admin/Resources/TaxRateResource/Pages/ListTaxRates.php @@ -0,0 +1,19 @@ +<?php + +namespace App\Filament\Admin\Resources\TaxRateResource\Pages; + +use App\Filament\Admin\Resources\TaxRateResource; +use Filament\Actions; +use Filament\Resources\Pages\ListRecords; + +class ListTaxRates extends ListRecords +{ + protected static string $resource = TaxRateResource::class; + + protected function getHeaderActions(): array + { + return [ + Actions\CreateAction::make(), + ]; + } +} diff --git a/app/Filament/Admin/Resources/TaxResource.php b/app/Filament/Admin/Resources/TaxResource.php deleted file mode 100644 index 7f6eed7..0000000 --- a/app/Filament/Admin/Resources/TaxResource.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php - -namespace App\Filament\Admin\Resources; - -use App\Filament\Admin\Resources\TaxResource\Pages; -use App\Models\Tax; -use Filament\Forms\Form; -use Filament\Resources\Resource; -use Filament\Tables; -use Filament\Tables\Table; - -class TaxResource extends Resource -{ - // protected static ?string $model = Tax::class; - - protected static ?string $navigationLabel = 'Service Tax'; - - protected static ?string $navigationIcon = 'lucide-circle-dollar-sign'; - - protected static ?string $navigationGroup = 'Settings'; - - protected static ?int $navigationSort = 11; - - public static function form(Form $form): Form - { - return $form - ->schema([ - // - ]); - } - - public static function table(Table $table): Table - { - return $table - ->columns([ - // - ]) - ->filters([ - // - ]) - ->actions([ - Tables\Actions\EditAction::make(), - ]) - ->bulkActions([ - Tables\Actions\BulkActionGroup::make([ - Tables\Actions\DeleteBulkAction::make(), - ]), - ]); - } - - public static function canAccess(): bool - { - return auth()->user()->is_admin; - } - - public static function getRelations(): array - { - return [ - // - ]; - } - - public static function getPages(): array - { - return [ - 'index' => Pages\ListTaxes::route('/'), - 'create' => Pages\CreateTax::route('/create'), - 'edit' => Pages\EditTax::route('/{record}/edit'), - ]; - } -} diff --git a/app/Filament/Admin/Resources/TaxResource/Pages/CreateTax.php b/app/Filament/Admin/Resources/TaxResource/Pages/CreateTax.php deleted file mode 100644 index c9338fe..0000000 --- a/app/Filament/Admin/Resources/TaxResource/Pages/CreateTax.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -namespace App\Filament\Admin\Resources\TaxResource\Pages; - -use App\Filament\Admin\Resources\TaxResource; -use Filament\Resources\Pages\CreateRecord; - -class CreateTax extends CreateRecord -{ - protected static string $resource = TaxResource::class; -} diff --git a/app/Filament/Admin/Resources/TaxResource/Pages/EditTax.php b/app/Filament/Admin/Resources/TaxResource/Pages/EditTax.php deleted file mode 100644 index e8b4e3a..0000000 --- a/app/Filament/Admin/Resources/TaxResource/Pages/EditTax.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -namespace App\Filament\Admin\Resources\TaxResource\Pages; - -use App\Filament\Admin\Resources\TaxResource; -use Filament\Actions; -use Filament\Resources\Pages\EditRecord; - -class EditTax extends EditRecord -{ - protected static string $resource = TaxResource::class; - - protected function getHeaderActions(): array - { - return [ - Actions\DeleteAction::make(), - ]; - } -} diff --git a/app/Filament/Admin/Resources/TaxResource/Pages/ListTaxes.php b/app/Filament/Admin/Resources/TaxResource/Pages/ListTaxes.php deleted file mode 100644 index 1456455..0000000 --- a/app/Filament/Admin/Resources/TaxResource/Pages/ListTaxes.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -namespace App\Filament\Admin\Resources\TaxResource\Pages; - -use App\Filament\Admin\Resources\TaxResource; -use Filament\Actions; -use Filament\Resources\Pages\ListRecords; - -class ListTaxes extends ListRecords -{ - protected static string $resource = TaxResource::class; - - protected function getHeaderActions(): array - { - return [ - Actions\CreateAction::make(), - ]; - } -} diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index d54c897..e5c88d2 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -16,27 +16,25 @@ class Invoice extends Model use HasFactory, SoftDeletes; protected $fillable = [ - 'customer_id', 'internal_id', + 'customer_id', 'status', 'subtotal', 'total', - 'gst', - 'pst', - 'date', - ]; - - protected $appends = [ - 'gst_amount', + 'pst_rate', + 'gst_rate', 'pst_amount', + 'gst_amount', + 'has_pst', + 'has_gst', + 'date', + 'due_date', ]; protected $casts = [ 'date' => 'datetime', 'total' => 'decimal:2', 'subtotal' => 'decimal:2', - 'gst' => 'bool', - 'pst' => 'bool', 'status' => InvoiceStatus::class, ]; @@ -46,29 +44,46 @@ public static function boot(): void static::created(function ($model) { $model->attributes['internal_id'] = 'TN4'.str_pad($model->id, 4, '0', STR_PAD_LEFT); + $model->attributes['pst_rate'] = TaxRate::where('name', 'PST')->value('value'); + $model->attributes['gst_rate'] = TaxRate::where('name', 'GST')->value('value'); $model->save(); }); } - public function setPstAttribute(int $value): void + public function setHasPstAttribute(bool $value): void { - $this->attributes['pst'] = $value; + $this->attributes['has_pst'] = $value; $this->save(); $this->calculateTotals(); } - public function setGstAttribute(int $value): void + public function setHasGstAttribute(bool $value): void { - $this->attributes['gst'] = $value; + $this->attributes['has_gst'] = $value; $this->save(); $this->calculateTotals(); - - // dd('value: '.$value.', model: '.$this->gst); } - public function setStatus(InvoiceStatus $status) + public function calculateTotals(): void + { + $subtotal = 0; + + // $gst_amount = ($this->gst_rate / 100) * $this->gst ?? 0; + // $pst_amount = ($this->pst_rate / 100) * $this->pst ?? 0; + + foreach ($this->orders as $order) { + $subtotal += $order->total_service_price; + } + + $this->subtotal = $subtotal; + // $this->total = $subtotal + $gst_amount + $pst_amount; + + $this->save(); + } + + public function setStatus(InvoiceStatus $status): void { if ($this->status !== $status) { $this->status = $status; @@ -76,37 +91,23 @@ public function setStatus(InvoiceStatus $status) } } - public function calculateTotals(): void - { - $subtotal = 0; - - foreach ($this->orders as $order) { - $subtotal += $order->total_service_price; - } - - $this->subtotal = $subtotal; - $this->total = $subtotal + $this->gst_amount + $this->pst_amount; - - $this->save(); - } - - public function getGstAmountAttribute(): float - { - if ($this->gst) { - return number_format($this->subtotal * 0.05, 2); - } - - return 0.00; - } - - public function getPstAmountAttribute(): float - { - if ($this->pst) { - return number_format($this->subtotal * 0.07, 2); - } - - return 0.00; - } + // public function getGstAmountAttribute(): float + // { + // if ($this->gst) { + // return round($this->subtotal * ($this->gst_rate / 100), 2); + // } + // + // return 0.00; + // } + // + // public function getPstAmountAttribute(): float + // { + // if ($this->pst) { + // return round($this->subtotal * ($this->pst_rate / 100), 2); + // } + // + // return 0.00; + // } public function orders(): HasMany { diff --git a/app/Models/TaxRate.php b/app/Models/TaxRate.php new file mode 100644 index 0000000..6a9a757 --- /dev/null +++ b/app/Models/TaxRate.php @@ -0,0 +1,14 @@ +<?php + +namespace App\Models; + +use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; + +class TaxRate extends Model +{ + /** @use HasFactory<\Database\Factories\TaxRateFactory> */ + use HasFactory; + + protected $fillable = ['name', 'value']; +} diff --git a/database/factories/InvoiceFactory.php b/database/factories/InvoiceFactory.php index 1c87eb8..827ac68 100644 --- a/database/factories/InvoiceFactory.php +++ b/database/factories/InvoiceFactory.php @@ -5,6 +5,7 @@ use App\Enums\InvoiceStatus; use App\Models\Customer; use App\Models\Invoice; +use App\Models\TaxRate; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Carbon; @@ -17,9 +18,11 @@ public function definition(): array $customer = Customer::all()->shuffle()->first(); return [ - 'created_at' => Carbon::now()->subDays(rand(1, 30)), - 'gst' => true, - 'pst' => $this->faker->boolean(40), + 'created_at' => Carbon::now()->subDays(rand(1, 30)), + 'pst_rate' => TaxRate::where('name', 'PST')->value('value'), + 'gst_rate' => TaxRate::where('name', 'GST')->value('value'), + // 'gst' => true, + // 'pst' => $this->faker->boolean(40), 'date' => Carbon::now()->subDays(rand(1, 60)), 'status' => $this->faker->randomElement(InvoiceStatus::cases())->value, 'customer_id' => $customer->id, diff --git a/database/factories/TaxRateFactory.php b/database/factories/TaxRateFactory.php new file mode 100644 index 0000000..1a697b0 --- /dev/null +++ b/database/factories/TaxRateFactory.php @@ -0,0 +1,23 @@ +<?php + +namespace Database\Factories; + +use Illuminate\Database\Eloquent\Factories\Factory; + +/** + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TaxRate> + */ +class TaxRateFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array<string, mixed> + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/000_create_users_table.php similarity index 100% rename from database/migrations/0001_01_01_000000_create_users_table.php rename to database/migrations/000_create_users_table.php diff --git a/database/migrations/0001_01_01_000001_create_cache_table.php b/database/migrations/001_create_cache_table.php similarity index 100% rename from database/migrations/0001_01_01_000001_create_cache_table.php rename to database/migrations/001_create_cache_table.php diff --git a/database/migrations/0001_01_01_000002_create_jobs_table.php b/database/migrations/002_create_jobs_table.php similarity index 100% rename from database/migrations/0001_01_01_000002_create_jobs_table.php rename to database/migrations/002_create_jobs_table.php diff --git a/database/migrations/003_create_tax_rates_table.php b/database/migrations/003_create_tax_rates_table.php new file mode 100644 index 0000000..1d422d8 --- /dev/null +++ b/database/migrations/003_create_tax_rates_table.php @@ -0,0 +1,29 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +return new class extends Migration +{ + /** + * Run the migrations. + */ + public function up(): void + { + Schema::create('tax_rates', function (Blueprint $table) { + $table->id(); + $table->string('name'); + $table->decimal('value', 8, 2); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('tax_rates'); + } +}; diff --git a/database/migrations/2024_09_03_204957_create_customers_table.php b/database/migrations/004_create_customers_table.php similarity index 100% rename from database/migrations/2024_09_03_204957_create_customers_table.php rename to database/migrations/004_create_customers_table.php diff --git a/database/migrations/2024_09_04_203012_create_contacts_table.php b/database/migrations/005_create_contacts_table.php similarity index 100% rename from database/migrations/2024_09_04_203012_create_contacts_table.php rename to database/migrations/005_create_contacts_table.php diff --git a/database/migrations/2024_09_06_213725_create_shipping_entries_table.php b/database/migrations/006_create_shipping_entries_table.php similarity index 100% rename from database/migrations/2024_09_06_213725_create_shipping_entries_table.php rename to database/migrations/006_create_shipping_entries_table.php diff --git a/database/migrations/2024_09_08_163053_create_invoices_table.php b/database/migrations/007_create_invoices_table.php similarity index 73% rename from database/migrations/2024_09_08_163053_create_invoices_table.php rename to database/migrations/007_create_invoices_table.php index 9e82534..3fce718 100644 --- a/database/migrations/2024_09_08_163053_create_invoices_table.php +++ b/database/migrations/007_create_invoices_table.php @@ -19,8 +19,14 @@ public function up(): void $table->decimal('subtotal', 8, 2)->default(0.00); $table->decimal('total', 8, 2)->default(0.00); - $table->boolean('gst')->default(false); - $table->boolean('pst')->default(false); + $table->decimal('pst_rate', 8, 2); + $table->decimal('gst_rate', 8, 2); + + $table->decimal('pst_amount', 8, 2)->nullable(); + $table->decimal('gst_amount', 8, 2)->nullable(); + + $table->boolean('has_pst')->default(false); + $table->boolean('has_gst')->default(true); $table->date('date')->default(today()); $table->date('due_date')->nullable(); diff --git a/database/migrations/2024_09_09_194631_create_orders_table.php b/database/migrations/008_create_orders_table.php similarity index 100% rename from database/migrations/2024_09_09_194631_create_orders_table.php rename to database/migrations/008_create_orders_table.php diff --git a/database/migrations/2024_09_09_215151_create_packing_slips_table.php b/database/migrations/009_create_packing_slips_table.php similarity index 100% rename from database/migrations/2024_09_09_215151_create_packing_slips_table.php rename to database/migrations/009_create_packing_slips_table.php diff --git a/database/migrations/2024_09_10_200000_create_service_types_table.php b/database/migrations/010_create_service_types_table.php similarity index 100% rename from database/migrations/2024_09_10_200000_create_service_types_table.php rename to database/migrations/010_create_service_types_table.php diff --git a/database/migrations/2024_09_10_224439_create_order_products_table.php b/database/migrations/011_create_order_products_table.php similarity index 100% rename from database/migrations/2024_09_10_224439_create_order_products_table.php rename to database/migrations/011_create_order_products_table.php diff --git a/database/migrations/2024_09_10_224947_create_product_services_table.php b/database/migrations/012_create_product_services_table.php similarity index 100% rename from database/migrations/2024_09_10_224947_create_product_services_table.php rename to database/migrations/012_create_product_services_table.php diff --git a/database/migrations/2024_09_10_225029_create_service_files_table.php b/database/migrations/013_create_service_files_table.php similarity index 100% rename from database/migrations/2024_09_10_225029_create_service_files_table.php rename to database/migrations/013_create_service_files_table.php diff --git a/database/migrations/2024_09_10_230904_create_product_sizes_table.php b/database/migrations/014_create_product_sizes_table.php similarity index 100% rename from database/migrations/2024_09_10_230904_create_product_sizes_table.php rename to database/migrations/014_create_product_sizes_table.php diff --git a/database/migrations/2024_10_21_145025_create_quotes_table.php b/database/migrations/015_create_quotes_table.php similarity index 100% rename from database/migrations/2024_10_21_145025_create_quotes_table.php rename to database/migrations/015_create_quotes_table.php diff --git a/database/migrations/2024_11_27_004920_create_invoice_reports_table.php b/database/migrations/016_create_invoice_reports_table.php similarity index 100% rename from database/migrations/2024_11_27_004920_create_invoice_reports_table.php rename to database/migrations/016_create_invoice_reports_table.php diff --git a/database/migrations/2024_12_01_233737_create_invoice_invoice_report_table.php b/database/migrations/017_create_invoice_invoice_report_table.php similarity index 100% rename from database/migrations/2024_12_01_233737_create_invoice_invoice_report_table.php rename to database/migrations/017_create_invoice_invoice_report_table.php diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 1462362..5756bbe 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -15,6 +15,7 @@ class DatabaseSeeder extends Seeder public function run(): void { $this->call([ + TaxRateSeeder::class, CustomerSeeder::class, ContactSeeder::class, ShippingEntrySeeder::class, diff --git a/database/seeders/TaxRateSeeder.php b/database/seeders/TaxRateSeeder.php new file mode 100644 index 0000000..639cd03 --- /dev/null +++ b/database/seeders/TaxRateSeeder.php @@ -0,0 +1,18 @@ +<?php + +namespace Database\Seeders; + +use App\Models\TaxRate; +use Illuminate\Database\Seeder; + +class TaxRateSeeder extends Seeder +{ + /** + * Run the database seeds. + */ + public function run(): void + { + TaxRate::create(['name' => 'GST', 'value' => 5.00]); + TaxRate::create(['name' => 'PST', 'value' => 7.00]); + } +}