mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 04:24:33 -04:00
Fixes for ledger
This commit is contained in:
parent
714be18351
commit
a2ef847f54
@ -163,7 +163,7 @@ class InvoiceController extends Controller
|
|||||||
|
|
||||||
//format data
|
//format data
|
||||||
$invoices->map(function ($invoice) {
|
$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->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;
|
$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
|
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
|
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 = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->get();
|
||||||
|
|
||||||
$invoices->each(function ($invoice) {
|
$invoices->each(function ($invoice) {
|
||||||
$invoice->service()->removeUnpaidGatewayFees()->save();
|
$invoice->service()->removeUnpaidGatewayFees();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,7 @@ class InstantPayment
|
|||||||
$invoices->each(function($invoice){
|
$invoices->each(function($invoice){
|
||||||
$invoice->service()
|
$invoice->service()
|
||||||
->markSent()
|
->markSent()
|
||||||
->removeUnpaidGatewayFees()
|
->removeUnpaidGatewayFees();
|
||||||
->save();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* pop non payable invoice from the $payable_invoices array */
|
/* pop non payable invoice from the $payable_invoices array */
|
||||||
|
@ -125,7 +125,7 @@ class AutoBillInvoice extends AbstractService
|
|||||||
}
|
}
|
||||||
catch(\Exception $e){
|
catch(\Exception $e){
|
||||||
nlog("payment NOT captured for ". $this->invoice->number . " with error " . $e->getMessage());
|
nlog("payment NOT captured for ". $this->invoice->number . " with error " . $e->getMessage());
|
||||||
$this->invoice->service()->removeUnpaidGatewayFees()->save();
|
$this->invoice->service()->removeUnpaidGatewayFees();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($payment){
|
if($payment){
|
||||||
|
@ -370,7 +370,6 @@ class InvoiceService
|
|||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
$this->invoice = $this->invoice->calc()->getInvoice();
|
$this->invoice = $this->invoice->calc()->getInvoice();
|
||||||
$this->invoice->save();
|
|
||||||
|
|
||||||
/* 24-03-2022 */
|
/* 24-03-2022 */
|
||||||
$new_balance = $this->invoice->balance;
|
$new_balance = $this->invoice->balance;
|
||||||
@ -378,7 +377,7 @@ class InvoiceService
|
|||||||
$post_count = count($this->invoice->line_items);
|
$post_count = count($this->invoice->line_items);
|
||||||
nlog("pre count = {$pre_count} post count = {$post_count}");
|
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;
|
$adjustment = $balance - $new_balance;
|
||||||
|
|
||||||
|
@ -75,12 +75,16 @@ class UpdateInvoicePayment
|
|||||||
//caution what if we amount paid was less than partial - we wipe it!
|
//caution what if we amount paid was less than partial - we wipe it!
|
||||||
$invoice = $invoice->service()
|
$invoice = $invoice->service()
|
||||||
->clearPartial()
|
->clearPartial()
|
||||||
->updateBalance($paid_amount * -1)
|
// ->updateBalance($paid_amount * -1)
|
||||||
->updatePaidToDate($paid_amount)
|
// ->updatePaidToDate($paid_amount)
|
||||||
->updateStatus()
|
->updateStatus()
|
||||||
->touchPdf()
|
->touchPdf()
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
$invoice->balance -= $paid_amount;
|
||||||
|
$invoice->paid_to_date += $paid_amount;
|
||||||
|
$invoice->save();
|
||||||
|
|
||||||
$invoice->service()
|
$invoice->service()
|
||||||
->workFlow()
|
->workFlow()
|
||||||
->save();
|
->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user