1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Create Test Data fixes (#3252)

* add types to transformers

* minor fixes for test data creator
This commit is contained in:
David Bomba 2020-01-27 21:53:08 +11:00 committed by GitHub
parent a72e1faa84
commit f0bac9e077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 59 additions and 46 deletions

View File

@ -217,22 +217,34 @@ class CreateTestData extends Command
foreach($company->clients as $client) {
$this->info('creating invoice for client #'.$client->id);
$this->createInvoice($client);
for($i=0; $i<$this->count; $i++)
$this->createInvoice($client);
$this->info('creating quote for client #'.$client->id);
$this->createQuote($client);
for($i=0; $i<$this->count; $i++)
$this->createQuote($client);
$this->info('creating expense for client #'.$client->id);
$this->createExpense($client);
for($i=0; $i<$this->count; $i++)
$this->createExpense($client);
$this->info('creating vendor for client #'.$client->id);
$this->createVendor($client);
for($i=0; $i<$this->count; $i++)
$this->createVendor($client);
$this->info('creating task for client #'.$client->id);
$this->createTask($client);
for($i=0; $i<$this->count; $i++)
$this->createTask($client);
$this->info('creating project for client #'.$client->id);
$this->createProject($client);
for($i=0; $i<$this->count; $i++)
$this->createProject($client);
}
}
@ -403,7 +415,8 @@ class CreateTestData extends Command
$invoice = InvoiceFactory::create($client->company->id, $client->user->id);//stub the company and user_id
$invoice->client_id = $client->id;
// $invoice->date = $faker->date();
$invoice->date = Carbon::now()->subDays(rand(0,90));
$dateable = Carbon::now()->subDays(rand(0,90));
$invoice->date = $dateable;
$invoice->line_items = $this->buildLineItems(rand(1,10));
$invoice->uses_inclusive_taxes = false;
@ -442,7 +455,7 @@ class CreateTestData extends Command
if (rand(0, 1)) {
$payment = PaymentFactory::create($client->company->id, $client->user->id);
$payment->date = now();
$payment->date = $dateable;
$payment->client_id = $client->id;
$payment->amount = $invoice->balance;
$payment->transaction_reference = rand(0, 500);

View File

@ -32,7 +32,7 @@ class ActivityTransformer extends EntityTransformer
'invoice_id' => $activity->invoice_id ? (string) $this->encodePrimaryKey($activity->invoice_id) : '',
'payment_id' => $activity->payment_id ? (string) $this->encodePrimaryKey($activity->payment_id) : '',
'credit_id' => $activity->credit_id ? (string) $this->encodePrimaryKey($activity->credit_id) : '',
'updated_at' => $activity->updated_at,
'updated_at' => (int)$activity->updated_at,
'expense_id' => $activity->expense_id ? (string) $this->encodePrimaryKey($activity->expense_id) : '',
'is_system' => (bool) $activity->is_system,
'contact_id' => $activity->contact_id ? (string) $this->encodePrimaryKey($activity->contact_id) : '',

View File

@ -33,8 +33,8 @@ class ClientContactLoginTransformer extends EntityTransformer
'first_name' => $contact->first_name ?: '',
'last_name' => $contact->last_name ?: '',
'email' => $contact->email ?: '',
'updated_at' => $contact->updated_at,
'archived_at' => $contact->deleted_at,
'updated_at' => (int)$contact->updated_at,
'archived_at' => (int)$contact->deleted_at,
'is_primary' => (bool) $contact->is_primary,
'is_locked' => (bool) $contact->is_locked,
'phone' => $contact->phone ?: '',

View File

@ -34,8 +34,8 @@ class ClientContactTransformer extends EntityTransformer
'first_name' => $contact->first_name ?: '',
'last_name' => $contact->last_name ?: '',
'email' => $contact->email ?: '',
'updated_at' => $contact->updated_at,
'archived_at' => $contact->deleted_at,
'updated_at' => (int)$contact->updated_at,
'archived_at' => (int)$contact->deleted_at,
'is_primary' => (bool) $contact->is_primary,
'is_locked' => (bool) $contact->is_locked,
'phone' => $contact->phone ?: '',

View File

@ -36,8 +36,8 @@ class ClientGatewayTokenTransformer extends EntityTransformer
'gateway_type_id' => (string)$cgt->gateway_type_id ?: '',
'company_gateway_id' => (string)$this->encodePrimaryKey($cgt->company_gateway_id) ?: '',
'is_default' => (bool) $cgt->is_default,
'updated_at' => $cgt->updated_at,
'archived_at' => $cgt->deleted_at,
'updated_at' => (int)$cgt->updated_at,
'archived_at' => (int)$cgt->deleted_at,
];
}
}

