mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:57:33 -05:00 
			
		
		
		
	Static analysis cleanup
This commit is contained in:
		
							parent
							
								
									2b83235572
								
							
						
					
					
						commit
						eff80b0187
					
				@ -11,10 +11,15 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Helpers\Invoice;
 | 
			
		||||
 | 
			
		||||
use App\Models\Quote;
 | 
			
		||||
use App\Models\Client;
 | 
			
		||||
use App\Models\Credit;
 | 
			
		||||
use App\Models\Invoice;
 | 
			
		||||
use App\Models\PurchaseOrder;
 | 
			
		||||
use App\Models\RecurringQuote;
 | 
			
		||||
use App\DataMapper\InvoiceItem;
 | 
			
		||||
use App\DataMapper\BaseSettings;
 | 
			
		||||
use App\Models\RecurringInvoice;
 | 
			
		||||
use App\DataMapper\Tax\RuleInterface;
 | 
			
		||||
use App\Utils\Traits\NumberFormatter;
 | 
			
		||||
use App\DataMapper\Tax\ZipTax\Response;
 | 
			
		||||
@ -59,7 +64,7 @@ class InvoiceItemSum
 | 
			
		||||
        'AU', // Australia
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    protected $invoice;
 | 
			
		||||
    protected RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice;
 | 
			
		||||
 | 
			
		||||
    private $items;
 | 
			
		||||
 | 
			
		||||
