mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 11:04:37 -04:00
Fixes for Client - Paid To Date updating when a payment with no invoices is generated
This commit is contained in:
parent
bfd6cf876b
commit
e808cc62a8
@ -77,10 +77,13 @@ class CreateAccount
|
|||||||
$sp794f3f->key = Str::random(32);
|
$sp794f3f->key = Str::random(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sp794f3f->trial_started = now();
|
if(Ninja::isHosted())
|
||||||
$sp794f3f->trial_plan = 'pro';
|
{
|
||||||
$sp794f3f->save();
|
$sp794f3f->trial_started = now();
|
||||||
|
$sp794f3f->trial_plan = 'pro';
|
||||||
|
$sp794f3f->save();
|
||||||
|
}
|
||||||
|
|
||||||
$sp035a66 = CreateCompany::dispatchNow($this->request, $sp794f3f);
|
$sp035a66 = CreateCompany::dispatchNow($this->request, $sp794f3f);
|
||||||
$sp035a66->load('account');
|
$sp035a66->load('account');
|
||||||
$sp794f3f->default_company_id = $sp035a66->id;
|
$sp794f3f->default_company_id = $sp035a66->id;
|
||||||
|
@ -48,7 +48,7 @@ class PaymentUpdatedActivity implements ShouldQueue
|
|||||||
|
|
||||||
$fields = new stdClass;
|
$fields = new stdClass;
|
||||||
|
|
||||||
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->payment->user_id;
|
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->payment->user_id;
|
||||||
|
|
||||||
$fields->payment_id = $payment->id;
|
$fields->payment_id = $payment->id;
|
||||||
$fields->client_id = $payment->client_id;
|
$fields->client_id = $payment->client_id;
|
||||||
|
@ -80,6 +80,11 @@ class PaymentRepository extends BaseRepository {
|
|||||||
|
|
||||||
$client->service()->updatePaidToDate($data['amount'])->save();
|
$client->service()->updatePaidToDate($data['amount'])->save();
|
||||||
}
|
}
|
||||||
|
elseif($data['amount'] >0){
|
||||||
|
|
||||||
|
//this fixes an edge case with unapplied payments
|
||||||
|
$client->service()->updatePaidToDate($data['amount'])->save();
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) {
|
if (array_key_exists('credits', $data) && is_array($data['credits']) && count($data['credits']) > 0) {
|
||||||
$_credit_totals = array_sum(array_column($data['credits'], 'amount'));
|
$_credit_totals = array_sum(array_column($data['credits'], 'amount'));
|
||||||
|
@ -104,6 +104,8 @@ class ApplyPayment extends AbstractService
|
|||||||
->ledger()
|
->ledger()
|
||||||
->updatePaymentBalance($amount_paid);
|
->updatePaymentBalance($amount_paid);
|
||||||
|
|
||||||
|
nlog("updating client balance by amount {$amount_paid}");
|
||||||
|
|
||||||
$this->invoice
|
$this->invoice
|
||||||
->client
|
->client
|
||||||
->service()
|
->service()
|
||||||
|
@ -33,13 +33,9 @@ class InvoiceService
|
|||||||
|
|
||||||
private $invoice;
|
private $invoice;
|
||||||
|
|
||||||
protected $client_service;
|
|
||||||
|
|
||||||
public function __construct($invoice)
|
public function __construct($invoice)
|
||||||
{
|
{
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
|
|
||||||
$this->client_service = new ClientService($invoice->client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,7 +45,7 @@ class InvoiceService
|
|||||||
*/
|
*/
|
||||||
public function markPaid()
|
public function markPaid()
|
||||||
{
|
{
|
||||||
$this->invoice = (new MarkPaid($this->client_service, $this->invoice))->run();
|
$this->invoice = (new MarkPaid($this->invoice))->run();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -29,14 +29,10 @@ class MarkPaid extends AbstractService
|
|||||||
{
|
{
|
||||||
use GeneratesCounter;
|
use GeneratesCounter;
|
||||||
|
|
||||||
private $client_service;
|
|
||||||
|
|
||||||
private $invoice;
|
private $invoice;
|
||||||
|
|
||||||
public function __construct(ClientService $client_service, Invoice $invoice)
|
public function __construct(Invoice $invoice)
|
||||||
{
|
{
|
||||||
$this->client_service = $client_service;
|
|
||||||
|
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +88,9 @@ class MarkPaid extends AbstractService
|
|||||||
$payment->ledger()
|
$payment->ledger()
|
||||||
->updatePaymentBalance($payment->amount * -1);
|
->updatePaymentBalance($payment->amount * -1);
|
||||||
|
|
||||||
$this->client_service
|
$this->invoice
|
||||||
|
->client
|
||||||
|
->service()
|
||||||
->updateBalance($payment->amount * -1)
|
->updateBalance($payment->amount * -1)
|
||||||
->updatePaidToDate($payment->amount)
|
->updatePaidToDate($payment->amount)
|
||||||
->save();
|
->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user