View File

@ -111,8 +111,8 @@ class ClientTransformer extends EntityTransformer
'is_deleted' => (bool) $client->is_deleted,
'vat_number' => $client->vat_number ?: '',
'id_number' => $client->id_number ?: '',
'updated_at' => $client->updated_at,
'archived_at' => $client->deleted_at,
'updated_at' => (int)$client->updated_at,
'archived_at' => (int)$client->deleted_at,
'display_name' => $client->present()->name()
];
}

View File

@ -53,8 +53,8 @@ class CompanyGatewayTransformer extends EntityTransformer
'update_details' => (bool)$company_gateway->update_details,
'config' => (string) $company_gateway->getConfigTransformed(),
'fees_and_limits' => $company_gateway->fees_and_limits ?: '',
'updated_at' => $company_gateway->updated_at,
'archived_at' => $company_gateway->deleted_at,
'updated_at' => (int)$company_gateway->updated_at,
'archived_at' => (int)$company_gateway->deleted_at,
'custom_value1' => $company_gateway->custom_value1 ?: '',
'custom_value2' => $company_gateway->custom_value2 ?: '',
'custom_value3' => $company_gateway->custom_value3 ?: '',

View File

@ -80,8 +80,8 @@ class CreditTransformer extends EntityTransformer
'status_id' => (string) ($credit->status_id ?: 1),
'design_id' => (string) ($credit->design_id ?: 1),
'invoice_id' => (string) ($credit->invoice_id ?: 1),
'updated_at' => $credit->updated_at,
'archived_at' => $credit->deleted_at,
'updated_at' => (int)$credit->updated_at,
'archived_at' => (int)$credit->deleted_at,
'number' => $credit->number ?: '',
'discount' => (float) $credit->discount,
'po_number' => $credit->po_number ?: '',

View File

@ -48,7 +48,7 @@ class DocumentTransformer extends EntityTransformer
'height' => (int) $document->height,
'is_default' => (bool) $document->is_default,
'updated_at' => (int) $document->updated_at,
'archived_at' => (int) $document->archived_at
'archived_at' => (int) $document->deleted_at
];
}

View File

@ -73,8 +73,8 @@ class ExpenseTransformer extends EntityTransformer
'custom_value2' => $expense->custom_value2 ?: '',
'custom_value3' => $expense->custom_value3 ?: '',
'custom_value4' => $expense->custom_value4 ?: '',
'updated_at' => $expense->updated_at,
'archived_at' => $expense->deleted_at,
'updated_at' => (int)$expense->updated_at,
'archived_at' => (int)$expense->deleted_at,
];
}
}

View File