@ -91,7 +96,7 @@ class InvoiceItemSum
 | 
			
		||||
 | 
			
		||||
    private RuleInterface $rule;
 | 
			
		||||
 | 
			
		||||
    public function __construct($invoice)
 | 
			
		||||
    public function __construct( RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice)
 | 
			
		||||
    {
 | 
			
		||||
        $this->tax_collection = collect([]);
 | 
			
		||||
 | 
			
		||||
@ -136,7 +141,7 @@ class InvoiceItemSum
 | 
			
		||||
 | 
			
		||||
    private function shouldCalculateTax(): self
 | 
			
		||||
    {
 | 
			
		||||
        if (!$this->invoice->company?->calculate_taxes) {
 | 
			
		||||
        if (!$this->invoice->company->calculate_taxes) {
 | 
			
		||||
            $this->calc_tax = false;
 | 
			
		||||
            return $this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -55,7 +55,7 @@ class InvoiceSum
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs the object with Invoice and Settings object.
 | 
			
		||||
     *
 | 
			
		||||
     * @param      \App\Models\RecurringInvoice|\App\Models\Quote|\App\Models\Credit|\App\Models\PurchaseOrder|\App\Models\Invoice  $invoice   The entity
 | 
			
		||||
     * @param RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice;
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct($invoice)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -11,9 +11,15 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Helpers\Invoice;
 | 
			
		||||
 | 
			
		||||
use App\Models\Quote;
 | 
			
		||||
use App\Models\Credit;
 | 
			
		||||
use App\Models\Invoice;
 | 
			
		||||
use App\Utils\Traits\NumberFormatter;
 | 
			
		||||
use App\Models\PurchaseOrder;
 | 
			
		||||
use App\Models\RecurringQuote;
 | 
			
		||||
use App\Models\RecurringInvoice;
 | 
			
		||||
use Illuminate\Support\Collection;
 | 
			
		||||
use App\Utils\Traits\NumberFormatter;
 | 
			
		||||
use App\Helpers\Invoice\InvoiceItemSumInclusive;
 | 
			
		||||
 | 
			
		||||
class InvoiceSumInclusive
 | 
			
		||||
{
 | 
			
		||||
@ -22,7 +28,7 @@ class InvoiceSumInclusive
 | 
			
		||||
    use Discounter;
 | 
			
		||||
    use NumberFormatter;
 | 
			
		||||
 | 
			
		||||
    protected $invoice;
 | 
			
		||||
    protected RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice;
 | 
			
		||||
 | 
			
		||||
    public $tax_map;
 | 
			
		||||
 | 
			
		||||
@ -46,7 +52,7 @@ class InvoiceSumInclusive
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs the object with Invoice and Settings object.
 | 
			
		||||
     *
 | 
			
		||||
     * @param      \App\Models\RecurringInvoice|\App\Models\Quote|\App\Models\Credit|\App\Models\PurchaseOrder|\App\Models\Invoice  $invoice   The entity
 | 
			
		||||
     * @param RecurringInvoice | Invoice | Quote | Credit | PurchaseOrder | RecurringQuote $invoice;
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct($invoice)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -35,30 +35,30 @@ use Laracasts\Presenter\PresentableTrait;
 | 
			
		||||
 * @property int $status_id
 | 
			
		||||
 * @property string|null $number
 | 
			
		||||
 * @property float $discount
 | 
			
		||||
 * @property int $is_amount_discount
 | 
			
		||||
 * @property bool $is_amount_discount
 | 
			
		||||
 * @property string|null $po_number
 | 
			
		||||
 * @property string|null $date
 | 
			
		||||
 * @property string|null $due_date
 | 
			
		||||
 * @property int $is_deleted
 | 
			
		||||
 * @property object|null $line_items
 | 
			
		||||
 * @property bool $is_deleted
 | 
			
		||||
 * @property array|null $line_items
 | 
			
		||||
 * @property object|null $backup
 | 
			
		||||
 * @property string|null $footer
 | 
			
		||||
 * @property string|null $public_notes
 | 
			
		||||
 * @property string|null $private_notes
 | 
			
		||||
 * @property string|null $terms
 | 
			
		||||
 * @property string|null $tax_name1
 | 
			
		||||
 * @property string $tax_rate1
 | 
			
		||||
 * @property float $tax_rate1
 | 
			
		||||
 * @property string|null $tax_name2
 | 
			
		||||
 * @property string $tax_rate2
 | 
			
		||||
 * @property float $tax_rate2
 | 
			
		||||
 * @property string|null $tax_name3
 | 
			
		||||
 * @property string $tax_rate3
 | 
			
		||||
 * @property string $total_taxes
 | 
			
		||||
 * @property float $tax_rate3
 | 
			
		||||
 * @property float $total_taxes
 | 
			
		||||
 * @property string|null $custom_value1
 | 
			
		||||
 * @property string|null $custom_value2
 | 
			
		||||
 * @property string|null $custom_value3
 | 
			
		||||
 * @property string|null $custom_value4
 | 
			
		||||
 * @property string $amount
 | 
			
		||||
 * @property string $balance
 | 
			
		||||
 * @property float $amount
 | 
			
		||||
 * @property float $balance
 | 
			
		||||
 * @property float|null $partial
 | 
			
		||||
 * @property string|null $last_viewed
 | 
			
		||||
 * @property int $frequency_id
 | 
			
		||||
@ -69,17 +69,17 @@ use Laracasts\Presenter\PresentableTrait;
 | 
			
		||||
 * @property int|null $updated_at
 | 
			
		||||
 * @property int|null $deleted_at
 | 
			
		||||
 * @property string $auto_bill
 | 
			
		||||
 * @property int $auto_bill_enabled
 | 
			
		||||
 * @property bool $auto_bill_enabled
 | 
			
		||||
 * @property int|null $design_id
 | 
			
		||||
 * @property int $uses_inclusive_taxes
 | 
			
		||||
 * @property bool $uses_inclusive_taxes
 | 
			
		||||
 * @property string|null $custom_surcharge1
 | 
			
		||||
 * @property string|null $custom_surcharge2
 | 
			
		||||
 * @property string|null $custom_surcharge3
 | 
			
		||||
 * @property string|null $custom_surcharge4
 | 
			
		||||
 * @property int $custom_surcharge_tax1
 | 
			
		||||
 * @property int $custom_surcharge_tax2
 | 
			
		||||
 * @property int $custom_surcharge_tax3
 | 
			
		||||
 * @property int $custom_surcharge_tax4
 | 
			
		||||
 * @property bool $custom_surcharge_tax1
 | 
			
		||||
 * @property bool $custom_surcharge_tax2
 | 
			
		||||
 * @property bool $custom_surcharge_tax3
 | 
			
		||||
 * @property bool $custom_surcharge_tax4
 | 
			
		||||
 * @property string|null $due_date_days
 | 
			
		||||
 * @property string|null $partial_due_date
 | 
			
		||||
 * @property string $exchange_rate
 | 
			
		||||
@ -609,22 +609,17 @@ class RecurringInvoice extends BaseModel
 | 
			
		||||
        switch ($status) {
 | 
			
		||||
            case self::STATUS_DRAFT:
 | 
			
		||||
                return '<h4><span class="badge badge-light">'.ctrans('texts.draft').'</span></h4>';
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_PENDING:
 | 
			
		||||
                return '<h4><span class="badge badge-primary">'.ctrans('texts.pending').'</span></h4>';
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_ACTIVE:
 | 
			
		||||
                return '<h4><span class="badge badge-primary">'.ctrans('texts.active').'</span></h4>';
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_COMPLETED:
 | 
			
		||||
                return '<h4><span class="badge badge-success">'.ctrans('texts.status_completed').'</span></h4>';
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_PAUSED:
 | 
			
		||||
                return '<h4><span class="badge badge-danger">'.ctrans('texts.paused').'</span></h4>';
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                // code...
 | 
			
		||||
                break;
 | 
			
		||||
                return '<h4><span class="badge badge-primary">'.ctrans('texts.pending').'</span></h4>';
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -633,22 +628,17 @@ class RecurringInvoice extends BaseModel
 | 
			
		||||
        switch ($status) {
 | 
			
		||||
            case self::STATUS_DRAFT:
 | 
			
		||||
                return ctrans('texts.draft');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_PENDING:
 | 
			
		||||
                return ctrans('texts.pending');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_ACTIVE:
 | 
			
		||||
                return ctrans('texts.active');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_COMPLETED:
 | 
			
		||||
                return ctrans('texts.status_completed');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_PAUSED:
 | 
			
		||||
                return ctrans('texts.paused');
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                // code...
 | 
			
		||||
                break;
 | 
			
		||||
                return ctrans('texts.pending');
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -657,43 +647,30 @@ class RecurringInvoice extends BaseModel
 | 
			
		||||
        switch ($frequency_id) {
 | 
			
		||||
            case self::FREQUENCY_DAILY:
 | 
			
		||||
                return ctrans('texts.freq_daily');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_WEEKLY:
 | 
			
		||||
                return ctrans('texts.freq_weekly');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_TWO_WEEKS:
 | 
			
		||||
                return ctrans('texts.freq_two_weeks');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_FOUR_WEEKS:
 | 
			
		||||
                return ctrans('texts.freq_four_weeks');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_MONTHLY:
 | 
			
		||||
                return ctrans('texts.freq_monthly');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_TWO_MONTHS:
 | 
			
		||||
                return ctrans('texts.freq_two_months');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_THREE_MONTHS:
 | 
			
		||||
                return ctrans('texts.freq_three_months');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_FOUR_MONTHS:
 | 
			
		||||
                return ctrans('texts.freq_four_months');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_SIX_MONTHS:
 | 
			
		||||
                return ctrans('texts.freq_six_months');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_ANNUALLY:
 | 
			
		||||
                return ctrans('texts.freq_annually');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_TWO_YEARS:
 | 
			
		||||
                return ctrans('texts.freq_two_years');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_THREE_YEARS:
 | 
			
		||||
                return ctrans('texts.freq_three_years');
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                return '';
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -774,15 +751,12 @@ class RecurringInvoice extends BaseModel
 | 
			
		||||
            case '':
 | 
			
		||||
            case '0':
 | 
			
		||||
                return $this->calculateDateFromTerms($date);
 | 
			
		||||
                break;
 | 
			
		||||
                
 | 
			
		||||
            case 'on_receipt':
 | 
			
		||||
                return Carbon::parse($date)->copy();
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            default:
 | 
			
		||||
                return $this->setDayOfMonth($date, $this->due_date_days);
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -543,22 +543,16 @@ class RecurringQuote extends BaseModel
 | 
			
		||||
        switch ($status) {
 | 
			
		||||
            case self::STATUS_DRAFT:
 | 
			
		||||
                return '<h4><span class="badge badge-light">'.ctrans('texts.draft').'</span></h4>';
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_PENDING:
 | 
			
		||||
                return '<h4><span class="badge badge-primary">'.ctrans('texts.pending').'</span></h4>';
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_ACTIVE:
 | 
			
		||||
                return '<h4><span class="badge badge-primary">'.ctrans('texts.active').'</span></h4>';
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_COMPLETED:
 | 
			
		||||
                return '<h4><span class="badge badge-success">'.ctrans('texts.status_completed').'</span></h4>';
 | 
			
		||||
                break;
 | 
			
		||||
            case self::STATUS_PAUSED:
 | 
			
		||||
                return '<h4><span class="badge badge-danger">'.ctrans('texts.paused').'</span></h4>';
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                // code...
 | 
			
		||||
                break;
 | 
			
		||||
                return '<h4><span class="badge badge-primary">'.ctrans('texts.pending').'</span></h4>';
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -567,46 +561,34 @@ class RecurringQuote extends BaseModel
 | 
			
		||||
        switch ($frequency_id) {
 | 
			
		||||
            case self::FREQUENCY_DAILY:
 | 
			
		||||
                return ctrans('texts.freq_daily');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_WEEKLY:
 | 
			
		||||
                return ctrans('texts.freq_weekly');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_TWO_WEEKS:
 | 
			
		||||
                return ctrans('texts.freq_two_weeks');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_FOUR_WEEKS:
 | 
			
		||||
                return ctrans('texts.freq_four_weeks');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_MONTHLY:
 | 
			
		||||
                return ctrans('texts.freq_monthly');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_TWO_MONTHS:
 | 
			
		||||
                return ctrans('texts.freq_two_months');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_THREE_MONTHS:
 | 
			
		||||
                return ctrans('texts.freq_three_months');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_FOUR_MONTHS:
 | 
			
		||||
                return ctrans('texts.freq_four_months');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_SIX_MONTHS:
 | 
			
		||||
                return ctrans('texts.freq_six_months');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_ANNUALLY:
 | 
			
		||||
                return ctrans('texts.freq_annually');
 | 
			
		||||
                break;
 | 
			
		||||
            case self::FREQUENCY_TWO_YEARS:
 | 
			
		||||
                return ctrans('texts.freq_two_years');
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                // code...
 | 
			
		||||
                break;
 | 
			
		||||
                return ctrans('texts.freq_weekly');
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Access the invoice calculator object.
 | 
			
		||||
     *
 | 
			
		||||
     * @return InvoiceSumInclusive | InvoiceSum The invoice calculator object getters
 | 
			
		||||
     */
 | 
			
		||||
    public function calc(): InvoiceSumInclusive | InvoiceSum
 | 
			
		||||
@ -679,10 +661,8 @@ class RecurringQuote extends BaseModel
 | 
			
		||||
        switch ($this->due_date_days) {
 | 
			
		||||
            case 'terms':
 | 
			
		||||
                return $this->calculateDateFromTerms($date);
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                return $this->setDayOfMonth($date, $this->due_date_days);
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -707,6 +687,7 @@ class RecurringQuote extends BaseModel
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Service entry points.
 | 
			
		||||
     * @return RecurringService
 | 
			
		||||
     */
 | 
			
		||||
    public function service() :RecurringService
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -11,15 +11,16 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Services\Recurring;
 | 
			
		||||
 | 
			
		||||
use App\Jobs\RecurringInvoice\SendRecurring;
 | 
			
		||||
use App\Jobs\Util\UnlinkFile;
 | 
			
		||||
use App\Models\RecurringQuote;
 | 
			
		||||
use Illuminate\Support\Carbon;
 | 
			
		||||
use App\Models\RecurringExpense;
 | 
			
		||||
use App\Models\RecurringInvoice;
 | 
			
		||||
use Illuminate\Support\Carbon;
 | 
			
		||||
use App\Jobs\RecurringInvoice\SendRecurring;
 | 
			
		||||
 | 
			
		||||
class RecurringService
 | 
			
		||||
{
 | 
			
		||||
    public function __construct(public RecurringInvoice | RecurringExpense $recurring_entity)
 | 
			
		||||
    public function __construct(public RecurringInvoice | RecurringExpense | RecurringQuote $recurring_entity)
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -30,6 +30,8 @@ class RecurringQuoteTest extends TestCase
 | 
			
		||||
    use DatabaseTransactions;
 | 
			
		||||
    use MockAccountData;
 | 
			
		||||
 | 
			
		||||
    public $faker;
 | 
			
		||||
    
 | 
			
		||||
    protected function setUp() :void
 | 
			
		||||
    {
 | 
			
		||||
        parent::setUp();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user