Support importing vendors

This commit is contained in:
Hillel Coren 2018-03-30 14:33:28 +03:00
parent 5a4961ea96
commit ab99ef0739
6 changed files with 34 additions and 15 deletions

View File

@ -98,10 +98,10 @@ class Vendor extends EntityModel
self::$fieldPostalCode,
self::$fieldCountry,
self::$fieldNotes,
VendorContact::$fieldFirstName,
VendorContact::$fieldLastName,
VendorContact::$fieldPhone,
VendorContact::$fieldEmail,
'contact_first_name',
'contact_last_name',
'contact_email',
'contact_phone',
];
}
@ -111,11 +111,12 @@ class Vendor extends EntityModel
public static function getImportMap()
{
return [
'first' => 'first_name',
'last' => 'last_name',
'email' => 'email',
'mobile|phone' => 'phone',
'name|organization' => 'name',
'first' => 'contact_first_name',
'last' => 'contact_last_name',
'email' => 'contact_email',
'mobile|phone' => 'contact_phone',
'work|office' => 'work_phone',
'name|organization|vendor' => 'name',
'street2|address2' => 'address2',
'street|address|address1' => 'address1',
'city' => 'city',

View File

@ -39,6 +39,19 @@ class BaseTransformer extends TransformerAbstract
return isset($this->maps[ENTITY_CLIENT][$name]);
}
/**
* @param $name
*
* @return bool
*/
public function hasVendor($name)
{
$name = trim(strtolower($name));
return isset($this->maps[ENTITY_VENDOR][$name]);
}
/**
* @param $key
*

View File

@ -31,12 +31,12 @@ class VendorTransformer extends BaseTransformer
'state' => $this->getString($data, 'state'),
'postal_code' => $this->getString($data, 'postal_code'),
'private_notes' => $this->getString($data, 'notes'),
'contacts' => [
'vendor_contacts' => [
[
'first_name' => $this->getString($data, 'first_name'),
'last_name' => $this->getString($data, 'last_name'),
'email' => $this->getString($data, 'email'),
'phone' => $this->getString($data, 'phone'),
'first_name' => $this->getString($data, 'contact_first_name'),
'last_name' => $this->getString($data, 'contact_last_name'),
'email' => $this->getString($data, 'contact_email'),
'phone' => $this->getString($data, 'contact_phone'),
],
],
'country_id' => isset($data->country) ? $this->getCountryId($data->country) : null,

View File

@ -97,6 +97,7 @@ class ImportService
ENTITY_PAYMENT,
ENTITY_TASK,
ENTITY_PRODUCT,
ENTITY_VENDOR,
ENTITY_EXPENSE,
ENTITY_CUSTOMER,
];

View File

@ -2799,6 +2799,10 @@ $LANG = array(
'view_in_portal' => 'View in Portal',
'cookie_message' => 'This website uses cookies to ensure you get the best experience on our website.',
'got_it' => 'Got it!',
'vendor_will_create' => 'vendor will be created',
'vendors_will_create' => 'vendors will be created',
'created_vendors' => 'Successfully created :count vendor(s)',
'import_vendors' => 'Import Vendors',
);

View File

@ -1,5 +1,5 @@
<tr>
<td>{{ trans('texts.client') }}</td>
<td>{{ trans('texts.vendor') }}</td>
@if ($multiUser)
<td>{{ trans('texts.user') }}</td>
@endif