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

View File

@ -39,6 +39,19 @@ class BaseTransformer extends TransformerAbstract
return isset($this->maps[ENTITY_CLIENT][$name]); 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 * @param $key
* *

View File

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

View File

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

View File

@ -2799,6 +2799,10 @@ $LANG = array(
'view_in_portal' => 'View in Portal', 'view_in_portal' => 'View in Portal',
'cookie_message' => 'This website uses cookies to ensure you get the best experience on our website.', 'cookie_message' => 'This website uses cookies to ensure you get the best experience on our website.',
'got_it' => 'Got it!', '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> <tr>
<td>{{ trans('texts.client') }}</td> <td>{{ trans('texts.vendor') }}</td>
@if ($multiUser) @if ($multiUser)
<td>{{ trans('texts.user') }}</td> <td>{{ trans('texts.user') }}</td>
@endif @endif