@ -18,8 +18,8 @@ class InvoiceItemTransformer extends EntityTransformer
return [
'id' => (int) $item->id,
'product_key' => $item->product_key,
'updated_at' => $item->updated_at,
'archived_at' => $item->deleted_at,
'updated_at' => (int)$item->updated_at,
'archived_at' => (int)$item->deleted_at,
'notes' => $item->notes ?: '',
'cost' => (float) $item->cost ?: '',
'quantity' => (float) ($item->quantity ?: 0.0),

View File

@ -90,8 +90,8 @@ class InvoiceTransformer extends EntityTransformer
'client_id' => (string) $this->encodePrimaryKey($invoice->client_id),
'status_id' => (string) ($invoice->status_id ?: 1),
'design_id' => (string) ($invoice->design_id ?: 1),
'updated_at' => $invoice->updated_at,
'archived_at' => $invoice->deleted_at,
'updated_at' => (int)$invoice->updated_at,
'archived_at' => (int)$invoice->deleted_at,
'number' => $invoice->number ?: '',
'discount' => (float) $invoice->discount,
'po_number' => $invoice->po_number ?: '',

View File

@ -72,8 +72,8 @@ class PaymentTransformer extends EntityTransformer
'transaction_reference' => $payment->transaction_reference ?: '',
'date' => $payment->date ?: '',
'is_manual' => (bool) $payment->is_manual,
'updated_at' => $payment->updated_at,
'archived_at' => $payment->deleted_at,
'updated_at' => (int)$payment->updated_at,
'archived_at' => (int)$payment->deleted_at,
'is_deleted' => (bool) $payment->is_deleted,
'type_id' => (string) $payment->payment_type_id ?: '',
'invitation_id' => (string) $payment->invitation_id ?: '',

View File

@ -73,8 +73,8 @@ class ProductTransformer extends EntityTransformer
'tax_rate2' => (float) $product->tax_rate2 ?: 0,
'tax_name3' => $product->tax_name3 ?: '',
'tax_rate3' => (float) $product->tax_rate3 ?: 0,
'updated_at' => $product->updated_at,
'archived_at' => $product->deleted_at,
'updated_at' => (int)$product->updated_at,
'archived_at' => (int)$product->deleted_at,
'custom_value1' => $product->custom_value1 ?: '',
'custom_value2' => $product->custom_value2 ?: '',
'custom_value3' => $product->custom_value3 ?: '',

View File

@ -80,8 +80,8 @@ class QuoteTransformer extends EntityTransformer
'status_id' => (string) ($quote->status_id ?: 1),
'design_id' => (string) ($quote->design_id ?: 1),
'invoice_id' => (string) ($quote->invoice_id ?: 1),
'updated_at' => $quote->updated_at,
'archived_at' => $quote->deleted_at,
'updated_at' => (int)$quote->updated_at,
'archived_at' => (int)$quote->deleted_at,
'number' => $quote->number ?: '',
'discount' => (float) $quote->discount,
'po_number' => $quote->po_number ?: '',

View File

@ -87,8 +87,8 @@ class RecurringInvoiceTransformer extends EntityTransformer
'balance' => (float) $invoice->balance ?: '',
'client_id' => (string) $invoice->client_id,
'status_id' => (string) ($invoice->status_id ?: 1),
'updated_at' => $invoice->updated_at,
'archived_at' => $invoice->deleted_at,
'updated_at' => (int)$invoice->updated_at,
'archived_at' => (int)$invoice->deleted_at,
'discount' => (float) $invoice->discount ?: '',
'po_number' => $invoice->po_number ?: '',
'date' => $invoice->date ?: '',

View File

@ -87,8 +87,8 @@ class RecurringQuoteTransformer extends EntityTransformer
'balance' => (float) $quote->balance ?: '',
'client_id' => (string) $quote->client_id,
'status_id' => (string) ($quote->status_id ?: 1),
'updated_at' => $quote->updated_at,
'archived_at' => $quote->deleted_at,
'updated_at' => (int)$quote->updated_at,
'archived_at' => (int)$quote->deleted_at,
'discount' => (float) $quote->discount ?: '',
'po_number' => $quote->po_number ?: '',
'quote_date' => $quote->quote_date ?: '',

View File

@ -18,8 +18,8 @@ class TaxRateTransformer extends EntityTransformer
'id' => (string) $this->encodePrimaryKey($tax_rate->id),
'name' => (string) $tax_rate->name,
'rate' => (float) $tax_rate->rate,
'updated_at' => $tax_rate->updated_at,
'archived_at' => $tax_rate->deleted_at,
'updated_at' => (int)$tax_rate->updated_at,
'archived_at' => (int)$tax_rate->deleted_at,
];
}
}

View File

@ -52,8 +52,8 @@ class UserTransformer extends EntityTransformer
'last_name' => $user->last_name ?: '',
'email' => $user->email ?: '',
'last_login' => Carbon::parse($user->last_login)->timestamp,
'updated_at' => $user->updated_at,
'archived_at' => $user->deleted_at,
'updated_at' => (int)$user->updated_at,
'archived_at' => (int)$user->deleted_at,
'phone' => $user->phone ?: '',
'email_verified_at' => $user->getEmailVerifiedAt(),
'signature' => $user->signature ?: '',

View File

@ -34,8 +34,8 @@ class VendorContactTransformer extends EntityTransformer
'first_name' => $vendor->first_name ?: '',
'last_name' => $vendor->last_name ?: '',
'email' => $vendor->email ?: '',
'updated_at' => $vendor->updated_at,
'archived_at' => $vendor->deleted_at,
'updated_at' => (int)$vendor->updated_at,
'archived_at' => (int)$vendor->deleted_at,
'is_primary' => (bool) $vendor->is_primary,
'phone' => $vendor->phone ?: '',
'custom_value1' => $vendor->custom_value1 ?: '',

View File

@ -92,8 +92,8 @@ class VendorTransformer extends EntityTransformer
'is_deleted' => (bool) $vendor->is_deleted,
'vat_number' => $vendor->vat_number ?: '',
'id_number' => $vendor->id_number ?: '',
'updated_at' => $vendor->updated_at,
'archived_at' => $vendor->deleted_at,
'updated_at' => (int)$vendor->updated_at,
'archived_at' => (int)$vendor->deleted_at,
];
}
}