1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Static analysis cleanup

This commit is contained in:
David Bomba 2023-04-26 22:31:53 +10:00
parent f00a89dd8b
commit 97abec29f6
4 changed files with 4 additions and 98 deletions

View File

@ -20,23 +20,9 @@ use Illuminate\Support\Facades\App;
class AddGatewayFee extends AbstractService
{
private $company_gateway;
public $invoice;
private $amount;
private $gateway_type_id;
public function __construct(CompanyGateway $company_gateway, int $gateway_type_id, Invoice $invoice, float $amount)
public function __construct(private CompanyGateway $company_gateway, private int $gateway_type_id, public Invoice $invoice, private float $amount)
{
$this->company_gateway = $company_gateway;
$this->invoice = $invoice;
$this->amount = $amount;
$this->gateway_type_id = $gateway_type_id;
}
public function run()

View File

@ -21,17 +21,10 @@ class ApplyRecurringNumber extends AbstractService
{
use GeneratesCounter;
private $client;
private $invoice;
private bool $completed = true;
public function __construct(Client $client, Invoice $invoice)
public function __construct(private Client $client, private Invoice $invoice)
{
$this->client = $client;
$this->invoice = $invoice;
}
public function run()

View File

@ -12,16 +12,9 @@
namespace App\Services\Invoice;
use App\Events\Invoice\InvoiceWasReversed;
use App\Factory\CreditFactory;
use App\Factory\InvoiceItemFactory;
use App\Helpers\Invoice\InvoiceSum;
use App\Jobs\Ninja\TransactionLog;
use App\Models\Client;
use App\Models\Credit;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Paymentable;
use App\Models\TransactionEvent;
use App\Services\AbstractService;
use App\Utils\Ninja;
use App\Utils\Traits\GeneratesCounter;
@ -74,48 +67,6 @@ class HandleReversal extends AbstractService
/* Generate a credit for the $total_paid amount */
$notes = 'Credit for reversal of '.$this->invoice->number;
$credit = false;
// if ($total_paid > 0) {
// $credit = CreditFactory::create($this->invoice->company_id, $this->invoice->user_id);
// $credit->client_id = $this->invoice->client_id;
// $credit->invoice_id = $this->invoice->id;
// $credit->date = now();
// $item = InvoiceItemFactory::create();
// $item->quantity = 1;
// $item->cost = (float) $total_paid;
// $item->notes = $notes;
// $line_items[] = $item;
// $credit->line_items = $line_items;
// $credit->save();
// $credit_calc = new InvoiceSum($credit);
// $credit_calc->build();
// $credit = $credit_calc->purgeTaxes()->getCredit();
// $credit->service()->markSent()->save();
// }
/*If there is a payment linked, then the credit needs to be linked back to that payment in case of refund*/
if ($paymentables->count() > 0 && $credit) {
// $payment = $paymentables->first()->payment;
// $payment->credits()->save($credit);
// $paymentable_credit = $payment->credits()
// ->wherePaymentableType(Credit::class)
// ->wherePaymentableId($credit->id)
// ->first();
// //harvest the credit record and add in the amount for the credit.
// $paymentable_credit->pivot->amount = $total_paid;
// $paymentable_credit->pivot->save();
// $paymentable_credit->paid_to_date += $total_paid;
// $paymentable_credit->save();
}
/* Set invoice balance to 0 */
if ($this->invoice->balance != 0) {
@ -133,22 +84,11 @@ class HandleReversal extends AbstractService
$this->invoice->client->service()
->updateBalance($balance_remaining * -1)
// ->updatePaidToDate($total_paid * -1)
->save();
event(new InvoiceWasReversed($this->invoice, $this->invoice->company, Ninja::eventVars()));
$transaction = [
'invoice' => $this->invoice->transaction_event(),
'payment' => [],
'client' => $this->invoice->client->transaction_event(),
'credit' => [],
'metadata' => [],
];
// TransactionLog::dispatch(TransactionEvent::INVOICE_REVERSED, $transaction, $this->invoice->company->db);
return $this->invoice;
//create a ledger row for this with the resulting Credit ( also include an explanation in the notes section )
}
}

View File

@ -160,19 +160,6 @@ class UpdateReminder extends AbstractService
return $this->invoice;
}
private function testReminderValid($reminder_number, $reminder_schedule) :bool
{
$reminder_sent = "reminder{$reminder_number}_sent";
$schedule_reminder = "schedule_reminder{$reminder_number}";
$enable_reminder = "enable_reminder{$reminder_number}";
$late_fee_amount = "late_fee_amount{$reminder_number}";
$late_fee_percent = "late_fee_percent{$reminder_number}";
return is_null($this->invoice->{$reminder_sent}) &&
$this->settings->{$schedule_reminder} == $reminder_schedule &&
($this->settings->{$enable_reminder} || $late_fee_percent > 0 || $late_fee_amount > 0);
}
private function addTimeInterval($date, $endless_reminder_frequency_id) :?Carbon
{
if (! $date) {