mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for tests
This commit is contained in:
parent
895cc7d926
commit
68a8715c6d
@ -32,7 +32,9 @@ class CloneQuoteToInvoiceFactory
|
||||
// unset($quote_array['public_notes']);
|
||||
unset($quote_array['footer']);
|
||||
unset($quote_array['design_id']);
|
||||
unset($quote_array['user']);
|
||||
|
||||
|
||||
foreach ($quote_array as $key => $value) {
|
||||
$invoice->{$key} = $value;
|
||||
}
|
||||
|
@ -63,6 +63,10 @@ class StoreRecurringExpenseRequest extends Request
|
||||
if(array_key_exists('color', $input) && is_null($input['color']))
|
||||
$input['color'] = '';
|
||||
|
||||
if(array_key_exists('foreign_amount', $input) && is_null($input['foreign_amount']))
|
||||
$input['foreign_amount'] = 0;
|
||||
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ class BaseRepository
|
||||
|
||||
if(!$model->id)
|
||||
$this->new_model = true;
|
||||
|
||||
|
||||
$model->saveQuietly();
|
||||
|
||||
/* Model now persisted, now lets do some child tasks */
|
||||
|
@ -58,7 +58,7 @@ class ApplyPaymentAmount extends AbstractService
|
||||
|
||||
$payment->amount = $this->amount;
|
||||
$payment->applied = min($this->amount, $this->invoice->balance);
|
||||
$payment->number = $this->getNextPaymentNumber($this->invoice->client);
|
||||
$payment->number = $this->getNextPaymentNumber($this->invoice->client, $payment);
|
||||
$payment->status_id = Payment::STATUS_COMPLETED;
|
||||
$payment->client_id = $this->invoice->client_id;
|
||||
$payment->transaction_reference = ctrans('texts.manual_entry');
|
||||
|
@ -52,7 +52,7 @@ class MarkPaid extends AbstractService
|
||||
|
||||
$payment->amount = $this->invoice->balance;
|
||||
$payment->applied = $this->invoice->balance;
|
||||
$payment->number = $this->getNextPaymentNumber($this->invoice->client);
|
||||
$payment->number = $this->getNextPaymentNumber($this->invoice->client, $payment);
|
||||
$payment->status_id = Payment::STATUS_COMPLETED;
|
||||
$payment->client_id = $this->invoice->client_id;
|
||||
$payment->transaction_reference = ctrans('texts.manual_entry');
|
||||
|
@ -215,7 +215,7 @@ trait GeneratesCounter
|
||||
|
||||
}
|
||||
|
||||
public function getNextRecurringQuoteNumber(Client $client, ?RecurringQuote $recurring_quote)
|
||||
public function getNextRecurringQuoteNumber(Client $client, $recurring_quote)
|
||||
{
|
||||
$entity_number = $this->getNextEntityNumber(RecurringQuote::class, $client);
|
||||
|
||||
|
@ -698,7 +698,7 @@ class PaymentTest extends TestCase
|
||||
$payment->amount = 10;
|
||||
$payment->client_id = $client->id;
|
||||
$payment->date = now();
|
||||
$payment->number = $client->getNextPaymentNumber($client);
|
||||
$payment->number = $client->getNextPaymentNumber($client, $payment);
|
||||
$payment->save();
|
||||
|
||||
$data = [
|
||||
|
@ -12,6 +12,7 @@ namespace Tests\Unit;
|
||||
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Factory\QuoteFactory;
|
||||
use App\Factory\VendorFactory;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
@ -184,24 +185,22 @@ class GeneratesCounterTest extends TestCase
|
||||
|
||||
public function testQuoteNumberValue()
|
||||
{
|
||||
$quote = Quote::factory()->create([
|
||||
'user_id' => $this->client->user_id,
|
||||
'company_id' => $this->client->company_id,
|
||||
'client_id' => $this->client->id
|
||||
]);
|
||||
|
||||
$quote_number = $this->getNextQuoteNumber($this->client->fresh());
|
||||
$quote_number = $this->getNextQuoteNumber($this->client->fresh(), $quote);
|
||||
|
||||
$this->assertEquals($quote_number, 0002);
|
||||
|
||||
// nlog(Quote::all()->pluck('number'));
|
||||
|
||||
// $quote_number = $this->getNextQuoteNumber($this->client->fresh());
|
||||
|
||||
// nlog($this->company->settings->quote_number_counter);
|
||||
|
||||
// nlog(Quote::all()->pluck('number'));
|
||||
|
||||
// $this->assertEquals($quote_number, '0003');
|
||||
}
|
||||
|
||||
public function testInvoiceNumberPattern()
|
||||
{
|
||||
|
||||
$settings = $this->client->company->settings;
|
||||
$settings->invoice_number_counter = 1;
|
||||
$settings->invoice_number_pattern = '{$year}-{$counter}';
|
||||
@ -234,8 +233,15 @@ class GeneratesCounterTest extends TestCase
|
||||
$this->client->save();
|
||||
$this->client->fresh();
|
||||
|
||||
$quote_number = $this->getNextQuoteNumber($this->client);
|
||||
$quote_number2 = $this->getNextQuoteNumber($this->client);
|
||||
$quote = Quote::factory()->create([
|
||||
'user_id' => $this->client->user_id,
|
||||
'company_id' => $this->client->company_id,
|
||||
'client_id' => $this->client->id
|
||||
]);
|
||||
|
||||
|
||||
$quote_number = $this->getNextQuoteNumber($this->client, $quote);
|
||||
$quote_number2 = $this->getNextQuoteNumber($this->client, $quote);
|
||||
|
||||
$this->assertEquals($quote_number, date('Y').'-0001');
|
||||
$this->assertEquals($quote_number2, date('Y').'-0002');
|
||||
@ -257,8 +263,14 @@ class GeneratesCounterTest extends TestCase
|
||||
$gs->settings = $settings;
|
||||
$gs->save();
|
||||
|
||||
$quote_number = $this->getNextQuoteNumber($this->client);
|
||||
$quote_number2 = $this->getNextQuoteNumber($this->client);
|
||||
$quote = Quote::factory()->create([
|
||||
'user_id' => $this->client->user_id,
|
||||
'company_id' => $this->client->company_id,
|
||||
'client_id' => $this->client->id
|
||||
]);
|
||||
|
||||
$quote_number = $this->getNextQuoteNumber($this->client, $quote);
|
||||
$quote_number2 = $this->getNextQuoteNumber($this->client, $quote);
|
||||
|
||||
$this->assertEquals($quote_number, date('Y').'-1000');
|
||||
$this->assertEquals($quote_number2, date('Y').'-1001');
|
||||
|
Loading…
Reference in New Issue
Block a user