1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/Services/Recurring/IncreasePrice.php

34 lines
934 B
PHP
Raw Normal View History

2023-03-15 07:01:55 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Services\Recurring;
use App\Models\RecurringInvoice;
use App\Services\AbstractService;
class IncreasePrice extends AbstractService
{
public function __construct(public RecurringInvoice $recurring_invoice, public float $percentage)
{
}
public function run()
{
$line_items = $this->recurring_invoice->line_items;
foreach ($line_items as $key => $line_item) {
$line_items[$key]->cost = $line_item->cost * (1 + round(($this->percentage / 100), 2));
}
$this->recurring_invoice->line_items = $line_items;
$this->recurring_invoice->calc()->getInvoice()->save();
}
}