Skip to content

Commit

Permalink
Merge pull request #81 from khalidmaquilang/dev
Browse files Browse the repository at this point in the history
v2.3.0 - SI-79 | Hotfix | todays widget + SI-78 | Hotfix | remove currency + SI-75 | Hotfix | sale view fix + SI-74 | Feature | fix plan fields + SI-84 | Feature | add prefix and fix company resource + SI-80 | Feature | Added Scheduler to check expired subscriptions + SI-82 | Feature | added sentry + SI-64 | Feature | goods issue + SI-85 | Feature | able to display limit + SI-86 | Hotfix | fix inventory creation
  • Loading branch information
khalidmaquilang authored Jun 16, 2024
2 parents b4ac94b + 456094a commit ac6c094
Show file tree
Hide file tree
Showing 73 changed files with 2,867 additions and 136 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"
SENTRY_LARAVEL_DSN=
24 changes: 24 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## :rocket: Deployment
- Run X, Y, Z on bas1
- Add the missing env variables

## Migrations
- 2021_07_23_214950_add_show_in_public_folder_column_to_contact_lists_table.php => `contact_lists` table
- 2021_09_16_010719_alter_filters_table.php => `filters` table

## Packages
- Updated package A
- Added package B

## :memo: Changes
**Change 1:**
- What has changed?

Add links and screenshots here

<hr>

**Change 2:**
- What has changed?

Add links and screenshots here
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ DB_PASSWORD=password
- Run ``composer install``
- Run ``npm install``
- Run ``php artisan key:generate``
- Run ``php artisan migrate``
- Run ``php artisan migrate --seed``
- Run ``php artisan shield:generate --all --option=permissions``
- Run ``php artisan serve``
- Run ``npm run dev`` (another window)
Expand Down Expand Up @@ -69,3 +69,11 @@ docker run --rm \
- Run ``./vendor/bin/sail artisan shield:generate --all --option=permissions``
- Run ``./vendor/bin/sail npm run dev``
- Open ``localhost`` on your browser

## Deploying Prod

- `composer install --prefer-dist --no-dev -o`
- `php artisan migrate`
- `php artisan optimize`
- `php artisan icon:cache`
- `php artisan filament:clear-cached-components`
39 changes: 39 additions & 0 deletions app/Console/Commands/CheckExpiredSubscriptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Console\Commands;

use App\Enums\SubscriptionStatusEnum;
use App\Events\PrepareFreemium;
use App\Services\SubscriptionService;
use Illuminate\Console\Command;

class CheckExpiredSubscriptions extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:check-expired-subscriptions';

/**
* The console command description.
*
* @var string
*/
protected $description = "This command checks for active subscriptions that have expired based on their `end_date`. Expired subscriptions are then marked as 'expired', and you can add additional logic here to handle notifications, access restrictions, or other relevant actions.";

/**
* Execute the console command.
*/
public function handle(SubscriptionService $subscriptionService)
{
$subscriptions = $subscriptionService->getExpiredSubscriptions();
foreach ($subscriptions as $subscription) {
$subscription->status = SubscriptionStatusEnum::PAST_DUE;
$subscription->save();

event(new PrepareFreemium($subscription->company));
}
}
}
40 changes: 40 additions & 0 deletions app/Enums/GoodsIssueTypeEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Enums;

use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;

enum GoodsIssueTypeEnum: string implements HasColor, HasLabel
{
case SALE = 'sale';
case TRANSFER = 'transfer';
case WRITE_OFF = 'write_off';
case RTO = 'return_to_supplier';

/**
* @return string
*/
public function getLabel(): string
{
return match ($this) {
self::SALE => 'Sale',
self::TRANSFER => 'Transfer',
self::WRITE_OFF => 'Write Off',
self::RTO => 'Return To Supplier',
};
}

/**
* @return string
*/
public function getColor(): string
{
return match ($this) {
self::SALE => 'success',
self::TRANSFER => 'info',
self::WRITE_OFF => 'gray',
self::RTO => 'danger',
};
}
}
9 changes: 9 additions & 0 deletions app/Enums/StockMovementEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ enum StockMovementEnum: string implements HasColor, HasLabel
case SALE = 'sale';
case ADJUSTMENT = 'adjustment';
case RETURN = 'return';
case TRANSFER = 'transfer';
case WRITE_OFF = 'write_off';
case RTO = 'return_to_supplier';

