mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for migrations Vendor Contacts
This commit is contained in:
parent
afcbb870bf
commit
6a54bb8c45
@ -227,6 +227,8 @@ class MigrationController extends BaseController
|
||||
|
||||
$account = auth()->user()->account;
|
||||
$company = (new ImportMigrations())->getCompany($account);
|
||||
$company->is_disabled = true;
|
||||
$company->save();
|
||||
|
||||
$account->default_company_id = $company->id;
|
||||
$account->save();
|
||||
@ -288,6 +290,9 @@ class MigrationController extends BaseController
|
||||
$account = auth()->user()->account;
|
||||
$company = (new ImportMigrations())->getCompany($account);
|
||||
|
||||
$company->is_disabled = true;
|
||||
$company->save();
|
||||
|
||||
$account->default_company_id = $company->id;
|
||||
$account->save();
|
||||
|
||||
@ -322,7 +327,10 @@ class MigrationController extends BaseController
|
||||
|
||||
$account = auth()->user()->account;
|
||||
$company = (new ImportMigrations())->getCompany($account);
|
||||
|
||||
|
||||
$company->is_disabled = true;
|
||||
$company->save();
|
||||
|
||||
$account->default_company_id = $company->id;
|
||||
$account->save();
|
||||
|
||||
@ -354,6 +362,10 @@ class MigrationController extends BaseController
|
||||
$account = auth()->user()->account;
|
||||
$company = (new ImportMigrations())->getCompany($account);
|
||||
|
||||
$company->is_disabled = true;
|
||||
$company->save();
|
||||
|
||||
|
||||
$company_token = new CompanyToken();
|
||||
$company_token->user_id = $user->id;
|
||||
$company_token->company_id = $company->id;
|
||||
|
@ -490,7 +490,7 @@ class Import implements ShouldQueue
|
||||
foreach ($modified_contacts as $key => $vendor_contacts) {
|
||||
$modified_contacts[$key]['company_id'] = $this->company->id;
|
||||
$modified_contacts[$key]['user_id'] = $this->processUserId($resource);
|
||||
$modified_contacts[$key]['client_id'] = $vendor->id;
|
||||
$modified_contacts[$key]['vendor_id'] = $vendor->id;
|
||||
$modified_contacts[$key]['password'] = 'mysuperpassword'; // @todo, and clean up the code..
|
||||
unset($modified_contacts[$key]['id']);
|
||||
}
|
||||
@ -1138,7 +1138,9 @@ class Import implements ShouldQueue
|
||||
|
||||
if(isset($resource['project_id']))
|
||||
$modified['project_id'] = $this->transformId('projects', $resource['project_id']);
|
||||
// $modified['vendor_id'] = $this->transformId('vendors', $resource['vendor_id']);
|
||||
|
||||
if(isset($resource['vendor_id']))
|
||||
$modified['vendor_id'] = $this->transformId('vendors', $resource['vendor_id']);
|
||||
|
||||
$expense = Expense::Create($modified);
|
||||
|
||||
|
@ -74,6 +74,7 @@ class VendorContact extends Authenticatable implements HasLocalePreference
|
||||
'custom_value4',
|
||||
'email',
|
||||
'is_primary',
|
||||
'vendor_id',
|
||||
];
|
||||
|
||||
public function getEntityType()
|
||||
|
@ -23,7 +23,7 @@ class VendorContactRepository extends BaseRepository
|
||||
{
|
||||
public $is_primary;
|
||||
|
||||
public function save($contacts, Vendor $vendor) : void
|
||||
public function save(array $data, Vendor $vendor) : void
|
||||
{
|
||||
|
||||
if (isset($data['contacts'])) {
|
||||
@ -65,9 +65,7 @@ class VendorContactRepository extends BaseRepository
|
||||
$update_contact->fill($contact);
|
||||
|
||||
if (array_key_exists('password', $contact) && strlen($contact['password']) > 1) {
|
||||
|
||||
$update_contact->password = Hash::make($contact['password']);
|
||||
|
||||
}
|
||||
|
||||
$update_contact->save();
|
||||
@ -76,7 +74,7 @@ class VendorContactRepository extends BaseRepository
|
||||
$vendor->load('contacts');
|
||||
|
||||
//always made sure we have one blank contact to maintain state
|
||||
if ($contacts->count() == 0) {
|
||||
if ($vendor->contacts->count() == 0) {
|
||||
$new_contact = new VendorContact;
|
||||
$new_contact->vendor_id = $vendor->id;
|
||||
$new_contact->company_id = $vendor->company_id;
|
||||
|
@ -70,7 +70,7 @@ class VendorRepository extends BaseRepository
|
||||
$vendor->save();
|
||||
|
||||
if (isset($data['contacts'])) {
|
||||
$contacts = $this->contact_repo->save($data['contacts'], $vendor);
|
||||
$contacts = $this->contact_repo->save($data, $vendor);
|
||||
}
|
||||
|
||||
if (empty($data['name'])) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user