2019-10-16 11:28:52 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-10-16 11:28:52 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-10-16 11:28:52 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Helpers\Invoice;
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class for discount calculations.
|
2019-10-16 11:28:52 +02:00
|
|
|
*/
|
|
|
|
trait CustomValuer
|
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
public function valuer($custom_value)
|
|
|
|
{
|
|
|
|
if (isset($custom_value) && is_numeric($custom_value)) {
|
|
|
|
return $custom_value;
|
|
|
|
}
|
2019-10-16 11:28:52 +02:00
|
|
|
|
|
|
|
return 0;
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-10-16 11:28:52 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public function valuerTax($custom_value, $has_custom_invoice_taxes)
|
|
|
|
{
|
|
|
|
if (isset($custom_value) && is_numeric($custom_value) && $has_custom_invoice_taxes === true) {
|
2020-09-06 11:38:10 +02:00
|
|
|
return round($custom_value * ($this->invoice->tax_rate1 / 100), 2) + round($custom_value * ($this->invoice->tax_rate2 / 100), 2) + round($custom_value * ($this->invoice->tax_rate3 / 100), 2);
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-10-16 11:28:52 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2019-10-16 11:28:52 +02:00
|
|
|
}
|