/**
* @return string
Expand All @@ -22,6 +25,9 @@ public function getLabel(): string
self::SALE => 'Sale',
self::ADJUSTMENT => 'Adjustment',
self::RETURN => 'Return',
self::TRANSFER => 'Transfer',
self::WRITE_OFF => 'Write Off',
self::RTO => 'Return To Supplier',
};
}

Expand All @@ -35,6 +41,9 @@ public function getColor(): string
self::SALE => 'success',
self::ADJUSTMENT => 'warning',
self::RETURN => 'danger',
self::TRANSFER => 'info',
self::WRITE_OFF => 'gray',
self::RTO => 'danger',
};
}
}
41 changes: 41 additions & 0 deletions app/Events/GoodsIssueCreated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Events;

use App\Enums\GoodsIssueTypeEnum;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class GoodsIssueCreated
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* Create a new event instance.
*/
public function __construct(
public int $productId,
public int $quantity,
public int $userId,
public GoodsIssueTypeEnum $type,
public ?string $customerId = null,
public ?string $supplierId = null,
public string $referenceNumber = '',
) {
//
}

/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('channel-name'),
];
}
}
2 changes: 2 additions & 0 deletions app/Events/GoodsReceiptCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Events;

use App\Enums\StockMovementEnum;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
Expand All @@ -21,6 +22,7 @@ public function __construct(
public int $userId,
public ?string $supplierId = null,
public string $referenceNumber = '',
public StockMovementEnum $type = StockMovementEnum::PURCHASE,
) {
//
}
Expand Down
34 changes: 34 additions & 0 deletions app/Events/PrepareFreemium.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Events;

use App\Models\Company;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class PrepareFreemium
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* Create a new event instance.
*/
public function __construct(public Company $company)
{
//
}

/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('channel-name'),
];
}
}
7 changes: 7 additions & 0 deletions app/Events/SaleCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Events;

use App\Enums\StockMovementEnum;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
Expand All @@ -15,12 +16,18 @@ class SaleCreated
* Create a new event instance.
*/
public function __construct(
public int $companyId,
public int $saleId,
public $saleDate,
public int $productId,
public string $sku,
public string $name,
public int $quantity,
public float $unitCost,
public int $userId,
public ?string $customerId = null,
public string $referenceNumber = '',
public StockMovementEnum $type = StockMovementEnum::SALE,
) {
//
}
Expand Down
36 changes: 8 additions & 28 deletions app/Filament/Admin/Resources/CompanyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,14 @@ class CompanyResource extends Resource
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('user_id')
->relationship('owner', 'name')
->searchable()
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('slug')
->required()
->maxLength(255),
Forms\Components\TextInput::make('logo')
->maxLength(255),
Forms\Components\TextInput::make('phone')
->tel()
->required()
->maxLength(255),
Forms\Components\TextInput::make('email')
->email()
->required()
->maxLength(255),
Forms\Components\Textarea::make('address')
->required()
->columnSpanFull(),
Forms\Components\TextInput::make('currency')
->required()
->maxLength(255),
]);
->schema(
array_merge([
Forms\Components\Select::make('user_id')
->relationship('owner', 'name')
->searchable()
->required(),
], Company::getForm())
);
}

public static function table(Table $table): Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function form(Form $form): Form
->required(),
Forms\Components\DatePicker::make('start_date')
->required(),
Forms\Components\DatePicker::make('end_date'),
Forms\Components\TextInput::make('extra_users')
->default(0),
]);
Expand All @@ -38,7 +39,7 @@ public function form(Form $form): Form
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('id')
->recordTitleAttribute('plan.name')
->columns([
Tables\Columns\TextColumn::make('plan.name'),
Tables\Columns\TextColumn::make('start_date')
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Admin/Resources/PlanResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ public static function form(Form $form): Form
Forms\Components\Select::make('billing_cycle')
->options(BillingCycleEnum::class)
->required(),
Forms\Components\TextInput::make('max_users')
->required()
->numeric(),
Forms\Components\TextInput::make('max_roles')
->required()
->numeric(),
Forms\Components\TextInput::make('max_monthly_purchase_order')
->required()
->numeric(),
Forms\Components\TextInput::make('max_monthly_sale_order')
->required()
->numeric(),
Forms\Components\Textarea::make('description')
->columnSpanFull(),
Forms\Components\Repeater::make('features')
Expand Down
Loading

0 comments on commit ac6c094

Please sign in to comment.