mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-10-01 09:13:19 -04:00
57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Staffpayroll\Services;
|
|
|
|
use App\Models\User;
|
|
use Modules\StaffPayroll\Services\InvoiceService;
|
|
use Modules\StudioPlus\Entities\StudioPlusVideo;
|
|
use Modules\StudioPlusWtiiabaddon\Entities\StudioPlusIncentive;
|
|
|
|
class GenerateInvoiceService
|
|
{
|
|
protected function addIncentiveItem(User $user, string $incentiveName = ''): void
|
|
{
|
|
$newUser = User::query()
|
|
->where('id', $user->id)
|
|
->first();
|
|
|
|
$invoice = (new InvoiceService)->getUserInvoiceOfMonth($newUser);
|
|
|
|
$invoice->items()->updateOrCreate(
|
|
[
|
|
'description' => $user->description,
|
|
],
|
|
[
|
|
'item_no' => 1,
|
|
'name' => $incentiveName,
|
|
'amount' => $user->amount_value_earned,
|
|
'quantity' => 1,
|
|
'issue_date' => now()->toDateString(),
|
|
]
|
|
);
|
|
}
|
|
|
|
protected function addIncentiveItemForVideo(User $user, StudioPlusVideo $studioPlusVideo, StudioPlusIncentive $studioPlusIncentive, string $incentiveName = '')
|
|
{
|
|
$newUser = User::query()
|
|
->where('id', $user->id)
|
|
->first();
|
|
|
|
$invoice = (new InvoiceService)->getUserInvoiceOfMonth($newUser);
|
|
|
|
$invoice->items()->updateOrCreate(
|
|
[
|
|
'studio_plus_video_id' => $studioPlusVideo->id
|
|
],
|
|
[
|
|
'item_no' => 1,
|
|
'name' => $incentiveName,
|
|
'description' => $studioPlusIncentive->description,
|
|
'amount' => $studioPlusIncentive->amount_value_earned,
|
|
'quantity' => 1,
|
|
'issue_date' => now()->toDateString(),
|
|
]
|
|
);
|
|
}
|
|
}
|