1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

enforce blank strings in transformers

This commit is contained in:
David Bomba 2019-09-27 08:14:02 +10:00
parent ae14195ade
commit 1e025dcbe1
11 changed files with 88 additions and 91 deletions

View File

@ -42,11 +42,8 @@ class CompanyTokenTransformer extends EntityTransformer
public function transform(CompanyToken $company_token)
{
return [
// 'id' => $this->encodePrimaryKey($company_token->id),
'token' => $company_token->token,
'name' => $company_token->name,
// 'user_id' => $company_token->user_id,
// 'company_id' => $company_token->company_id,
'name' => $company_token->name ?: '',
];
}

View File

@ -65,22 +65,22 @@ class CompanyTransformer extends EntityTransformer
{
return [
'id' => $this->encodePrimaryKey($company->id),
'name' => $company->name,
'logo' => $company->logo,
'company_key' => $company->company_key,
'address1' => $company->address1,
'address2' => $company->address2,
'city' => $company->city,
'state' => $company->state,
'postal_code' => $company->postal_code,
'work_phone' => $company->work_phone,
'work_email' => $company->work_email,
'country_id' => (string) $company->country_id,
'vat_number' => $company->vat_number,
'id_number' => $company->id_number,
'size_id' => (string) $company->size_id,
'industry_id' => (string) $company->industry_id,
'settings' => $company->settings,
'name' => $company->name ?: '',
'logo' => $company->logo ?: '',
'company_key' => $company->company_key ?: '',
'address1' => $company->address1 ?: '',
'address2' => $company->address2 ?: '',
'city' => $company->city ?: '',
'state' => $company->state ?: '',
'postal_code' => $company->postal_code ?: '',
'work_phone' => $company->work_phone ?: '',
'work_email' => $company->work_email ?: '',
'country_id' => (string) $company->country_id ?: '',
'vat_number' => $company->vat_number ?: '',
'id_number' => $company->id_number ?: '',
'size_id' => (string) $company->size_id ?: '',
'industry_id' => (string) $company->industry_id ?: '',
'settings' => $company->settings ?: '',
'updated_at' => $company->updated_at,
'deleted_at' => $company->deleted_at,
];

View File

@ -46,8 +46,8 @@ class CompanyUserTransformer extends EntityTransformer
public function transform(CompanyUser $company_user)
{
return [
'permissions' => $company_user->permissions,
'settings' => $company_user->settings,
'permissions' => $company_user->permissions ?: '',
'settings' => $company_user->settings ?: '',
'is_owner' => (bool) $company_user->is_owner,
'is_admin' => (bool) $company_user->is_admin,
'is_locked' => (bool) $company_user->is_locked,

View File

@ -24,8 +24,8 @@ class InvoiceInvitationTransformer extends EntityTransformer
return [
'id' => $this->encodePrimaryKey($invitation->id),
'key' => $invitation->getName(),
'link' => $invitation->getLink(),
'key' => $invitation->getName() ?: '',
'link' => $invitation->getLink() ?: '',
'sent_date' => $invitation->sent_date ?: '',
'viewed_date' => $invitation->sent_date ?: '',
'opened_date' => $invitation->opened_date ?: '',

View File

@ -21,17 +21,17 @@ class InvoiceItemTransformer extends EntityTransformer
'product_key' => $item->product_key,
'updated_at' => $item->updated_at,
'archived_at' => $item->deleted_at,
'notes' => $item->notes,
'cost' => (float) $item->cost,
'notes' => $item->notes ?: '',
'cost' => (float) $item->cost ?: '',
'quantity' => (float) ($item->quantity ?: 0.0),
'tax_name1' => $item->tax_name1 ? $item->tax_name1 : '',
'tax_rate1' => (float) ($item->tax_rate1 ?: 0.0),
'tax_name2' => $item->tax_name2 ? $item->tax_name2 : '',
'tax_rate2' => (float) ($item->tax_rate2 ?: 0.0),
'invoice_item_type_id' => (string) $item->invoice_item_type_id,
'invoice_item_type_id' => (string) $item->invoice_item_type_id ?: '',
'custom_value1' => $item->custom_value1 ?: '',
'custom_value2' => $item->custom_value2 ?: '',
'discount' => (float) $item->discount,
'discount' => (float) $item->discount ?: '',
];
}
}

View File

@ -83,41 +83,41 @@ class InvoiceTransformer extends EntityTransformer
{
return [
'id' => $this->encodePrimaryKey($invoice->id),
'amount' => (float) $invoice->amount,
'balance' => (float) $invoice->balance,
'amount' => (float) $invoice->amount ?: '',
'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,
'invoice_number' => $invoice->invoice_number,
'discount' => (float) $invoice->discount,
'po_number' => $invoice->po_number,
'discount' => (float) $invoice->discount ?: '',
'po_number' => $invoice->po_number ?: '',
'invoice_date' => $invoice->invoice_date ?: '',
'due_date' => $invoice->due_date ?: '',
'terms' => $invoice->terms ?: '',
'public_notes' => $invoice->public_notes ?: '',
'private_notes' => $invoice->private_notes ?: '',
'is_deleted' => (bool) $invoice->is_deleted,
'invoice_type_id' => (int) $invoice->invoice_type_id,
'invoice_type_id' => (int) $invoice->invoice_type_id ?: '',
'tax_name1' => $invoice->tax_name1 ? $invoice->tax_name1 : '',
'tax_rate1' => (float) $invoice->tax_rate1,
'tax_rate1' => (float) $invoice->tax_rate1 ?: '',
'tax_name2' => $invoice->tax_name2 ? $invoice->tax_name2 : '',
'tax_rate2' => (float) $invoice->tax_rate2,
'tax_rate2' => (float) $invoice->tax_rate2 ?: '',
'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 ?: '',
'custom_value1' => (string) $invoice->custom_value1,
'custom_value2' => (string) $invoice->custom_value2,
'custom_value3' => (string) $invoice->custom_value3,
'custom_value4' => (string) $invoice->custom_value4,
'custom_value1' => (string) $invoice->custom_value1 ?: '',
'custom_value2' => (string) $invoice->custom_value2 ?: '',
'custom_value3' => (string) $invoice->custom_value3 ?: '',
'custom_value4' => (string) $invoice->custom_value4 ?: '',
'has_tasks' => (bool) $invoice->has_tasks,
'has_expenses' => (bool) $invoice->has_expenses,
'custom_text_value1' => $invoice->custom_text_value1 ?: '',
'custom_text_value2' => $invoice->custom_text_value2 ?: '',
'line_items' => $invoice->line_items ?: '',
'backup' => $invoice->backup ?: '',
'settings' => $invoice->settings,
'settings' => $invoice->settings ?: '',
];
}

View File

@ -60,10 +60,10 @@ class ProductTransformer extends EntityTransformer
{
return [
'id' => $this->encodePrimaryKey($product->id),
'product_key' => $product->product_key,
'notes' => $product->notes,
'cost' => (float) $product->cost,
'price' => (float) $product->price,
'product_key' => $product->product_key ?: '',
'notes' => $product->notes ?: '',
'cost' => (float) $product->cost ?: '',
'price' => (float) $product->price ?: '',
'quantity' => (float) ($product->quantity ?: 0.0),
'tax_name1' => $product->tax_name1 ?: '',
'tax_rate1' => (float) $product->tax_rate1,

View File

@ -80,15 +80,15 @@ class QuoteTransformer extends EntityTransformer
{
return [
'id' => $this->encodePrimaryKey($quote->id),
'amount' => (float) $quote->amount,
'balance' => (float) $quote->balance,
'amount' => (float) $quote->amount ?: '',
'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,
'quote_number' => $quote->quote_number,
'discount' => (float) $quote->discount,
'po_number' => $quote->po_number,
'quote_number' => $quote->quote_number ?: '',
'discount' => (float) $quote->discount ?: '',
'po_number' => $quote->po_number ?: '',
'quote_date' => $quote->quote_date ?: '',
'valid_until' => $quote->valid_until ?: '',
'terms' => $quote->terms ?: '',
@ -97,23 +97,23 @@ class QuoteTransformer extends EntityTransformer
'is_deleted' => (bool) $quote->is_deleted,
'quote_type_id' => (string) $quote->quote_type_id,
'tax_name1' => $quote->tax_name1 ? $quote->tax_name1 : '',
'tax_rate1' => (float) $quote->tax_rate1,
'tax_rate1' => (float) $quote->tax_rate1 ?: '',
'tax_name2' => $quote->tax_name2 ? $quote->tax_name2 : '',
'tax_rate2' => (float) $quote->tax_rate2,
'tax_rate2' => (float) $quote->tax_rate2 ?: '',
'is_amount_discount' => (bool) ($quote->is_amount_discount ?: false),
'quote_footer' => $quote->quote_footer ?: '',
'partial' => (float) ($quote->partial ?: 0.0),
'partial_due_date' => $quote->partial_due_date ?: '',
'custom_value1' => (float) $quote->custom_value1,
'custom_value2' => (float) $quote->custom_value2,
'custom_taxes1' => (bool) $quote->custom_taxes1,
'custom_taxes2' => (bool) $quote->custom_taxes2,
'custom_value1' => (float) $quote->custom_value1 ?: '',
'custom_value2' => (float) $quote->custom_value2 ?: '',
'custom_taxes1' => (bool) $quote->custom_taxes1 ?: '',
'custom_taxes2' => (bool) $quote->custom_taxes2 ?: '',
'has_tasks' => (bool) $quote->has_tasks,
'has_expenses' => (bool) $quote->has_expenses,
'custom_text_value1' => $quote->custom_text_value1 ?: '',
'custom_text_value2' => $quote->custom_text_value2 ?: '',
'backup' => $quote->backup ?: '',
'settings' => $quote->settings,
'settings' => $quote->settings ?: '',
];
}
}

View File

@ -81,14 +81,14 @@ class RecurringInvoiceTransformer extends EntityTransformer
{
return [
'id' => $this->encodePrimaryKey($invoice->id),
'amount' => (float) $invoice->amount,
'balance' => (float) $invoice->balance,
'amount' => (float) $invoice->amount ?: '',
'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,
'discount' => (float) $invoice->discount,
'po_number' => $invoice->po_number,
'discount' => (float) $invoice->discount ?: '',
'po_number' => $invoice->po_number ?: '',
'invoice_date' => $invoice->invoice_date ?: '',
'due_date' => $invoice->due_date ?: '',
'terms' => $invoice->terms ?: '',
@ -96,27 +96,27 @@ class RecurringInvoiceTransformer extends EntityTransformer
'private_notes' => $invoice->private_notes ?: '',
'is_deleted' => (bool) $invoice->is_deleted,
'tax_name1' => $invoice->tax_name1 ? $invoice->tax_name1 : '',
'tax_rate1' => (float) $invoice->tax_rate1,
'tax_rate1' => (float) $invoice->tax_rate1 ?: '',
'tax_name2' => $invoice->tax_name2 ? $invoice->tax_name2 : '',
'tax_rate2' => (float) $invoice->tax_rate2,
'tax_rate2' => (float) $invoice->tax_rate2 ?: '',
'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 ?: '',
'custom_value1' => (float) $invoice->custom_value1,
'custom_value2' => (float) $invoice->custom_value2,
'custom_taxes1' => (bool) $invoice->custom_taxes1,
'custom_taxes2' => (bool) $invoice->custom_taxes2,
'custom_value1' => (float) $invoice->custom_value1 ?: '',
'custom_value2' => (float) $invoice->custom_value2 ?: '',
'custom_taxes1' => (bool) $invoice->custom_taxes1 ?: '',
'custom_taxes2' => (bool) $invoice->custom_taxes2 ?: '',
'has_tasks' => (bool) $invoice->has_tasks,
'has_expenses' => (bool) $invoice->has_expenses,
'custom_text_value1' => $invoice->custom_text_value1 ?: '',
'custom_text_value2' => $invoice->custom_text_value2 ?: '',
'backup' => $invoice->backup ?: '',
'settings' => $invoice->settings,
'settings' => $invoice->settings ?: '',
'frequency_id' => (string) $invoice->frequency_id,
'start_date' => $invoice->start_date,
'last_sent_date' => $invoice->last_sent_date,
'next_send_date' => $invoice->next_send_date,
'start_date' => $invoice->start_date ?: '',
'last_sent_date' => $invoice->last_sent_date ?: '',
'next_send_date' => $invoice->next_send_date ?: '',
'remaining_cycles' => (int) $invoice->remaining_cycles,
];
}

View File

@ -81,14 +81,14 @@ class RecurringQuoteTransformer extends EntityTransformer
{
return [
'id' => $this->encodePrimaryKey($quote->id),
'amount' => (float) $quote->amount,
'balance' => (float) $quote->balance,
'amount' => (float) $quote->amount ?: '',
'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,
'discount' => (float) $quote->discount,
'po_number' => $quote->po_number,
'discount' => (float) $quote->discount ?: '',
'po_number' => $quote->po_number ?: '',
'quote_date' => $quote->quote_date ?: '',
'valid_until' => $quote->valid_until ?: '',
'terms' => $quote->terms ?: '',
@ -96,27 +96,27 @@ class RecurringQuoteTransformer extends EntityTransformer
'private_notes' => $quote->private_notes ?: '',
'is_deleted' => (bool) $quote->is_deleted,
'tax_name1' => $quote->tax_name1 ? $quote->tax_name1 : '',
'tax_rate1' => (float) $quote->tax_rate1,
'tax_rate1' => (float) $quote->tax_rate1 ?: '',
'tax_name2' => $quote->tax_name2 ? $quote->tax_name2 : '',
'tax_rate2' => (float) $quote->tax_rate2,
'tax_rate2' => (float) $quote->tax_rate2 ?: '',
'is_amount_discount' => (bool) ($quote->is_amount_discount ?: false),
'quote_footer' => $quote->quote_footer ?: '',
'partial' => (float) ($quote->partial ?: 0.0),
'partial_due_date' => $quote->partial_due_date ?: '',
'custom_value1' => (float) $quote->custom_value1,
'custom_value2' => (float) $quote->custom_value2,
'custom_taxes1' => (bool) $quote->custom_taxes1,
'custom_taxes2' => (bool) $quote->custom_taxes2,
'custom_value1' => (float) $quote->custom_value1 ?: '',
'custom_value2' => (float) $quote->custom_value2 ?: '',
'custom_taxes1' => (bool) $quote->custom_taxes1 ?: '',
'custom_taxes2' => (bool) $quote->custom_taxes2 ?: '',
'has_tasks' => (bool) $quote->has_tasks,
'has_expenses' => (bool) $quote->has_expenses,
'custom_text_value1' => $quote->custom_text_value1 ?: '',
'custom_text_value2' => $quote->custom_text_value2 ?: '',
'backup' => $quote->backup ?: '',
'settings' => $quote->settings,
'settings' => $quote->settings ?: '',
'frequency_id' => (int) $quote->frequency_id,
'start_date' => $quote->start_date,
'last_sent_date' => $quote->last_sent_date,
'next_send_date' => $quote->next_send_date,
'start_date' => $quote->start_date ?: '',
'last_sent_date' => $quote->last_sent_date ?: '',
'next_send_date' => $quote->next_send_date ?: '',
'remaining_cycles' => (int) $quote->remaining_cycles,
];
}

View File

@ -46,15 +46,15 @@ class UserTransformer extends EntityTransformer
{
return [
'id' => $this->encodePrimaryKey($user->id),
'first_name' => $user->first_name,
'last_name' => $user->last_name,
'email' => $user->email,
'last_login' => $user->last_login,
'first_name' => $user->first_name ?: '',
'last_name' => $user->last_name ?: '',
'email' => $user->email ?: '',
'last_login' => $user->last_login ?: '',
'updated_at' => $user->updated_at,
'deleted_at' => $user->deleted_at,
'phone' => $user->phone,
'email_verified_at' => $user->email_verified_at,
'signature' => $user->signature,
'phone' => $user->phone ?: '',
'email_verified_at' => $user->email_verified_at ?: '',
'signature' => $user->signature ?: '',
];
}