Skip to content

Commit

Permalink
Adding event to billing deleting of payment (openemr#6842)
Browse files Browse the repository at this point in the history
* Adding event to billing deleting of payment

* changed license and added space

* changed license and added space

* removing escaping
  • Loading branch information
juggernautsei committed Sep 13, 2023
1 parent d25d771 commit 74366f3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
9 changes: 8 additions & 1 deletion interface/billing/search_payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@
use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Common\Twig\TwigContainer;
use OpenEMR\Core\Header;
use OpenEMR\Events\Billing\Payments\DeletePayment;
use OpenEMR\OeUI\OemrUI;

if (!AclMain::aclCheckCore('acct', 'bill', '', 'write') && !AclMain::aclCheckCore('acct', 'eob', '', 'write')) {
echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Search Payment")]);
exit;
}

/**
* @var EventDispatcherInterface $eventDispatcher
*/
$eventDispatcher = $GLOBALS['kernel']->getEventDispatcher();

//===============================================================================
//Deletion of payment and its corresponding distributions.
//===============================================================================
Expand All @@ -51,7 +57,8 @@
sqlStatement("update form_encounter set last_level_closed=last_level_closed - 1 where pid =? and encounter=?", [$PId, $Encounter]);
}
}

//dispatch this payment is being deleted trigger refund process
$eventDispatcher->dispatch(new DeletePayment($DeletePaymentId), DeletePayment::ACTION_DELETE_PAYMENT, 10);
//delete and log that action
row_delete("ar_session", "session_id ='" . add_escape_custom($DeletePaymentId) . "'");
row_modify("ar_activity", "deleted = NOW()", "deleted IS NULL AND session_id = '" . add_escape_custom($DeletePaymentId) . "'");
Expand Down
27 changes: 27 additions & 0 deletions src/Events/Billing/Payments/DeletePayment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* @package openemr
* @link https://www.open-emr.org
* @author Sherwin Gaddis <[email protected]>
* @copyright (c) 2023
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/

namespace OpenEMR\Events\Billing\Payments;

use Symfony\Contracts\EventDispatcher\Event;

class DeletePayment extends Event
{
const ACTION_DELETE_PAYMENT = 'billing.payment.action.delete.payment';
private int $paymentId = 0;
public function __construct($paymentId)
{
$this->paymentId = $paymentId;
}
public function getPaymentId(): int
{
return $this->paymentId;
}
}

0 comments on commit 74366f3

Please sign in to comment.