Skip to content

Commit 2b7c948

Browse files
Merge pull request #33 from khalidmaquilang/dev
v1.1.0
2 parents f603288 + 1d01e52 commit 2b7c948

File tree

59 files changed

+1837
-250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1837
-250
lines changed

app/Enums/DiscountTypeEnum.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Enums;
4+
5+
use Filament\Support\Contracts\HasLabel;
6+
7+
enum DiscountTypeEnum: string implements HasLabel
8+
{
9+
case FIXED = 'fixed';
10+
case PERCENTAGE = 'percentage';
11+
12+
/**
13+
* @return string
14+
*/
15+
public function getLabel(): string
16+
{
17+
return match ($this) {
18+
self::FIXED => 'Fixed',
19+
self::PERCENTAGE => 'Percentage',
20+
};
21+
}
22+
23+
/**
24+
* @return array
25+
*/
26+
public static function toArray(): array
27+
{
28+
return array_column(self::cases(), 'value');
29+
}
30+
}

app/Enums/PurchaseOrderEnum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function getLabel(): string
3131
public function getColor(): string
3232
{
3333
return match ($this) {
34-
self::PENDING => 'primary',
34+
self::PENDING => 'info',
3535
self::RECEIVED => 'success',
3636
self::PARTIALLY_RECEIVED => 'warning',
3737
self::CANCELLED => 'danger',

app/Events/GoodsReceiptCreated.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace App\Events;
4+
5+
use Illuminate\Broadcasting\InteractsWithSockets;
6+
use Illuminate\Broadcasting\PrivateChannel;
7+
use Illuminate\Foundation\Events\Dispatchable;
8+
use Illuminate\Queue\SerializesModels;
9+
10+
class GoodsReceiptCreated
11+
{
12+
use Dispatchable, InteractsWithSockets, SerializesModels;
13+
14+
/**
15+
* Create a new event instance.
16+
*/
17+
public function __construct(
18+
public int $productId,
19+
public int $quantity,
20+
public float $unitCost,
21+
public int $userId,
22+
public ?string $supplierId = null,
23+
public string $referenceNumber = '',
24+
) {
25+
//
26+
}
27+
28+
/**
29+
* Get the channels the event should broadcast on.
30+
*
31+
* @return array<int, \Illuminate\Broadcasting\Channel>
32+
*/
33+
public function broadcastOn(): array
34+
{
35+
return [
36+
new PrivateChannel('channel-name'),
37+
];
38+
}
39+
}

app/Events/SaleCreated.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace App\Events;
4+
5+
use Illuminate\Broadcasting\InteractsWithSockets;
6+
use Illuminate\Broadcasting\PrivateChannel;
7+
use Illuminate\Foundation\Events\Dispatchable;
8+
use Illuminate\Queue\SerializesModels;
9+
10+
class SaleCreated
11+
{
12+
use Dispatchable, InteractsWithSockets, SerializesModels;
13+
14+
/**
15+
* Create a new event instance.
16+
*/
17+
public function __construct(
18+
public int $productId,
19+
public int $quantity,
20+
public float $unitCost,
21+
public int $userId,
22+
public ?string $customerId = null,
23+
public string $referenceNumber = '',
24+
) {
25+
//
26+
}
27+
28+
/**
29+
* Get the channels the event should broadcast on.
30+
*
31+
* @return array<int, \Illuminate\Broadcasting\Channel>
32+
*/
33+
public function broadcastOn(): array
34+
{
35+
return [
36+
new PrivateChannel('channel-name'),
37+
];
38+
}
39+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace App\Filament\Exports;
4+
5+
use App\Models\Customer;
6+
use Filament\Actions\Exports\ExportColumn;
7+
use Filament\Actions\Exports\Exporter;
8+
use Filament\Actions\Exports\Models\Export;
9+
10+
class CustomerExporter extends Exporter
11+
{
12+
use ReportExporterTrait;
13+
14+
protected string $filename = 'customers-report';
15+
16+
protected static ?string $model = Customer::class;
17+
18+
public static function getColumns(): array
19+
{
20+
return [
21+
ExportColumn::make('name'),
22+
ExportColumn::make('email'),
23+
ExportColumn::make('phone'),
24+
ExportColumn::make('address'),
25+
ExportColumn::make('status')
26+
->formatStateUsing(fn ($state) => $state->getLabel()),
27+
ExportColumn::make('gender'),
28+
ExportColumn::make('user.name'),
29+
ExportColumn::make('created_at'),
30+
ExportColumn::make('updated_at'),
31+
ExportColumn::make('deleted_at'),
32+
];
33+
}
34+
35+
public static function getCompletedNotificationBody(Export $export): string
36+
{
37+
$body = 'Your customer export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
38+
39+
if ($failedRowsCount = $export->getFailedRowsCount()) {
40+
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
41+
}
42+
43+
return $body;
44+
}
45+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Filament\Exports;
4+
5+
use App\Models\Inventory;
6+
use Filament\Actions\Exports\ExportColumn;
7+
use Filament\Actions\Exports\Exporter;
8+
use Filament\Actions\Exports\Models\Export;
9+
10+
class InventoryExporter extends Exporter
11+
{
12+
use ReportExporterTrait;
13+
14+
protected string $filename = 'inventories-report';
15+
16+
protected static ?string $model = Inventory::class;
17+
18+
public static function getColumns(): array
19+
{
20+
return [
21+
ExportColumn::make('product.name'),
22+
ExportColumn::make('quantity_on_hand'),
23+
ExportColumn::make('average_cost'),
24+
ExportColumn::make('user.name'),
25+
ExportColumn::make('created_at'),
26+
ExportColumn::make('updated_at'),
27+
];
28+
}
29+
30+
public static function getCompletedNotificationBody(Export $export): string
31+
{
32+
$body = 'Your inventory export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
33+
34+
if ($failedRowsCount = $export->getFailedRowsCount()) {
35+
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
36+
}
37+
38+
return $body;
39+
}
40+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace App\Filament\Exports;
4+
5+
use App\Models\Product;
6+
use Filament\Actions\Exports\ExportColumn;
7+
use Filament\Actions\Exports\Exporter;
8+
use Filament\Actions\Exports\Models\Export;
9+
10+
class ProductExporter extends Exporter
11+
{
12+
use ReportExporterTrait;
13+
14+
protected string $filename = 'products-report';
15+
16+
protected static ?string $model = Product::class;
17+
18+
public static function getColumns(): array
19+
{
20+
return [
21+
ExportColumn::make('category.name'),
22+
ExportColumn::make('sku')
23+
->label('SKU'),
24+
ExportColumn::make('name'),
25+
ExportColumn::make('purchase_price'),
26+
ExportColumn::make('selling_price'),
27+
ExportColumn::make('description'),
28+
ExportColumn::make('created_at'),
29+
ExportColumn::make('updated_at'),
30+
ExportColumn::make('deleted_at'),
31+
];
32+
}
33+
34+
public static function getCompletedNotificationBody(Export $export): string
35+
{
36+
$body = 'Your product export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
37+
38+
if ($failedRowsCount = $export->getFailedRowsCount()) {
39+
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
40+
}
41+
42+
return $body;
43+
}
44+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace App\Filament\Exports;
4+
5+
use App\Models\PurchaseOrder;
6+
use Carbon\Carbon;
7+
use Filament\Actions\Exports\ExportColumn;
8+
use Filament\Actions\Exports\Exporter;
9+
use Filament\Actions\Exports\Models\Export;
10+
11+
class PurchaseOrderExporter extends Exporter
12+
{
13+
use ReportExporterTrait;
14+
15+
protected string $filename = 'purchase-orders-report';
16+
17+
protected static ?string $model = PurchaseOrder::class;
18+
19+
public static function getColumns(): array
20+
{
21+
return [
22+
ExportColumn::make('purchase_code'),
23+
ExportColumn::make('order_date')
24+
->formatStateUsing(fn ($state) => Carbon::parse($state)->format('M d, Y')),
25+
ExportColumn::make('expected_delivery_date')
26+
->formatStateUsing(fn ($state) => empty($state) ? '' : Carbon::parse($state)->format('M d, Y')),
27+
ExportColumn::make('status')
28+
->formatStateUsing(fn ($state) => $state->getLabel() ?? ''),
29+
ExportColumn::make('total_amount'),
30+
ExportColumn::make('paid_amount'),
31+
ExportColumn::make('supplier.company_name'),
32+
ExportColumn::make('paymentType.name'),
33+
ExportColumn::make('user.name'),
34+
ExportColumn::make('created_at'),
35+
ExportColumn::make('updated_at'),
36+
ExportColumn::make('deleted_at'),
37+
];
38+
}
39+
40+
public static function getCompletedNotificationBody(Export $export): string
41+
{
42+
$body = 'Your purchase order export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
43+
44+
if ($failedRowsCount = $export->getFailedRowsCount()) {
45+
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
46+
}
47+
48+
return $body;
49+
}
50+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Filament\Exports;
4+
5+
use Filament\Actions\Exports\Models\Export;
6+
7+
trait ReportExporterTrait
8+
{
9+
public function getFileName(Export $export): string
10+
{
11+
return "{$this->filename}-".now()->format('Y-m-d');
12+
}
13+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace App\Filament\Exports;
4+
5+
use App\Models\Sale;
6+
use Carbon\Carbon;
7+
use Filament\Actions\Exports\ExportColumn;
8+
use Filament\Actions\Exports\Exporter;
9+
use Filament\Actions\Exports\Models\Export;
10+
11+
class SaleExporter extends Exporter
12+
{
13+
use ReportExporterTrait;
14+
15+
protected string $filename = 'sales-report';
16+
17+
protected static ?string $model = Sale::class;
18+
19+
public static function getColumns(): array
20+
{
21+
return [
22+
ExportColumn::make('invoice_number'),
23+
ExportColumn::make('sale_date')
24+
->formatStateUsing(fn ($state) => Carbon::parse($state)->format('M d, Y')),
25+
ExportColumn::make('pay_until')
26+
->label('Due Date')
27+
->formatStateUsing(fn ($state) => now()->addDays($state)->format('M d, Y')),
28+
ExportColumn::make('vat'),
29+
ExportColumn::make('discount'),
30+
ExportColumn::make('discount_type')
31+
->formatStateUsing(fn ($state) => $state->getLabel()),
32+
ExportColumn::make('total_amount'),
33+
ExportColumn::make('paid_amount'),
34+
ExportColumn::make('customer.name'),
35+
ExportColumn::make('paymentType.name'),
36+
ExportColumn::make('user.name'),
37+
ExportColumn::make('created_at'),
38+
ExportColumn::make('updated_at'),
39+
ExportColumn::make('deleted_at'),
40+
];
41+
}
42+
43+
public static function getCompletedNotificationBody(Export $export): string
44+
{
45+
$body = 'Your sale export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
46+
47+
if ($failedRowsCount = $export->getFailedRowsCount()) {
48+
$body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
49+
}
50+
51+
return $body;
52+
}
53+
}

0 commit comments

Comments
 (0)