1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Working on data import tranformers

This commit is contained in:
Hillel Coren 2016-01-06 09:52:26 +02:00
parent 373c2e7736
commit 18155a9482
17 changed files with 95 additions and 96 deletions

View File

@ -13,20 +13,20 @@ class ClientTransformer extends BaseTransformer
return new Item($data, function ($data) {
return [
'name' => $data->organization,
'work_phone' => $data->busphone,
'address1' => $data->street,
'address2' => $data->street2,
'city' => $data->city,
'state' => $data->province,
'postal_code' => $data->postalcode,
'private_notes' => $data->notes,
'name' => $this->getString($data, 'organization'),
'work_phone' => $this->getString($data, 'busphone'),
'address1' => $this->getString($data, 'street'),
'address2' => $this->getString($data, 'street2'),
'city' => $this->getString($data, 'city'),
'state' => $this->getString($data, 'province'),
'postal_code' => $this->getString($data, 'postalcode'),
'private_notes' => $this->getString($data, 'notes'),
'contacts' => [
[
'first_name' => $data->firstname,
'last_name' => $data->lastname,
'email' => $data->email,
'phone' => $data->mobphone ?: $data->homephone,
'first_name' => $this->getString($data, 'firstname'),
'last_name' => $this->getString($data, 'lastname'),
'email' => $this->getString($data, 'email'),
'phone' => $this->getString($data, 'mobphone') ?: $this->getString($data, 'homephone'),
],
],
'country_id' => $this->getCountryId($data->country),

View File

@ -20,14 +20,13 @@ class InvoiceTransformer extends BaseTransformer
'client_id' => $this->getClientId($data->organization),
'invoice_number' => $this->getInvoiceNumber($data->invoice_number),
'paid' => (float) $data->paid,
'po_number' => $data->po_number,
'terms' => $data->terms,
'public_notes' => $data->notes,
'po_number' => $this->getString($data, 'po_number'),
'terms' => $this->getString($data, 'terms'),
'invoice_date_sql' => $data->create_date,
'invoice_items' => [
[
'product_key' => '',
'notes' => $data->notes,
'notes' => $this->getString($data, 'notes'),
'cost' => (float) $data->amount,
'qty' => 1,
]

View File

@ -13,7 +13,7 @@ class ClientTransformer extends BaseTransformer
return new Item($data, function ($data) {
return [
'name' => $data->client_name,
'name' => $this->getString($data, 'client_name'),
];
});
}

View File

@ -14,10 +14,10 @@ class ContactTransformer extends BaseTransformer
return new Item($data, function ($data) {
return [
'client_id' => $this->getClientId($data->client),
'first_name' => $data->first_name,
'last_name' => $data->last_name,
'email' => $data->email,
'phone' => $data->office_phone ?: $data->mobile_phone,
'first_name' => $this->getString($data, 'first_name'),
'last_name' => $this->getString($data, 'last_name'),
'email' => $this->getString($data, 'email'),
'phone' => $this->getString($data, 'office_phone') ?: $this->getString($data, 'mobile_phone'),
];
});
}

View File

@ -20,12 +20,12 @@ class InvoiceTransformer extends BaseTransformer
'client_id' => $this->getClientId($data->client),
'invoice_number' => $this->getInvoiceNumber($data->id),
'paid' => (float) $data->paid_amount,
'po_number' => $data->po_number,
'po_number' => $this->getString($data, 'po_number'),
'invoice_date_sql' => $this->getDate($data->issue_date, 'm/d/Y'),
'invoice_items' => [
[
'product_key' => '',
'notes' => $data->subject,
'notes' => $this->getString($data, 'subject'),
'cost' => (float) $data->invoice_amount,
'qty' => 1,
]

View File

@ -13,21 +13,21 @@ class ClientTransformer extends BaseTransformer
return new Item($data, function ($data) {
return [
'name' => $data->name,
'name' => $this->getString($data, 'name'),
'contacts' => [
[
'first_name' => $this->getFirstName($data->primary_contact),
'last_name' => $this->getLastName($data->primary_contactk),
'email' => $data->business_email,
'email' => $this->getString($data, 'business_email'),
],
],
'address1' => $data->address_1,
'address2' => $data->address_2,
'city' => $data->city,
'state' => $data->state_name,
'postal_code' => $data->zip_code,
'work_phone' => $data->phone,
'website' => $data->website,
'address1' => $this->getString($data, 'address_1'),
'address2' => $this->getString($data, 'address_2'),
'city' => $this->getString($data, 'city'),
'state' => $this->getString($data, 'state_name'),
'postal_code' => $this->getString($data, 'zip_code'),
'work_phone' => $this->getString($data, 'phone'),
'website' => $this->getString($data, 'website'),
'country_id' => $this->getCountryId($data->country),
];
});

View File

@ -25,7 +25,7 @@ class InvoiceTransformer extends BaseTransformer
'invoice_items' => [
[
'product_key' => '',
'notes' => $data->summary,
'notes' => $this->getString($data, 'summary'),
'cost' => (float) $data->billed_total,
'qty' => 1,
]

View File

@ -13,19 +13,19 @@ class ClientTransformer extends BaseTransformer
return new Item($data, function ($data) {
return [
'name' => $data->client_name,
'work_phone' => $data->tel,
'website' => $data->website,
'address1' => $data->address,
'city' => $data->city,
'state' => $data->state,
'postal_code' => $data->postcode,
'name' => $this->getString($data, 'client_name'),
'work_phone' => $this->getString($data, 'tel'),
'website' => $this->getString($data, 'website'),
'address1' => $this->getString($data, 'address'),
'city' => $this->getString($data, 'city'),
'state' => $this->getString($data, 'state'),
'postal_code' => $this->getString($data, 'postcode'),
'country_id' => $this->getCountryIdBy2($data->country),
'private_notes' => $data->notes,
'private_notes' => $this->getString($data, 'notes'),
'contacts' => [
[
'email' => $data->email,
'phone' => $data->mobile,
'email' => $this->getString($data, 'email'),
'phone' => $this->getString($data, 'mobile'),
],
],
];

View File

@ -19,15 +19,15 @@ class InvoiceTransformer extends BaseTransformer
return [
'client_id' => $this->getClientId($data->client_name),
'invoice_number' => $this->getInvoiceNumber($data->ref),
'po_number' => $data->po_number,
'po_number' => $this->getString($data, 'po_number'),
'invoice_date_sql' => $data->date,
'due_date_sql' => $data->due_date,
'invoice_footer' => $data->footer,
'invoice_footer' => $this->getString($data, 'footer'),
'paid' => (float) $data->paid,
'invoice_items' => [
[
'product_key' => '',
'notes' => $data->description,
'notes' => $this->getString($data, 'description'),
'cost' => (float) $data->total,
'qty' => 1,
]

View File

@ -13,19 +13,19 @@ class ClientTransformer extends BaseTransformer
return new Item($data, function ($data) {
return [
'name' => $data->name,
'city' => isset($data->city) ? $data->city : '',
'state' => isset($data->city) ? $data->stateprovince : '',
'id_number' => isset($data->registration_number) ? $data->registration_number : '',
'postal_code' => isset($data->postalzip_code) ? $data->postalzip_code : '',
'private_notes' => isset($data->notes) ? $data->notes : '',
'work_phone' => isset($data->phone) ? $data->phone : '',
'name' => $this->getString($data, 'name'),
'city' => $this->getString($data, 'city'),
'state' => $this->getString($data, 'stateprovince'),
'id_number' => $this->getString($data, 'registration_number'),
'postal_code' => $this->getString($data, 'postalzip_code'),
'private_notes' => $this->getString($data, 'notes'),
'work_phone' => $this->getString($data, 'phone'),
'contacts' => [
[
'first_name' => isset($data->contact_name) ? $this->getFirstName($data->contact_name) : '',
'last_name' => isset($data->contact_name) ? $this->getLastName($data->contact_name) : '',
'email' => $data->email,
'phone' => isset($data->mobile) ? $data->mobile : '',
'email' => $this->getString($data, 'email'),
'phone' => $this->getString($data, 'mobile'),
],
],
'country_id' => isset($data->country) ? $this->getCountryId($data->country) : null,

View File

@ -20,15 +20,15 @@ class InvoiceTransformer extends BaseTransformer
'client_id' => $this->getClientId($data->client),
'invoice_number' => $this->getInvoiceNumber($data->document_no),
'paid' => (float) $data->paid_to_date,
'po_number' => $data->purchase_order,
'terms' => $data->terms,
'public_notes' => $data->notes,
'po_number' => $this->getString($data, 'purchase_order'),
'terms' => $this->getString($data, 'terms'),
'public_notes' => $this->getString($data, 'notes'),
'invoice_date_sql' => $this->getDate($data->date),
'due_date_sql' => $this->getDate($data->due_date),
'invoice_items' => [
[
'product_key' => '',
'notes' => $data->description,
'notes' => $this->getString($data, 'description'),
'cost' => (float) $data->total,
'qty' => 1,
]

View File

@ -13,13 +13,13 @@ class ClientTransformer extends BaseTransformer
return new Item($data, function ($data) {
return [
'name' => $data->company,
'work_phone' => $data->phone,
'name' => $this->getString($data, 'company'),
'work_phone' => $this->getString($data, 'phone'),
'contacts' => [
[
'first_name' => $this->getFirstName($data->name),
'last_name' => $this->getLastName($data->name),
'email' => $data->email,
'email' => $this->getString($data, 'email'),
],
],
];

View File

@ -20,13 +20,13 @@ class InvoiceTransformer extends BaseTransformer
'client_id' => $this->getClientId($data->client),
'invoice_number' => $this->getInvoiceNumber($data->number),
'paid' => (float) $data->total - (float) $data->balance,
'public_notes' => $data->subject,
'public_notes' => $this->getString($data, 'subject'),
'invoice_date_sql' => $data->date_sent,
'due_date_sql' => $data->date_due,
'invoice_items' => [
[
'product_key' => '',
'notes' => $data->line_item,
'notes' => $this->getString($data, 'line_item'),
'cost' => (float) $data->total,
'qty' => 1,
]

View File

@ -13,22 +13,22 @@ class ClientTransformer extends BaseTransformer
return new Item($data, function ($data) {
return [
'name' => $data->customer_name,
'id_number' => $data->account_number,
'work_phone' => $data->phone,
'website' => $data->website,
'address1' => $data->address_line_1,
'address2' => $data->address_line_2,
'city' => $data->city,
'state' => $data->provincestate,
'postal_code' => $data->postal_codezip_code,
'private_notes' => $data->delivery_instructions,
'name' => $this->getString($data, 'customer_name'),
'id_number' => $this->getString($data, 'account_number'),
'work_phone' => $this->getString($data, 'phone'),
'website' => $this->getString($data, 'website'),
'address1' => $this->getString($data, 'address_line_1'),
'address2' => $this->getString($data, 'address_line_2'),
'city' => $this->getString($data, 'city'),
'state' => $this->getString($data, 'provincestate'),
'postal_code' => $this->getString($data, 'postal_codezip_code'),
'private_notes' => $this->getString($data, 'delivery_instructions'),
'contacts' => [
[
'first_name' => $data->contact_first_name,
'last_name' => $data->contact_last_name,
'email' => $data->email,
'phone' => $data->mobile,
'first_name' => $this->getString($data, 'contact_first_name'),
'last_name' => $this->getString($data, 'contact_last_name'),
'email' => $this->getString($data, 'email'),
'phone' => $this->getString($data, 'mobile'),
],
],
'country_id' => $this->getCountryId($data->country),

View File

@ -19,14 +19,14 @@ class InvoiceTransformer extends BaseTransformer
return [
'client_id' => $this->getClientId($data->customer),
'invoice_number' => $this->getInvoiceNumber($data->invoice_num),
'po_number' => $data->po_so,
'po_number' => $this->getString($data, 'po_so'),
'invoice_date_sql' => $this->getDate($data->invoice_date),
'due_date_sql' => $this->getDate($data->due_date),
'paid' => 0,
'invoice_items' => [
[
'product_key' => $data->product,
'notes' => $data->description,
'product_key' => $this->getString($data, 'product'),
'notes' => $this->getString($data, 'description'),
'cost' => (float) $data->amount,
'qty' => (float) $data->quantity,
]

View File

@ -13,21 +13,21 @@ class ClientTransformer extends BaseTransformer
return new Item($data, function ($data) {
return [
'name' => $data->customer_name,
'id_number' => $data->customer_id,
'work_phone' => $data->phonek,
'address1' => $data->billing_address,
'city' => $data->billing_city,
'state' => $data->billing_state,
'postal_code' => $data->billing_code,
'private_notes' => $data->notes,
'website' => $data->website,
'name' => $this->getString($data, 'customer_name'),
'id_number' => $this->getString($data, 'customer_id'),
'work_phone' => $this->getString($data, 'phone'),
'address1' => $this->getString($data, 'billing_address'),
'city' => $this->getString($data, 'billing_city'),
'state' => $this->getString($data, 'billing_state'),
'postal_code' => $this->getString($data, 'billing_code'),
'private_notes' => $this->getString($data, 'notes'),
'website' => $this->getString($data, 'website'),
'contacts' => [
[
'first_name' => $data->first_name,
'last_name' => $data->last_name,
'email' => $data->emailid,
'phone' => $data->mobilephone,
'first_name' => $this->getString($data, 'first_name'),
'last_name' => $this->getString($data, 'last_name'),
'email' => $this->getString($data, 'emailid'),
'phone' => $this->getString($data, 'mobilephone'),
],
],
'country_id' => $this->getCountryId($data->billing_country),

View File

@ -20,13 +20,13 @@ class InvoiceTransformer extends BaseTransformer
'client_id' => $this->getClientId($data->customer_name),
'invoice_number' => $this->getInvoiceNumber($data->invoice_number),
'paid' => (float) $data->total - (float) $data->balance,
'po_number' => $data->purchaseorder,
'po_number' => $this->getString($data, 'purchaseorder'),
'due_date_sql' => $data->due_date,
'invoice_date_sql' => $data->invoice_date,
'invoice_items' => [
[
'product_key' => '',
'notes' => $data->item_desc,
'notes' => $this->getString($data, 'item_desc'),
'cost' => (float) $data->total,
'qty' => 1,
]