-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #433 from jesusantguerrero/release/alpha7
Release/alpha7
- Loading branch information
Showing
31 changed files
with
1,234 additions
and
500 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace App\Domains\Integration\Actions\APAP; | ||
|
||
use Exception; | ||
use Illuminate\Support\Str; | ||
use Illuminate\Support\Facades\Log; | ||
use Symfony\Component\DomCrawler\Crawler; | ||
use App\Domains\Automation\Models\Automation; | ||
use App\Domains\Integration\Concerns\MailToTransaction; | ||
use App\Domains\Integration\Concerns\TransactionDataDTO; | ||
|
||
class APAPNotification implements MailToTransaction | ||
{ | ||
use APAPAction; | ||
|
||
public function handle(Automation $automation, mixed $mail, int $index = 0): TransactionDataDTO | null | ||
{ | ||
$html= str_replace('<?xml version="1.0" encoding="utf-8"?>', "", $mail['message']); | ||
$html= str_replace('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', "", $html); | ||
// dd($html); | ||
$body = new Crawler($html, true, null , true); | ||
try { | ||
if (!$body) return null; | ||
$productLine = $body->filter('table')->first()->text(); | ||
$visaPos = strpos($productLine, 'Visa'); | ||
$product = Str::substr($productLine, $visaPos - 1, strpos($productLine, 'terminada') - $visaPos - 1); | ||
|
||
|
||
$tdValues = $body->filter('table td')->each(function (Crawler $node) { | ||
return $node->text(); | ||
}); | ||
|
||
$total = (int) str_replace(',', '', $tdValues[13]); | ||
$type = 1; | ||
|
||
return new TransactionDataDTO([ | ||
'id' => (int) $mail['id'], | ||
'date' => date('Y-m-d', strtotime($mail['date'])), | ||
'payee' => $tdValues[15], | ||
'category' => '', | ||
'categoryGroup' => '', | ||
'description' => $product, | ||
'amount' => $total * $type, | ||
'currencyCode' => APAP::parseCurrency($tdValues[11]) ?? "DOP", | ||
]); | ||
} catch (Exception $e) { | ||
Log::error($e->getMessage()); | ||
return null; | ||
} | ||
|
||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
app/Domains/Transaction/Listeners/DeleteTransactionPayment.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,33 @@ | ||
<?php | ||
|
||
namespace App\Domains\Transaction\Listeners; | ||
|
||
use Insane\Journal\Models\Core\Payment; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Insane\Journal\Events\TransactionDeleted; | ||
use App\Domains\Transaction\Services\ReconciliationService; | ||
|
||
class DeleteTransactionPayment implements ShouldQueue | ||
{ | ||
/** | ||
* Create the event listener. | ||
*/ | ||
public function __construct(private ReconciliationService $service) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Handle the event. | ||
*/ | ||
public function handle(TransactionDeleted $event): void | ||
{ | ||
echo $event->transaction->transactionable_type; | ||
if ($event->transaction->transactionable_type == Payment::class) { | ||
$payment = $event->transaction->transactionable; | ||
$billingCycle = $payment->payable; | ||
$payment->delete(); | ||
$billingCycle->update(); | ||
} | ||
} | ||
} |
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
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.