-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/inikoo/aiku
- Loading branch information
Showing
156 changed files
with
3,542 additions
and
1,974 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/Actions/Accounting/Invoice/InvoiceRecurringBillTransactions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Raul Perusquia <raul@inikoo.com> | ||
* Created: Thu, 20 Feb 2025 16:49:23 Central Indonesia Time, Sanur, Bali, Indonesia | ||
* Copyright (c) 2025, Raul A Perusquia Flores | ||
*/ | ||
|
||
namespace App\Actions\Accounting\Invoice; | ||
|
||
use App\Actions\Accounting\InvoiceTransaction\StoreInvoiceTransaction; | ||
use App\Actions\OrgAction; | ||
use App\Models\Accounting\Invoice; | ||
use App\Models\Fulfilment\RecurringBill; | ||
|
||
class InvoiceRecurringBillTransactions extends OrgAction | ||
{ | ||
public function handle(Invoice $invoice, RecurringBill $recurringBill): Invoice | ||
{ | ||
$transactions = $recurringBill->transactions; | ||
|
||
foreach ($transactions as $transaction) { | ||
$data = [ | ||
'tax_category_id' => $transaction->recurringBill->tax_category_id, | ||
'quantity' => $transaction->quantity * $transaction->temporal_quantity, | ||
'gross_amount' => $transaction->gross_amount, | ||
'net_amount' => $transaction->net_amount, | ||
]; | ||
StoreInvoiceTransaction::make()->action($invoice, $transaction->historicAsset, $data); | ||
} | ||
|
||
return $invoice; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/Actions/Comms/DispatchedEmail/Hydrators/DispatchedEmailHydrateEmailTracking.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Artha <artha@aw-advantage.com> | ||
* Created: Thu, 20 Feb 2025 13:37:24 Central Indonesia Time, Sanur, Bali, Indonesia | ||
* Copyright (c) 2025, Raul A Perusquia Flores | ||
*/ | ||
|
||
namespace App\Actions\Comms\DispatchedEmail\Hydrators; | ||
|
||
use App\Actions\Traits\WithEnumStats; | ||
use App\Enums\Comms\EmailTrackingEvent\EmailTrackingEventTypeEnum; | ||
use App\Models\Comms\DispatchedEmail; | ||
use Illuminate\Queue\Middleware\WithoutOverlapping; | ||
use Lorisleiva\Actions\Concerns\AsAction; | ||
|
||
class DispatchedEmailHydrateEmailTracking | ||
{ | ||
use AsAction; | ||
use WithEnumStats; | ||
|
||
private DispatchedEmail $dispatchedEmail; | ||
|
||
public string $jobQueue = 'low-priority'; | ||
|
||
public function __construct(DispatchedEmail $dispatchedEmail) | ||
{ | ||
$this->dispatchedEmail = $dispatchedEmail; | ||
} | ||
|
||
public function getJobMiddleware(): array | ||
{ | ||
return [(new WithoutOverlapping($this->dispatchedEmail->id))->dontRelease()]; | ||
} | ||
|
||
|
||
public function handle(DispatchedEmail $dispatchedEmail): void | ||
{ | ||
$stats = [ | ||
'number_clicks' => $dispatchedEmail | ||
->emailTrackingEvents() | ||
->where('type', EmailTrackingEventTypeEnum::CLICKED) | ||
->count(), | ||
'number_reads' => $dispatchedEmail | ||
->emailTrackingEvents() | ||
->where('type', EmailTrackingEventTypeEnum::OPENED) | ||
->count() | ||
]; | ||
|
||
$dispatchedEmail->update($stats); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/Actions/Comms/EmailTrackingEvent/PostProcessingEmailTrackingEvent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/* | ||
* Author: Raul Perusquia <raul@inikoo.com> | ||
* Created: Tue, 19 Nov 2024 11:09:35 Central Indonesia Time, Sanur, Bali, Indonesia | ||
* Copyright (c) 2024, Raul A Perusquia Flores | ||
*/ | ||
|
||
namespace App\Actions\Comms\EmailTrackingEvent; | ||
|
||
use App\Actions\OrgAction; | ||
use App\Actions\Traits\Rules\WithNoStrictRules; | ||
use App\Actions\Traits\WithActionUpdate; | ||
use App\Models\Comms\EmailTrackingEvent; | ||
use hisorange\BrowserDetect\Parser as Browser; | ||
use Illuminate\Support\Arr; | ||
|
||
class PostProcessingEmailTrackingEvent extends OrgAction | ||
{ | ||
use WithNoStrictRules; | ||
use WithActionUpdate; | ||
|
||
public function handle(EmailTrackingEvent $emailTrackingEvent): EmailTrackingEvent | ||
{ | ||
$parsedUserAgent = (new Browser())->parse(Arr::get($emailTrackingEvent->data, 'userAgent')); | ||
|
||
$ip = Arr::get($emailTrackingEvent->data, 'ipAddress'); | ||
$device = $parsedUserAgent->deviceType(); | ||
|
||
return $this->update($emailTrackingEvent, [ | ||
'ip' => $ip, | ||
'device' => $device, | ||
'data' => (object) [] | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.