mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 07:47:30 -04:00 
			
		
		
		
	Fixes for ledger
This commit is contained in:
		
							parent
							
								
									714be18351
								
							
						
					
					
						commit
						a2ef847f54
					
				| @ -163,7 +163,7 @@ class InvoiceController extends Controller | ||||
| 
 | ||||
|         //format data
 | ||||
|         $invoices->map(function ($invoice) { | ||||
|             $invoice->service()->removeUnpaidGatewayFees()->save(); | ||||
|             $invoice->service()->removeUnpaidGatewayFees(); | ||||
|             $invoice->balance = $invoice->balance > 0 ? Number::formatValue($invoice->balance, $invoice->client->currency()) : 0; | ||||
|             $invoice->partial =  $invoice->partial > 0 ? Number::formatValue($invoice->partial, $invoice->client->currency()) : 0; | ||||
| 
 | ||||
|  | ||||
| @ -16,7 +16,10 @@ class CreateStatementRequest extends Request | ||||
|      */ | ||||
|     public function authorize(): bool | ||||
|     { | ||||
|         return auth()->user()->isAdmin(); | ||||
|         // return auth()->user()->isAdmin();
 | ||||
| 
 | ||||
|         return auth()->user()->can('view', $this->client()); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @ -52,7 +55,6 @@ class CreateStatementRequest extends Request | ||||
| 
 | ||||
|     public function client(): ?Client | ||||
|     { | ||||
|         // return Client::without('gateway_tokens','documents','contacts.company',)->where('id', $this->client_id)->withTrashed()->first();
 | ||||
|         return Client::without('company',)->where('id', $this->client_id)->withTrashed()->first(); | ||||
|         return Client::without('company')->where('id', $this->client_id)->withTrashed()->first(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -349,7 +349,7 @@ class BaseDriver extends AbstractPaymentDriver | ||||
|         $invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->get(); | ||||
| 
 | ||||
|         $invoices->each(function ($invoice) { | ||||
|             $invoice->service()->removeUnpaidGatewayFees()->save(); | ||||
|             $invoice->service()->removeUnpaidGatewayFees(); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -72,8 +72,7 @@ class InstantPayment | ||||
|         $invoices->each(function($invoice){ | ||||
|             $invoice->service() | ||||
|                     ->markSent() | ||||
|                     ->removeUnpaidGatewayFees() | ||||
|                     ->save(); | ||||
|                     ->removeUnpaidGatewayFees(); | ||||
|         }); | ||||
| 
 | ||||
|         /* pop non payable invoice from the $payable_invoices array */ | ||||
|  | ||||
| @ -125,7 +125,7 @@ class AutoBillInvoice extends AbstractService | ||||
|          } | ||||
|          catch(\Exception $e){ | ||||
|             nlog("payment NOT captured for ". $this->invoice->number . " with error " . $e->getMessage()); | ||||
|             $this->invoice->service()->removeUnpaidGatewayFees()->save(); | ||||
|             $this->invoice->service()->removeUnpaidGatewayFees(); | ||||
|          } | ||||
| 
 | ||||
|         if($payment){ | ||||
|  | ||||
| @ -370,7 +370,6 @@ class InvoiceService | ||||
|                                      })->toArray(); | ||||
| 
 | ||||
|         $this->invoice = $this->invoice->calc()->getInvoice(); | ||||
|         $this->invoice->save(); | ||||
|          | ||||
|         /* 24-03-2022 */ | ||||
|         $new_balance = $this->invoice->balance; | ||||
| @ -378,7 +377,7 @@ class InvoiceService | ||||
|         $post_count = count($this->invoice->line_items); | ||||
|         nlog("pre count = {$pre_count} post count = {$post_count}"); | ||||
| 
 | ||||
|         if($pre_count != $post_count) | ||||
|         if((int)$pre_count != (int)$post_count) | ||||
|         { | ||||
|             $adjustment = $balance - $new_balance; | ||||
| 
 | ||||
|  | ||||
| @ -75,12 +75,16 @@ class UpdateInvoicePayment | ||||
|             //caution what if we amount paid was less than partial - we wipe it!
 | ||||
|             $invoice =  $invoice->service()  | ||||
|                                 ->clearPartial() | ||||
|                                 ->updateBalance($paid_amount * -1) | ||||
|                                 ->updatePaidToDate($paid_amount) | ||||
|                                 // ->updateBalance($paid_amount * -1)
 | ||||
|                                 // ->updatePaidToDate($paid_amount)
 | ||||
|                                 ->updateStatus() | ||||
|                                 ->touchPdf() | ||||
|                                 ->save(); | ||||
| 
 | ||||
|             $invoice->balance -= $paid_amount; | ||||
|             $invoice->paid_to_date += $paid_amount; | ||||
|             $invoice->save(); | ||||
|              | ||||
|             $invoice->service() | ||||
|                 ->workFlow() | ||||
|                 ->save(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user