1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Merge pull request #2198 from mindnervestech/mnt-nullable-fix-master

Transformers update for nullable fix
This commit is contained in:
Hillel Coren 2018-06-26 05:41:03 -07:00 committed by GitHub
commit 34e7b0aaaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 108 additions and 108 deletions

View File

@ -117,45 +117,45 @@ class ClientTransformer extends EntityTransformer
{
return array_merge($this->getDefaults($client), [
'id' => (int) $client->public_id,
'name' => $client->name,
'display_name' => $client->getDisplayName(),
'balance' => (float) $client->balance,
'paid_to_date' => (float) $client->paid_to_date,
'name' => $client->name ?: '',
'display_name' => $client->getDisplayName() ?: '',
'balance' => (float) ($client->balance ?: 0.0),
'paid_to_date' => (float) ($client->paid_to_date ?: 0.0),
'updated_at' => $this->getTimestamp($client->updated_at),
'archived_at' => $this->getTimestamp($client->deleted_at),
'address1' => $client->address1,
'address2' => $client->address2,
'city' => $client->city,
'state' => $client->state,
'postal_code' => $client->postal_code,
'country_id' => (int) $client->country_id,
'work_phone' => $client->work_phone,
'private_notes' => $client->private_notes,
'public_notes' => $client->public_notes,
'last_login' => $client->last_login,
'website' => $client->website,
'industry_id' => (int) $client->industry_id,
'size_id' => (int) $client->size_id,
'address1' => $client->address1 ?: '',
'address2' => $client->address2 ?: '',
'city' => $client->city ?: '',
'state' => $client->state ?: '',
'postal_code' => $client->postal_code ?: '',
'country_id' => (int) ($client->country_id ?: 0),
'work_phone' => $client->work_phone ?: '',
'private_notes' => $client->private_notes ?: '',
'public_notes' => $client->public_notes ?: '',
'last_login' => $client->last_login ?: '',
'website' => $client->website ?: '',
'industry_id' => (int) ($client->industry_id ?: 0),
'size_id' => (int) ($client->size_id ?: 0),
'is_deleted' => (bool) $client->is_deleted,
'payment_terms' => (int) $client->payment_terms,
'vat_number' => $client->vat_number,
'id_number' => $client->id_number,
'language_id' => (int) $client->language_id,
'currency_id' => (int) $client->currency_id,
'custom_value1' => $client->custom_value1,
'custom_value2' => $client->custom_value2,
'invoice_number_counter' => (int) $client->invoice_number_counter,
'quote_number_counter' => (int) $client->quote_number_counter,
'payment_terms' => (int) ($client->payment_terms ?: 0),
'vat_number' => $client->vat_number ?: '',
'id_number' => $client->id_number ?: '',
'language_id' => (int) ($client->language_id ?: 0),
'currency_id' => (int) ($client->currency_id ?: 0),
'custom_value1' => $client->custom_value1 ?: '',
'custom_value2' => $client->custom_value2 ?: '',
'invoice_number_counter' => (int) ($client->invoice_number_counter ?: 0),
'quote_number_counter' => (int) ($client->quote_number_counter ?: 0),
'task_rate' => (float) $client->task_rate,
'shipping_address1' => $client->shipping_address1,
'shipping_address2' => $client->shipping_address2,
'shipping_city' => $client->shipping_city,
'shipping_state' => $client->shipping_state,
'shipping_postal_code' => $client->shipping_postal_code,
'shipping_country_id' => (int) $client->shipping_country_id,
'shipping_address1' => $client->shipping_address1 ?: '',
'shipping_address2' => $client->shipping_address2 ?: '',
'shipping_city' => $client->shipping_city ?: '',
'shipping_state' => $client->shipping_state ?: '',
'shipping_postal_code' => $client->shipping_postal_code ?: '',
'shipping_country_id' => (int) ($client->shipping_country_id ?: 0),
'show_tasks_in_portal' => (bool) $client->show_tasks_in_portal,
'send_reminders' => (bool) $client->send_reminders,
'credit_number_counter' => (int) $client->credit_number_counter,
'credit_number_counter' => (int) ($client->credit_number_counter ?: 0),
'custom_messages' => json_encode($client->custom_messages),
]);
}

View File

