2019-10-13 12:59:55 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Helpers\Invoice;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class for discount calculations
|
|
|
|
*/
|
|
|
|
trait Discounter
|
|
|
|
{
|
|
|
|
|
2019-10-16 11:28:52 +02:00
|
|
|
public function discount($amount)
|
2019-10-13 12:59:55 +02:00
|
|
|
{
|
|
|
|
|
2019-10-16 11:28:52 +02:00
|
|
|
if($this->invoice->is_amount_discount === true)
|
|
|
|
return $this->invoice->discount;
|
|
|
|
|
|
|
|
|
|
|
|
return round($amount * ($this->invoice->discount / 100), 2);
|
|
|
|
|
2019-10-13 12:59:55 +02:00
|
|
|
}
|
|
|
|
|
2019-10-16 11:28:52 +02:00
|
|
|
// public function pro_rata_discount($amount)
|
|
|
|
// {
|
|
|
|
// return round(($this->invoice->discount/$this->getSubTotal() * $amount),2);
|
|
|
|
// }
|
|
|
|
|
2019-10-13 12:59:55 +02:00
|
|
|
}
|