mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 22:17:35 -05:00 
			
		
		
		
	Working on autobill payments
This commit is contained in:
		
							parent
							
								
									0ff8b68fbe
								
							
						
					
					
						commit
						018340cd03
					
				@ -42,6 +42,8 @@ class AutoBillInvoice extends AbstractService
 | 
			
		||||
        if(!$this->invoice->isPayable())
 | 
			
		||||
            return $this->invoice;
 | 
			
		||||
 | 
			
		||||
        $this->invoice = $this->invoice->service()->markSent()->save();
 | 
			
		||||
 | 
			
		||||
        if($this->invoice->balance > 0)
 | 
			
		||||
            $gateway_token = $this->getGateway($this->invoice->balance);      
 | 
			
		||||
        else
 | 
			
		||||
@ -70,12 +72,12 @@ class AutoBillInvoice extends AbstractService
 | 
			
		||||
 | 
			
		||||
        if($payment){
 | 
			
		||||
            
 | 
			
		||||
            $this->invoice->service()->toggleFeesPaid()->save();
 | 
			
		||||
            $this->invoice = $this->invoice->service()->toggleFeesPaid()->save();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            //autobill failed
 | 
			
		||||
            //TODO autobill failed
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -182,9 +182,11 @@ class InvoiceService
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        $this->invoice->line_items = collect($this->invoice->line_items)
 | 
			
		||||
                                     ->where('type_id',3)->map(function ($item) {
 | 
			
		||||
                                     ->map(function ($item) {
 | 
			
		||||
 | 
			
		||||
                                            if($item->type_id == 3)
 | 
			
		||||
                                                $item->type_id = 4;
 | 
			
		||||
                                            
 | 
			
		||||
                                            $item->type_id=4;
 | 
			
		||||
                                            return $item;
 | 
			
		||||
 | 
			
		||||
                                      })->toArray();
 | 
			
		||||
 | 
			
		||||
@ -42,6 +42,10 @@ class MarkPaid extends AbstractService
 | 
			
		||||
            $this->invoice->service()->markSent();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /*Don't double pay*/
 | 
			
		||||
        if($this->invoice->statud_id == Invoice::STATUS_PAID)
 | 
			
		||||
            return $this->invoice;
 | 
			
		||||
 | 
			
		||||
        /* Create Payment */
 | 
			
		||||
        $payment = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -45,11 +45,11 @@ class TriggeredActions extends AbstractService
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        if($this->request->has('auto_bill')) {
 | 
			
		||||
            $this->invoice->service()->autoBill()->save();
 | 
			
		||||
            $this->invoice = $this->invoice->service()->autoBill()->save();
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if($this->request->has('paid') && (bool)$this->request->input('paid') !== false) {
 | 
			
		||||
            $this->invoice->service()->markPaid()->save();
 | 
			
		||||
            $this->invoice = $this->invoice->service()->markPaid()->save();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if($this->request->has('send_email') && (bool)$this->request->input('send_email') !== false) {
 | 
			
		||||
 | 
			
		||||
@ -189,7 +189,9 @@ trait MakesReminders
 | 
			
		||||
        $client = $this->client;
 | 
			
		||||
 | 
			
		||||
        //if the invoice
 | 
			
		||||
        if ($client->getSetting('enable_reminder1') !== false && $this->inReminderWindow(
 | 
			
		||||
        if($this->balance == 0){
 | 
			
		||||
            return 'invoice';
 | 
			
		||||
        }elseif ($client->getSetting('enable_reminder1') !== false && $this->inReminderWindow(
 | 
			
		||||
            $client->getSetting('schedule_reminder1'),
 | 
			
		||||
            $client->getSetting('num_days_reminder1')
 | 
			
		||||
        )) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user