@ -34,18 +34,18 @@ class ContactTransformer extends EntityTransformer
{
return array_merge($this->getDefaults($contact), [
'id' => (int) $contact->public_id,
'first_name' => $contact->first_name,
'last_name' => $contact->last_name,
'email' => $contact->email,
'contact_key' => $contact->contact_key,
'first_name' => $contact->first_name ?: '',
'last_name' => $contact->last_name ?: '',
'email' => $contact->email ?: '',
'contact_key' => $contact->contact_key ?: '',
'updated_at' => $this->getTimestamp($contact->updated_at),
'archived_at' => $this->getTimestamp($contact->deleted_at),
'is_primary' => (bool) $contact->is_primary,
'phone' => $contact->phone,
'last_login' => $contact->last_login,
'phone' => $contact->phone ?: '',
'last_login' => $contact->last_login ?: '',
'send_invoice' => (bool) $contact->send_invoice,
'custom_value1' => $contact->custom_value1,
'custom_value2' => $contact->custom_value2,
'custom_value1' => $contact->custom_value1 ?: '',
'custom_value2' => $contact->custom_value2 ?: '',
]);
}
}

View File

@ -31,10 +31,10 @@ class CreditTransformer extends EntityTransformer
'updated_at' => $this->getTimestamp($credit->updated_at),
'archived_at' => $this->getTimestamp($credit->deleted_at),
'is_deleted' => (bool) $credit->is_deleted,
'credit_date' => $credit->credit_date,
'credit_number' => $credit->credit_number,
'private_notes' => $credit->private_notes,
'public_notes' => $credit->public_notes,
'credit_date' => $credit->credit_date ?: '',
'credit_number' => $credit->credit_number ?: '',
'private_notes' => $credit->private_notes ?: '',
'public_notes' => $credit->public_notes ?: '',
'client_id' => $credit->client->public_id,
]);
}

View File

@ -19,7 +19,7 @@ class ExpenseCategoryTransformer extends EntityTransformer
{
return array_merge($this->getDefaults($expenseCategory), [
'id' => (int) $expenseCategory->public_id,
'name' => $expenseCategory->name,
'name' => $expenseCategory->name ?: '',
'updated_at' => $this->getTimestamp($expenseCategory->updated_at),
'archived_at' => $this->getTimestamp($expenseCategory->deleted_at),
]);

View File

@ -67,25 +67,25 @@ class ExpenseTransformer extends EntityTransformer
'should_be_invoiced' => (bool) $expense->should_be_invoiced,
'updated_at' => $this->getTimestamp($expense->updated_at),
'archived_at' => $this->getTimestamp($expense->deleted_at),
'transaction_id' => $expense->transaction_id,
'transaction_reference' => $expense->transaction_reference,
'bank_id' => $expense->bank_id,
'expense_currency_id' => (int) $expense->expense_currency_id,
'expense_category_id' => $expense->expense_category ? (int) $expense->expense_category->public_id : null,
'transaction_id' => $expense->transaction_id ?: '',
'transaction_reference' => $expense->transaction_reference ?: '',
'bank_id' => $expense->bank_id ?: '',
'expense_currency_id' => (int) ($expense->expense_currency_id ?: 0),
'expense_category_id' => $expense->expense_category ? (int) $expense->expense_category->public_id : 0,
'amount' => (float) $expense->amount,
'expense_date' => $expense->expense_date,
'expense_date' => $expense->expense_date ?: '',
'exchange_rate' => (float) $expense->exchange_rate,
'invoice_currency_id' => (int) $expense->invoice_currency_id,
'is_deleted' => (bool) $expense->is_deleted,
'tax_name1' => $expense->tax_name1,
'tax_name2' => $expense->tax_name2,
'tax_rate1' => $expense->tax_rate1,
'tax_rate2' => $expense->tax_rate2,
'client_id' => $this->client ? $this->client->public_id : (isset($expense->client->public_id) ? (int) $expense->client->public_id : null),
'invoice_id' => isset($expense->invoice->public_id) ? (int) $expense->invoice->public_id : null,
'vendor_id' => isset($expense->vendor->public_id) ? (int) $expense->vendor->public_id : null,
'custom_value1' => $expense->custom_value1,
'custom_value2' => $expense->custom_value2,
'tax_name1' => $expense->tax_name1 ?: '',
'tax_name2' => $expense->tax_name2 ?: '',
'tax_rate1' => $expense->tax_rate1 ?: '',
'tax_rate2' => $expense->tax_rate2 ?: '',
'client_id' => $this->client ? $this->client->public_id : (isset($expense->client->public_id) ? (int) $expense->client->public_id : 0),
'invoice_id' => isset($expense->invoice->public_id) ? (int) $expense->invoice->public_id : 0,
'vendor_id' => isset($expense->vendor->public_id) ? (int) $expense->vendor->public_id : 0,
'custom_value1' => $expense->custom_value1 ?: '',
'custom_value2' => $expense->custom_value2 ?: '',
]);
}
}

View File

