diff --git a/app/Abstracts/View/Components/DocumentTemplate.php b/app/Abstracts/View/Components/DocumentTemplate.php
index 6c7715862..9b9e6ab18 100644
--- a/app/Abstracts/View/Components/DocumentTemplate.php
+++ b/app/Abstracts/View/Components/DocumentTemplate.php
@@ -31,10 +31,6 @@ abstract class DocumentTemplate extends Base
public $logo;
- public $companyLocation;
-
- public $contactLocation;
-
public $backgroundColor;
public $hideFooter;
@@ -127,7 +123,7 @@ abstract class DocumentTemplate extends Base
* @return void
*/
public function __construct(
- $type, $document, $item = false, $documentTemplate = '', $logo = '', $backgroundColor = '', $companyLocation = '', $contactLocation = '',
+ $type, $document, $item = false, $documentTemplate = '', $logo = '', $backgroundColor = '',
bool $hideFooter = false, bool $hideCompanyLogo = false, bool $hideCompanyDetails = false,
bool $hideCompanyName = false, bool $hideCompanyAddress = false, bool $hideCompanyTaxNumber = false, bool $hideCompanyPhone = false, bool $hideCompanyEmail = false, bool $hideContactInfo = false,
bool $hideContactName = false, bool $hideContactAddress = false, bool $hideContactTaxNumber = false, bool $hideContactPhone = false, bool $hideContactEmail = false,
@@ -143,8 +139,6 @@ abstract class DocumentTemplate extends Base
$this->documentTemplate = $this->getDocumentTemplate($type, $documentTemplate);
$this->logo = $this->getLogo($logo);
$this->backgroundColor = $this->getBackgroundColor($type, $backgroundColor);
- $this->companyLocation = $this->getCompanyLocation();
- $this->contactLocation = $this->getContactLocation($document);
$this->hideFooter = $hideFooter;
$this->hideCompanyLogo = $hideCompanyLogo;
@@ -652,50 +646,4 @@ abstract class DocumentTemplate extends Base
// @todo what return value invoice or always false??
return setting('invoice.hide_amount', $hideAmount);
}
-
- protected function getCompanyLocation()
- {
- $location = [];
-
- if (setting('company.city')) {
- $location[] = setting('company.city');
- }
-
- if (setting('company.zip_code')) {
- $location[] = setting('company.zip_code');
- }
-
- if (setting('company.state')) {
- $location[] = setting('company.state');
- }
-
- if (setting('company.country')) {
- $location[] = trans('countries.' . setting('company.country'));
- }
-
- return implode(', ', $location);
- }
-
- protected function getContactLocation($document)
- {
- $location = [];
-
- if ($document->contact->city) {
- $location[] = $document->contact->city;
- }
-
- if ($document->contact->zip_code) {
- $location[] = $document->contact->zip_code;
- }
-
- if ($document->contact->state) {
- $location[] = $document->contact->state;
- }
-
- if ($document->contact->country) {
- $location[] = trans('countries.' . $document->contact->country);
- }
-
- return implode(', ', $location);
- }
}
diff --git a/app/Models/Common/Company.php b/app/Models/Common/Company.php
index 01650ba7e..231ecada2 100644
--- a/app/Models/Common/Company.php
+++ b/app/Models/Common/Company.php
@@ -25,6 +25,13 @@ class Company extends Eloquent implements Ownable
protected $table = 'companies';
+ /**
+ * The accessors to append to the model's array form.
+ *
+ * @var array
+ */
+ protected $appends = ['location'];
+
protected $dates = ['deleted_at'];
protected $fillable = ['domain', 'enabled', 'created_by'];
@@ -446,6 +453,29 @@ class Company extends Eloquent implements Ownable
return $this->getMedia('company.logo')->last();
}
+ public function getLocationAttribute()
+ {
+ $location = [];
+
+ if (setting('company.city')) {
+ $location[] = setting('company.city');
+ }
+
+ if (setting('company.zip_code')) {
+ $location[] = setting('company.zip_code');
+ }
+
+ if (setting('company.state')) {
+ $location[] = setting('company.state');
+ }
+
+ if (setting('company.country')) {
+ $location[] = trans('countries.' . setting('company.country'));
+ }
+
+ return implode(', ', $location);
+ }
+
public function makeCurrent($force = false)
{
if (!$force && $this->isCurrent()) {
diff --git a/app/Models/Common/Contact.php b/app/Models/Common/Contact.php
index 69b48eee7..3cc368952 100644
--- a/app/Models/Common/Contact.php
+++ b/app/Models/Common/Contact.php
@@ -19,6 +19,13 @@ class Contact extends Model
protected $table = 'contacts';
+ /**
+ * The accessors to append to the model's array form.
+ *
+ * @var array
+ */
+ protected $appends = ['location'];
+
/**
* Attributes that should be mass-assignable.
*
diff --git a/resources/assets/js/components/AkauntingCompanyEdit.vue b/resources/assets/js/components/AkauntingCompanyEdit.vue
index 4f71cce8f..b011b5385 100644
--- a/resources/assets/js/components/AkauntingCompanyEdit.vue
+++ b/resources/assets/js/components/AkauntingCompanyEdit.vue
@@ -13,9 +13,9 @@
{{ company.address }}
-
+
- {{ company_data.locations }}
+ {{ company.location }}
|
@@ -60,18 +60,18 @@ import Form from './../plugins/form';
export default {
name: 'akaunting-company-edit',
- components: {
- [Select.name]: Select,
- [Option.name]: Option,
- [OptionGroup.name]: OptionGroup,
- [ColorPicker.name]: ColorPicker,
- AkauntingModalAddNew,
- AkauntingModal,
- AkauntingMoney,
- AkauntingRadioGroup,
- AkauntingSelect,
- AkauntingDate,
- },
+ components: {
+ [Select.name]: Select,
+ [Option.name]: Option,
+ [OptionGroup.name]: OptionGroup,
+ [ColorPicker.name]: ColorPicker,
+ AkauntingModalAddNew,
+ AkauntingModal,
+ AkauntingMoney,
+ AkauntingRadioGroup,
+ AkauntingSelect,
+ AkauntingDate,
+ },
props: {
buttonText: {
@@ -94,9 +94,6 @@ export default {
default: {},
description: 'Company object'
},
- countryText: {
- type: [Array, Object],
- },
companyForm: {
type: Object,
default: function () {
@@ -120,7 +117,6 @@ export default {
buttons: this.companyForm.buttons,
},
company_html: '',
- company_data: this.company,
};
},
@@ -247,27 +243,5 @@ export default {
documentClasses.remove("modal-open");
},
},
-
- created() {
- let locations = [];
-
- if (this.company.city) {
- locations.push(this.company.city);
- }
-
- if (this.company.zip_code) {
- locations.push(this.company.zip_code);
- }
-
- if (this.company.state) {
- locations.push(this.company.state);
- }
-
- if (this.company.country) {
- locations.push(this.countryText[this.company.country])
- }
-
- this.company.locations = locations.join(', ');
- },
};
diff --git a/resources/assets/js/components/AkauntingContactCard.vue b/resources/assets/js/components/AkauntingContactCard.vue
index 99a37887f..b170c48a5 100644
--- a/resources/assets/js/components/AkauntingContactCard.vue
+++ b/resources/assets/js/components/AkauntingContactCard.vue
@@ -88,9 +88,9 @@
{{ contact.address }}
-
+
- {{ contact.locations }}
+ {{ contact.location }}
|
@@ -197,7 +197,7 @@ export default {
zip_code:'',
state:'',
country:'',
- country_name:'',
+ location:'',
reference: ''
};
},
@@ -241,10 +241,6 @@ export default {
default: 'Bill to',
description: ""
},
- countryText: {
- type: [Array, Object],
- default: () => [],
- },
taxNumberText: {
type: String,
default: 'Tax number',
@@ -284,7 +280,6 @@ export default {
buttons: this.addNew.buttons,
},
add_new_html: '',
- country_text_data: this.countryText,
};
},
@@ -315,7 +310,7 @@ export default {
zip_code: '',
state: '',
country: '',
- countryname: '',
+ location: '',
reference: ''
});
},
@@ -345,7 +340,7 @@ export default {
zip_code: (contact.zip_code) ? contact.zip_code : '',
state: (contact.state) ? contact.state : '',
country: (contact.country) ? contact.country : '',
- country_name: (contact.country_name) ? contact.country_name : '',
+ location: (contact.location) ? contact.location : '',
reference: (contact.reference) ? contact.reference : ''
});
}, this);
@@ -361,26 +356,6 @@ export default {
this.contact_list.forEach(function (contact, index) {
if (contact_id == contact.id) {
this.contact = contact;
-
- let locations = [];
-
- if (this.contact.city) {
- locations.push(this.contact.city);
- }
-
- if (this.contact.zip_code) {
- locations.push(this.contact.zip_code);
- }
-
- if (this.contact.state) {
- locations.push(this.contact.state);
- }
-
- if (this.contact.country) {
- locations.push(this.country_text_data[this.contact.country]);
- }
-
- this.contact.locations = locations.join(', ');
}
}, this);
@@ -616,7 +591,7 @@ export default {
zip_code: '',
state: '',
country: '',
- country_name: '',
+ location: '',
reference: ''
});
@@ -641,30 +616,9 @@ export default {
zip_code: (contact.zip_code) ? contact.zip_code : '',
state: (contact.state) ? contact.state : '',
country: (contact.country) ? contact.country : '',
- country_name: (contact.country_name) ? contact.country_name : '',
+ location: (contact.location) ? contact.location : '',
reference: (contact.reference) ? contact.reference : ''
});
-
- let locations = [];
-
- if (contact.city) {
- locations.push(contact.city);
- }
-
- if (contact.zip_code) {
- locations.push(contact.zip_code);
- }
-
- if (contact.state) {
- locations.push(contact.state);
- }
-
- if (contact.country) {
- locations.push(this.country_text_data[contact.country])
- }
-
- this.contact.locations = locations.join(', ');
-
}, this);
}
diff --git a/resources/views/components/documents/form/company.blade.php b/resources/views/components/documents/form/company.blade.php
index 41d022d9c..c43a1aa14 100644
--- a/resources/views/components/documents/form/company.blade.php
+++ b/resources/views/components/documents/form/company.blade.php
@@ -26,7 +26,6 @@
{!! nl2br(setting('company.address')) !!}
- {!! $companyLocation !!}
+ {!! $document->company->location !!}
@endif
@@ -89,7 +89,7 @@
@if (!$hideContactAddress)
{!! nl2br($document->contact_address) !!}
- {!! $contactLocation !!}
+ {!! $document->contact->location !!}
@endif
@stack('address_input_end')
diff --git a/resources/views/components/select-contact-card.blade.php b/resources/views/components/select-contact-card.blade.php
index 82251ef6b..f242e1ec8 100644
--- a/resources/views/components/select-contact-card.blade.php
+++ b/resources/views/components/select-contact-card.blade.php
@@ -4,7 +4,6 @@
no-matching-data-text="{{ trans('general.no_matching_data') }}"
search-route="{{ $search_route }}"
create-route="{{ $create_route }}"
- :country-text="{{ json_encode(trans('countries')) }}"
:contacts="{{ json_encode($contacts) }}"
:selected="{{ json_encode($contact) }}"
add-contact-text="{{ is_array($textAddContact) ? trans($textAddContact[0], ['field' => trans_choice($textAddContact[1], 1)]) : trans($textAddContact) }}"