* Fixes for payment number

* Fixes for tests
This commit is contained in:
David Bomba 2020-02-26 21:46:35 +11:00 committed by GitHub
parent 0b2435af2a
commit b2f4e51b55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 54 additions and 52 deletions

View File

@ -448,7 +448,7 @@ class CreateTestData extends Command
{
$faker = \Faker\Factory::create();
$invoice = InvoiceFactory::create($client->company->id, $client->user->id);//stub the company and user_id
$invoice = InvoiceFactory::create($client->company->id, $client->user->id, $client->getMergedSettings(), $client);//stub the company and user_id
$invoice->client_id = $client->id;
// $invoice->date = $faker->date();
$dateable = Carbon::now()->subDays(rand(0,90));

View File

@ -131,7 +131,7 @@ class SendTestEmails extends Command
]);
}
$invoice = InvoiceFactory::create($company->id, $user->id);
$invoice = InvoiceFactory::create($company->id, $user->id, $client->getMergedSettings(), $client);
$invoice->client_id = $client->id;
$invoice->setRelation('client', $client);
$invoice->save();

View File

@ -16,7 +16,7 @@ use App\Models\Credit;
class CreditFactory
{
public static function create(int $company_id, int $user_id, object $settings, Client $client) :Credit
public static function create(int $company_id, int $user_id, object $settings= null, Client $client = null) :Credit
{
$credit = new Credit();
$credit->status_id = Credit::STATUS_DRAFT;
@ -24,9 +24,9 @@ class CreditFactory
$credit->discount = 0;
$credit->is_amount_discount = true;
$credit->po_number = '';
$credit->footer = strlen($settings->credit_footer) > 0 ? $settings->credit_footer : '';
$credit->terms = strlen($settings->credit_terms) > 0 ? $settings->credit_terms : '';
$credit->public_notes = strlen($client->public_notes) > 0 ? $client->public_notes : '';
$credit->footer = isset($settings) && strlen($settings->credit_footer) > 0 ? $settings->credit_footer : '';
$credit->terms = isset($settings) && strlen($settings->credit_terms) > 0 ? $settings->credit_terms : '';
$credit->public_notes = isset($client) && strlen($client->public_notes) > 0 ? $client->public_notes : '';
$credit->private_notes = '';
$credit->date = null;
$credit->due_date = null;

View File

@ -19,7 +19,7 @@ use Illuminate\Support\Facades\Log;
class InvoiceFactory
{
public static function create(int $company_id, int $user_id, object $settings, Client $client) :Invoice
public static function create(int $company_id, int $user_id, object $settings = null, Client $client = null) :Invoice
{
$invoice = new Invoice();
$invoice->status_id = Invoice::STATUS_DRAFT;
@ -27,9 +27,9 @@ class InvoiceFactory
$invoice->discount = 0;
$invoice->is_amount_discount = true;
$invoice->po_number = '';
$invoice->footer = strlen($settings->invoice_footer) > 0 ? $settings->invoice_footer : '';
$invoice->terms = strlen($settings->invoice_terms) > 0 ? $settings->invoice_terms : '';
$invoice->public_notes = strlen($client->public_notes) > 0 ? $client->public_notes : '';
$invoice->footer = isset($settings) && strlen($settings->invoice_footer) > 0 ? $settings->invoice_footer : '';
$invoice->terms = isset($settings) && strlen($settings->invoice_terms) > 0 ? $settings->invoice_terms : '';
$invoice->public_notes = isset($settings) && strlen($client->public_notes) > 0 ? $client->public_notes : '';
$invoice->private_notes = '';
$invoice->date = null;
$invoice->due_date = null;

View File

@ -19,7 +19,7 @@ use Illuminate\Support\Facades\Log;
class QuoteFactory
{
public static function create(int $company_id, int $user_id, object $settings, Client $client) :Quote
public static function create(int $company_id, int $user_id, object $settings = null, Client $client = null) :Quote
{
$quote = new Quote();
$quote->status_id = Quote::STATUS_DRAFT;
@ -27,9 +27,9 @@ class QuoteFactory
$quote->discount = 0;
$quote->is_amount_discount = true;
$quote->po_number = '';
$quote->footer = strlen($settings->quote_footer) > 0 ? $settings->quote_footer : '';
$quote->terms = strlen($settings->quote_terms) > 0 ? $settings->quote_terms : '';
$quote->public_notes = strlen($client->public_notes) > 0 ? $client->public_notes : '';
$quote->footer = isset($settings) && strlen($settings->quote_footer) > 0 ? $settings->quote_footer : '';
$quote->terms = isset($settings) && strlen($settings->quote_terms) > 0 ? $settings->quote_terms : '';
$quote->public_notes = isset($client) && strlen($client->public_notes) > 0 ? $client->public_notes : '';
$quote->private_notes = '';
$quote->date = null;
$quote->due_date = null;

View File

@ -158,7 +158,8 @@ class InvoiceController extends BaseController {
*
*/
public function create(CreateInvoiceRequest $request) {
$invoice = InvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id);
$invoice = InvoiceFactory::create(auth()->user()->company()->id, auth()->user()->id, $client->getMergedSettings(), $client);
return $this->itemResponse($invoice);
}

View File

@ -45,7 +45,7 @@ class MarkPaid extends AbstractService
$payment = PaymentFactory::create($this->invoice->company_id, $this->invoice->user_id);
$payment->amount = $this->invoice->balance;
$payment->number = $this->getNextPaymentNumber($payment->client);
$payment->number = $this->getNextPaymentNumber($this->invoice->client);
$payment->status_id = Payment::STATUS_COMPLETED;
$payment->client_id = $this->invoice->client_id;
$payment->transaction_reference = ctrans('texts.manual_entry');

View File

@ -187,7 +187,7 @@ class CompanyGatewayApiTest extends TestCase
])->post('/api/v1/company_gateways', $data);
$response->assertStatus(302);
$response->assertStatus(200);
}

View File

@ -42,12 +42,13 @@ class ImportTest extends TestCase
$this->makeTestData();
$migration_file = base_path() . '/tests/Unit/Migration/migration.json';
// \Log::error($migration_file);
// $handle = fopen($migration_file, "r");
// $migration_file = fread($handle, filesize($migration_file));
// fclose($handle);
$handle = fopen($migration_file, "r");
$migration_file = fread($handle, filesize($migration_file));
fclose($handle);
$this->migration_array = json_decode(file_get_contents($migration_file),1);
$this->migration_array = json_decode($migration_file,1);
}
public function testImportClassExists()
@ -102,7 +103,7 @@ class ImportTest extends TestCase
public function testInvoicesImporting()
{
$this->makeTestData();
//$this->makeTestData();
$this->invoice->forceDelete();
$this->quote->forceDelete();

View File

@ -17155,12 +17155,12 @@
"max_limit": 65317,
"fee_amount": "0.00",
"fee_percent": "0.000",
"tax_name1": null,
"tax_rate1": null,
"tax_name2": null,
"tax_rate2": null,
"tax_name3": "",
"tax_rate3": 0
"fee_tax_name1": null,
"fee_tax_rate1": null,
"fee_tax_name2": null,
"fee_tax_rate2": null,
"fee_tax_name3": "",
"fee_tax_rate3": 0
}
],
"custom_value1": "",
@ -17224,12 +17224,12 @@
"max_limit": 53254,
"fee_amount": "0.00",
"fee_percent": "0.000",
"tax_name1": null,
"tax_rate1": null,
"tax_name2": null,
"tax_rate2": null,
"tax_name3": "",
"tax_rate3": 0
"fee_tax_name1": null,
"fee_tax_rate1": null,
"fee_tax_name2": null,
"fee_tax_rate2": null,
"fee_tax_name3": "",
"fee_tax_rate3": 0
}
],
"custom_value1": "",
@ -17265,12 +17265,12 @@
"max_limit": 72857,
"fee_amount": "0.00",
"fee_percent": "0.000",
"tax_name1": null,
"tax_rate1": null,
"tax_name2": null,
"tax_rate2": null,
"tax_name3": "",
"tax_rate3": 0
"fee_tax_name1": null,
"fee_tax_rate1": null,
"fee_tax_name2": null,
"fee_tax_rate2": null,
"fee_tax_name3": "",
"fee_tax_rate3": 0
}
],
"custom_value1": "",
@ -17306,12 +17306,12 @@
"max_limit": 71349,
"fee_amount": "0.00",
"fee_percent": "0.000",
"tax_name1": null,
"tax_rate1": null,
"tax_name2": null,
"tax_rate2": null,
"tax_name3": "",
"tax_rate3": 0
"fee_tax_name1": null,
"fee_tax_rate1": null,
"fee_tax_name2": null,
"fee_tax_rate2": null,
"fee_tax_name3": "",
"fee_tax_rate3": 0
}
],
"custom_value1": "",
@ -17347,12 +17347,12 @@
"max_limit": 74365,
"fee_amount": "0.00",
"fee_percent": "0.000",
"tax_name1": null,
"tax_rate1": null,
"tax_name2": null,
"tax_rate2": null,
"tax_name3": "",
"tax_rate3": 0
"fee_tax_name1": null,
"fee_tax_rate1": null,
"fee_tax_name2": null,
"fee_tax_rate2": null,
"fee_tax_name3": "",
"fee_tax_rate3": 0
}
],
"custom_value1": "",