@ -14,8 +14,8 @@ class InvitationTransformer extends EntityTransformer
'id' => (int) $invitation->public_id,
'key' => $invitation->getName(),
'link' => $invitation->getLink(),
'sent_date' => $invitation->sent_date,
'viewed_date' => $invitation->sent_date,
'sent_date' => $invitation->sent_date ?: '',
'viewed_date' => $invitation->sent_date ?: '',
];
}
}

View File

@ -15,14 +15,14 @@ class InvoiceItemTransformer extends EntityTransformer
'archived_at' => $this->getTimestamp($item->deleted_at),
'notes' => $item->notes,
'cost' => (float) $item->cost,
'qty' => (float) $item->qty,
'qty' => (float) ($item->qty ?: 0.0),
'tax_name1' => $item->tax_name1 ? $item->tax_name1 : '',
'tax_rate1' => (float) $item->tax_rate1,
'tax_rate1' => (float) ($item->tax_rate1 ?: 0.0),
'tax_name2' => $item->tax_name2 ? $item->tax_name2 : '',
'tax_rate2' => (float) $item->tax_rate2,
'tax_rate2' => (float) ($item->tax_rate2 ?: 0.0),
'invoice_item_type_id' => (int) $item->invoice_item_type_id,
'custom_value1' => $item->custom_value1,
'custom_value2' => $item->custom_value2,
'custom_value1' => $item->custom_value1 ?: '',
'custom_value2' => $item->custom_value2 ?: '',
'discount' => (float) $item->discount,
]);
}

View File

@ -97,29 +97,29 @@ class InvoiceTransformer extends EntityTransformer
'invoice_number' => $invoice->is_recurring ? '' : $invoice->invoice_number,
'discount' => (float) $invoice->discount,
'po_number' => $invoice->po_number,
'invoice_date' => $invoice->invoice_date,
'due_date' => $invoice->due_date,
'invoice_date' => $invoice->invoice_date ?: '',
'due_date' => $invoice->due_date ?: '',
'terms' => $invoice->terms,
'public_notes' => $invoice->public_notes,
'private_notes' => $invoice->private_notes,
'public_notes' => $invoice->public_notes ?: '',
'private_notes' => $invoice->private_notes ?: '',
'is_deleted' => (bool) $invoice->is_deleted,
'invoice_type_id' => (int) $invoice->invoice_type_id,
'is_recurring' => (bool) $invoice->is_recurring,
'frequency_id' => (int) $invoice->frequency_id,
'start_date' => $invoice->start_date,
'end_date' => $invoice->end_date,
'last_sent_date' => $invoice->last_sent_date,
'recurring_invoice_id' => (int) $invoice->recurring_invoice_id,
'start_date' => $invoice->start_date ?: '',
'end_date' => $invoice->end_date ?: '',
'last_sent_date' => $invoice->last_sent_date ?: '',
'recurring_invoice_id' => (int) ($invoice->recurring_invoice_id ?: 0),
'tax_name1' => $invoice->tax_name1 ? $invoice->tax_name1 : '',
'tax_rate1' => (float) $invoice->tax_rate1,
'tax_name2' => $invoice->tax_name2 ? $invoice->tax_name2 : '',
'tax_rate2' => (float) $invoice->tax_rate2,
'amount' => (float) $invoice->amount,
'balance' => (float) $invoice->balance,
'is_amount_discount' => (bool) $invoice->is_amount_discount,
'invoice_footer' => $invoice->invoice_footer,
'partial' => (float) $invoice->partial,
'partial_due_date' => $invoice->partial_due_date,
'is_amount_discount' => (bool) ($invoice->is_amount_discount ?: false),
'invoice_footer' => $invoice->invoice_footer ?: '',
'partial' => (float) ($invoice->partial ?: 0.0),
'partial_due_date' => $invoice->partial_due_date ?: '',
'has_tasks' => (bool) $invoice->has_tasks,
'auto_bill' => (bool) $invoice->auto_bill,
'custom_value1' => (float) $invoice->custom_value1,

View File

@ -25,15 +25,15 @@ class ProductTransformer extends EntityTransformer
'product_key' => $product->product_key,
'notes' => $product->notes,
'cost' => (float) $product->cost,
'qty' => (float) $product->qty,
'qty' => (float) ($product->qty ?: 0.0),
'tax_name1' => $product->tax_name1 ?: '',
'tax_rate1' => (float) $product->tax_rate1,
'tax_name2' => $product->tax_name2 ?: '',
'tax_rate2' => (float) $product->tax_rate2,
'updated_at' => $this->getTimestamp($product->updated_at),
'archived_at' => $this->getTimestamp($product->deleted_at),
'custom_value1' => $product->custom_value1,
'custom_value2' => $product->custom_value2,
'custom_value1' => $product->custom_value1 ?: '',
'custom_value2' => $product->custom_value2 ?: '',
'is_deleted' => (bool) $product->is_deleted,
]);
}

