mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 05:24:35 -04:00
Minor fixeS
This commit is contained in:
parent
449649b748
commit
a93baadd1a
@ -29,6 +29,7 @@ use App\Models\Expense;
|
|||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Quote;
|
use App\Models\Quote;
|
||||||
|
use App\Models\RecurringInvoice;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Vendor;
|
use App\Models\Vendor;
|
||||||
@ -532,7 +533,9 @@ class CreateTestData extends Command
|
|||||||
$invoice->save();
|
$invoice->save();
|
||||||
$invoice->service()->createInvitations()->markSent();
|
$invoice->service()->createInvitations()->markSent();
|
||||||
|
|
||||||
$this->invoice_repo->markSent($invoice);
|
if (rand(0, 1)) {
|
||||||
|
$this->invoice_repo->markSent($invoice);
|
||||||
|
}
|
||||||
|
|
||||||
if (rand(0, 1)) {
|
if (rand(0, 1)) {
|
||||||
$invoice = $invoice->service()->markPaid()->save();
|
$invoice = $invoice->service()->markPaid()->save();
|
||||||
@ -545,6 +548,9 @@ class CreateTestData extends Command
|
|||||||
'documentable_id' => $invoice->id
|
'documentable_id' => $invoice->id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
RecurringInvoice::factory()->create(['user_id' => $invoice->user->id, 'company_id' => $invoice->company->id, 'client_id' => $invoice->client_id]);
|
||||||
|
|
||||||
|
|
||||||
event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars()));
|
event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ class PaymentController extends Controller
|
|||||||
$invoice_totals = $payable_invoices->sum('amount');
|
$invoice_totals = $payable_invoices->sum('amount');
|
||||||
$first_invoice = $invoices->first();
|
$first_invoice = $invoices->first();
|
||||||
$credit_totals = $first_invoice->client->getSetting('use_credits_payment') == 'always' ? $first_invoice->client->service()->getCreditBalance() : 0;
|
$credit_totals = $first_invoice->client->getSetting('use_credits_payment') == 'always' ? $first_invoice->client->service()->getCreditBalance() : 0;
|
||||||
$starting_invoice_amount = $first_invoice->amount;
|
$starting_invoice_amount = $first_invoice->balance;
|
||||||
|
|
||||||
if ($gateway) {
|
if ($gateway) {
|
||||||
$first_invoice->service()->addGatewayFee($gateway, $payment_method_id, $invoice_totals)->save();
|
$first_invoice->service()->addGatewayFee($gateway, $payment_method_id, $invoice_totals)->save();
|
||||||
@ -234,7 +234,7 @@ class PaymentController extends Controller
|
|||||||
* by adding it as a line item, and then subtract
|
* by adding it as a line item, and then subtract
|
||||||
* the starting and finishing amounts of the invoice.
|
* the starting and finishing amounts of the invoice.
|
||||||
*/
|
*/
|
||||||
$fee_totals = $first_invoice->amount - $starting_invoice_amount;
|
$fee_totals = $first_invoice->balance - $starting_invoice_amount;
|
||||||
|
|
||||||
if ($gateway) {
|
if ($gateway) {
|
||||||
$tokens = auth()->user()->client->gateway_tokens()
|
$tokens = auth()->user()->client->gateway_tokens()
|
||||||
|
@ -28,6 +28,8 @@ class LedgerService
|
|||||||
{
|
{
|
||||||
$balance = 0;
|
$balance = 0;
|
||||||
|
|
||||||
|
\DB::connection(config('database.default'))->beginTransaction();
|
||||||
|
|
||||||
$company_ledger = $this->ledger();
|
$company_ledger = $this->ledger();
|
||||||
|
|
||||||
if ($company_ledger) {
|
if ($company_ledger) {
|
||||||
@ -44,6 +46,8 @@ class LedgerService
|
|||||||
|
|
||||||
$this->entity->company_ledger()->save($company_ledger);
|
$this->entity->company_ledger()->save($company_ledger);
|
||||||
|
|
||||||
|
\DB::connection(config('database.default'))->commit();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +55,8 @@ class LedgerService
|
|||||||
{
|
{
|
||||||
$balance = 0;
|
$balance = 0;
|
||||||
|
|
||||||
|
\DB::connection(config('database.default'))->beginTransaction();
|
||||||
|
|
||||||
/* Get the last record for the client and set the current balance*/
|
/* Get the last record for the client and set the current balance*/
|
||||||
$company_ledger = $this->ledger();
|
$company_ledger = $this->ledger();
|
||||||
|
|
||||||
@ -68,12 +74,16 @@ class LedgerService
|
|||||||
|
|
||||||
$this->entity->company_ledger()->save($company_ledger);
|
$this->entity->company_ledger()->save($company_ledger);
|
||||||
|
|
||||||
|
\DB::connection(config('database.default'))->commit();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateCreditBalance($adjustment, $notes = '')
|
public function updateCreditBalance($adjustment, $notes = '')
|
||||||
{
|
{
|
||||||
$balance = 0;
|
$balance = 0;
|
||||||
|
|
||||||
|
\DB::connection(config('database.default'))->beginTransaction();
|
||||||
|
|
||||||
$company_ledger = $this->ledger();
|
$company_ledger = $this->ledger();
|
||||||
|
|
||||||
@ -91,6 +101,8 @@ class LedgerService
|
|||||||
|
|
||||||
$this->entity->company_ledger()->save($company_ledger);
|
$this->entity->company_ledger()->save($company_ledger);
|
||||||
|
|
||||||
|
\DB::connection(config('database.default'))->commit();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,6 +111,7 @@ class LedgerService
|
|||||||
return CompanyLedger::whereClientId($this->entity->client_id)
|
return CompanyLedger::whereClientId($this->entity->client_id)
|
||||||
->whereCompanyId($this->entity->company_id)
|
->whereCompanyId($this->entity->company_id)
|
||||||
->orderBy('id', 'DESC')
|
->orderBy('id', 'DESC')
|
||||||
|
->lockForUpdate()
|
||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,3 +122,11 @@ class LedgerService
|
|||||||
return $this->entity;
|
return $this->entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
DB::connection(config('database.default'))->beginTransaction();
|
||||||
|
|
||||||
|
\DB::connection(config('database.default'))->commit();
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
@ -141,8 +141,6 @@ class RecurringInvoiceTest extends TestCase
|
|||||||
])->put('/api/v1/recurring_invoices/'.$this->encodePrimaryKey($RecurringInvoice->id), $RecurringInvoice_update)
|
])->put('/api/v1/recurring_invoices/'.$this->encodePrimaryKey($RecurringInvoice->id), $RecurringInvoice_update)
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $this->token,
|
'X-API-TOKEN' => $this->token,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user