View File

@ -25,17 +25,17 @@ class ProjectTransformer extends EntityTransformer
{
return array_merge($this->getDefaults($project), [
'id' => (int) $project->public_id,
'name' => $project->name,
'client_id' => $project->client ? (int) $project->client->public_id : null,
'name' => $project->name ?: '',
'client_id' => $project->client ? (int) $project->client->public_id : 0,
'updated_at' => $this->getTimestamp($project->updated_at),
'archived_at' => $this->getTimestamp($project->deleted_at),
'is_deleted' => (bool) $project->is_deleted,
'task_rate' => (float) $project->task_rate,
'due_date' => $project->due_date,
'private_notes' => $project->private_notes,
'due_date' => $project->due_date ?: '',
'private_notes' => $project->private_notes ?: '',
'budgeted_hours' => (float) $project->budgeted_hours,
'custom_value1' => $project->custom_value1,
'custom_value2' => $project->custom_value2,
'custom_value1' => $project->custom_value1 ?: '',
'custom_value2' => $project->custom_value2 ?: '',
]);
}
}

View File

@ -52,18 +52,18 @@ class TaskTransformer extends EntityTransformer
{
return array_merge($this->getDefaults($task), [
'id' => (int) $task->public_id,
'description' => $task->description,
'duration' => $task->getDuration(),
'description' => $task->description ?: '',
'duration' => $task->getDuration() ?: 0,
'updated_at' => (int) $this->getTimestamp($task->updated_at),
'archived_at' => (int) $this->getTimestamp($task->deleted_at),
'invoice_id' => $task->invoice ? (int) $task->invoice->public_id : 0,
'client_id' => $task->client ? (int) $task->client->public_id : 0,
'project_id' => $task->project ? (int) $task->project->public_id : 0,
'is_deleted' => (bool) $task->is_deleted,
'time_log' => $task->time_log,
'time_log' => $task->time_log ?: '',
'is_running' => (bool) $task->is_running,
'custom_value1' => $task->custom_value1,
'custom_value2' => $task->custom_value2,
'custom_value1' => $task->custom_value1 ?: '',
'custom_value2' => $task->custom_value2 ?: '',
]);
}
}

View File

@ -11,13 +11,13 @@ class VendorContactTransformer extends EntityTransformer
{
return array_merge($this->getDefaults($contact), [
'id' => (int) $contact->public_id,
'first_name' => $contact->first_name,
'last_name' => $contact->last_name,
'email' => $contact->email,
'first_name' => $contact->first_name ?: '',
'last_name' => $contact->last_name ?: '',
'email' => $contact->email ?: '',
'updated_at' => $this->getTimestamp($contact->updated_at),
'archived_at' => $this->getTimestamp($contact->deleted_at),
'is_primary' => (bool) $contact->is_primary,
'phone' => $contact->phone,
'phone' => $contact->phone ?: '',
]);
}
}

View File

@ -67,9 +67,9 @@ class VendorTransformer extends EntityTransformer
{
return array_merge($this->getDefaults($vendor), [
'id' => (int) $vendor->public_id,
'name' => $vendor->name,
'balance' => (float) $vendor->balance,
'paid_to_date' => (float) $vendor->paid_to_date,
'name' => $vendor->name ?: '',
'balance' => (float) ($vendor->balance ?: 0.0),
'paid_to_date' => (float) ($vendor->paid_to_date ?: 0.0),
'updated_at' => $this->getTimestamp($vendor->updated_at),
'archived_at' => $this->getTimestamp($vendor->deleted_at),
'address1' => $vendor->address1,
@ -77,17 +77,17 @@ class VendorTransformer extends EntityTransformer
'city' => $vendor->city,
'state' => $vendor->state,
'postal_code' => $vendor->postal_code,
'country_id' => (int) $vendor->country_id,
'country_id' => (int) ($vendor->country_id ?: 0),
'work_phone' => $vendor->work_phone,
'private_notes' => $vendor->private_notes,
'last_login' => $vendor->last_login,
'last_login' => $vendor->last_login ?: '',
'website' => $vendor->website,
'is_deleted' => (bool) $vendor->is_deleted,
'vat_number' => $vendor->vat_number,
'id_number' => $vendor->id_number,
'currency_id' => (int) $vendor->currency_id,
'custom_value1' => $vendor->custom_value1,
'custom_value2' => $vendor->custom_value2,
'vat_number' => $vendor->vat_number ?: '',
'id_number' => $vendor->id_number ?: '',
'currency_id' => (int) ($vendor->currency_id ?: 0),
'custom_value1' => $vendor->custom_value1 ?: '',
'custom_value2' => $vendor->custom_value2 ?: '',
]);
}
}