Fix countries for documents #1p66u4u
This commit is contained in:
parent
4f1146dc33
commit
d9d0e09e3a
@ -19,6 +19,7 @@ class Bills extends Export implements WithColumnFormatting
|
|||||||
$model->category_name = $model->category->name;
|
$model->category_name = $model->category->name;
|
||||||
$model->bill_number = $model->document_number;
|
$model->bill_number = $model->document_number;
|
||||||
$model->billed_at = $model->issued_at;
|
$model->billed_at = $model->issued_at;
|
||||||
|
$model->contact_country = ($model->contact_country) ? trans('countries.' . $model->contact_country) : null;
|
||||||
|
|
||||||
return parent::map($model);
|
return parent::map($model);
|
||||||
}
|
}
|
||||||
@ -40,6 +41,10 @@ class Bills extends Export implements WithColumnFormatting
|
|||||||
'contact_tax_number',
|
'contact_tax_number',
|
||||||
'contact_phone',
|
'contact_phone',
|
||||||
'contact_address',
|
'contact_address',
|
||||||
|
'contact_country',
|
||||||
|
'contact_state',
|
||||||
|
'contact_zip_code',
|
||||||
|
'contact_city',
|
||||||
'notes',
|
'notes',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,13 @@ class Vendors extends Export
|
|||||||
return Model::vendor()->collectForExport($this->ids);
|
return Model::vendor()->collectForExport($this->ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function map($model): array
|
||||||
|
{
|
||||||
|
$model->country = ($model->country) ? trans('countries.' . $model->country) : null;
|
||||||
|
|
||||||
|
return parent::map($model);
|
||||||
|
}
|
||||||
|
|
||||||
public function fields(): array
|
public function fields(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -20,6 +27,10 @@ class Vendors extends Export
|
|||||||
'tax_number',
|
'tax_number',
|
||||||
'phone',
|
'phone',
|
||||||
'address',
|
'address',
|
||||||
|
'country',
|
||||||
|
'state',
|
||||||
|
'zip_code',
|
||||||
|
'city',
|
||||||
'website',
|
'website',
|
||||||
'currency_code',
|
'currency_code',
|
||||||
'reference',
|
'reference',
|
||||||
|
@ -12,6 +12,13 @@ class Customers extends Export
|
|||||||
return Model::customer()->collectForExport($this->ids);
|
return Model::customer()->collectForExport($this->ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function map($model): array
|
||||||
|
{
|
||||||
|
$model->country = ($model->country) ? trans('countries.' . $model->country) : null;
|
||||||
|
|
||||||
|
return parent::map($model);
|
||||||
|
}
|
||||||
|
|
||||||
public function fields(): array
|
public function fields(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -20,6 +27,10 @@ class Customers extends Export
|
|||||||
'tax_number',
|
'tax_number',
|
||||||
'phone',
|
'phone',
|
||||||
'address',
|
'address',
|
||||||
|
'country',
|
||||||
|
'state',
|
||||||
|
'zip_code',
|
||||||
|
'city',
|
||||||
'website',
|
'website',
|
||||||
'currency_code',
|
'currency_code',
|
||||||
'reference',
|
'reference',
|
||||||
|
@ -19,6 +19,7 @@ class Invoices extends Export implements WithColumnFormatting
|
|||||||
$model->category_name = $model->category->name;
|
$model->category_name = $model->category->name;
|
||||||
$model->invoice_number = $model->document_number;
|
$model->invoice_number = $model->document_number;
|
||||||
$model->invoiced_at = $model->issued_at;
|
$model->invoiced_at = $model->issued_at;
|
||||||
|
$model->contact_country = ($model->contact_country) ? trans('countries.' . $model->contact_country) : null;
|
||||||
|
|
||||||
return parent::map($model);
|
return parent::map($model);
|
||||||
}
|
}
|
||||||
@ -40,6 +41,10 @@ class Invoices extends Export implements WithColumnFormatting
|
|||||||
'contact_tax_number',
|
'contact_tax_number',
|
||||||
'contact_phone',
|
'contact_phone',
|
||||||
'contact_address',
|
'contact_address',
|
||||||
|
'contact_country',
|
||||||
|
'contact_state',
|
||||||
|
'contact_zip_code',
|
||||||
|
'contact_city',
|
||||||
'notes',
|
'notes',
|
||||||
'footer',
|
'footer',
|
||||||
];
|
];
|
||||||
|
@ -22,11 +22,14 @@ class Bills extends Import
|
|||||||
|
|
||||||
$row = parent::map($row);
|
$row = parent::map($row);
|
||||||
|
|
||||||
|
$country = array_search($row['contact_country'], trans('countries'));
|
||||||
|
|
||||||
$row['document_number'] = $row['bill_number'];
|
$row['document_number'] = $row['bill_number'];
|
||||||
$row['issued_at'] = $row['billed_at'];
|
$row['issued_at'] = $row['billed_at'];
|
||||||
$row['category_id'] = $this->getCategoryId($row, 'expense');
|
$row['category_id'] = $this->getCategoryId($row, 'expense');
|
||||||
$row['contact_id'] = $this->getContactId($row, 'vendor');
|
$row['contact_id'] = $this->getContactId($row, 'vendor');
|
||||||
$row['type'] = Model::BILL_TYPE;
|
$row['type'] = Model::BILL_TYPE;
|
||||||
|
$row['contact_country'] = !empty($country) ? $country : null;
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,10 @@ class Vendors extends Import
|
|||||||
{
|
{
|
||||||
$row = parent::map($row);
|
$row = parent::map($row);
|
||||||
|
|
||||||
|
$country = array_search($row['country'], trans('countries'));
|
||||||
|
|
||||||
$row['type'] = 'vendor';
|
$row['type'] = 'vendor';
|
||||||
|
$row['country'] = !empty($country) ? $country : null;
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,10 @@ class Customers extends Import
|
|||||||
{
|
{
|
||||||
$row = parent::map($row);
|
$row = parent::map($row);
|
||||||
|
|
||||||
|
$country = array_search($row['country'], trans('countries'));
|
||||||
|
|
||||||
$row['type'] = 'customer';
|
$row['type'] = 'customer';
|
||||||
|
$row['country'] = !empty($country) ? $country : null;
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,14 @@ class Invoices extends Import
|
|||||||
|
|
||||||
$row = parent::map($row);
|
$row = parent::map($row);
|
||||||
|
|
||||||
|
$country = array_search($row['contact_country'], trans('countries'));
|
||||||
|
|
||||||
$row['document_number'] = $row['invoice_number'];
|
$row['document_number'] = $row['invoice_number'];
|
||||||
$row['issued_at'] = $row['invoiced_at'];
|
$row['issued_at'] = $row['invoiced_at'];
|
||||||
$row['category_id'] = $this->getCategoryId($row, 'income');
|
$row['category_id'] = $this->getCategoryId($row, 'income');
|
||||||
$row['contact_id'] = $this->getContactId($row, 'customer');
|
$row['contact_id'] = $this->getContactId($row, 'customer');
|
||||||
$row['type'] = Model::INVOICE_TYPE;
|
$row['type'] = Model::INVOICE_TYPE;
|
||||||
|
$row['contact_country'] = !empty($country) ? $country : null;
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,6 @@ class Contact extends Model
|
|||||||
return $amount;
|
return $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getLocationAttribute()
|
public function getLocationAttribute()
|
||||||
{
|
{
|
||||||
$location = [];
|
$location = [];
|
||||||
|
@ -26,7 +26,7 @@ class Document extends Model
|
|||||||
|
|
||||||
protected $table = 'documents';
|
protected $table = 'documents';
|
||||||
|
|
||||||
protected $appends = ['attachment', 'amount_without_tax', 'discount', 'paid', 'received_at', 'status_label', 'sent_at', 'reconciled'];
|
protected $appends = ['attachment', 'amount_without_tax', 'discount', 'paid', 'received_at', 'status_label', 'sent_at', 'reconciled', 'contact_location'];
|
||||||
|
|
||||||
protected $dates = ['deleted_at', 'issued_at', 'due_at'];
|
protected $dates = ['deleted_at', 'issued_at', 'due_at'];
|
||||||
|
|
||||||
@ -48,6 +48,10 @@ class Document extends Model
|
|||||||
'contact_tax_number',
|
'contact_tax_number',
|
||||||
'contact_phone',
|
'contact_phone',
|
||||||
'contact_address',
|
'contact_address',
|
||||||
|
'contact_country',
|
||||||
|
'contact_state',
|
||||||
|
'contact_zip_code',
|
||||||
|
'contact_city',
|
||||||
'notes',
|
'notes',
|
||||||
'footer',
|
'footer',
|
||||||
'parent_id',
|
'parent_id',
|
||||||
@ -397,6 +401,29 @@ class Document extends Model
|
|||||||
return $value ?: 'sales.invoices.print_' . setting('invoice.template');
|
return $value ?: 'sales.invoices.print_' . setting('invoice.template');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getContactLocationAttribute()
|
||||||
|
{
|
||||||
|
$location = [];
|
||||||
|
|
||||||
|
if ($this->contact_city) {
|
||||||
|
$location[] = $this->contact_city;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->contact_zip_code) {
|
||||||
|
$location[] = $this->contact_zip_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->contact_state) {
|
||||||
|
$location[] = $this->contact_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->contact_country) {
|
||||||
|
$location[] = trans('countries.' . $this->contact_country);
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(', ', $location);
|
||||||
|
}
|
||||||
|
|
||||||
protected static function newFactory(): Factory
|
protected static function newFactory(): Factory
|
||||||
{
|
{
|
||||||
return DocumentFactory::new();
|
return DocumentFactory::new();
|
||||||
|
33
database/migrations/2021_09_10_000000_core_v2127.php
Normal file
33
database/migrations/2021_09_10_000000_core_v2127.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CoreV2127 extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('documents', function (Blueprint $table) {
|
||||||
|
$table->string('contact_country')->nullable()->after('contact_address');
|
||||||
|
$table->string('contact_state')->nullable()->after('contact_address');
|
||||||
|
$table->string('contact_zip_code')->nullable()->after('contact_address');
|
||||||
|
$table->string('contact_city')->nullable()->after('contact_address');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
4
resources/assets/js/mixins/global.js
vendored
4
resources/assets/js/mixins/global.js
vendored
@ -478,6 +478,10 @@ export default {
|
|||||||
this.form.contact_tax_number = (contact.tax_number) ? contact.tax_number : '';
|
this.form.contact_tax_number = (contact.tax_number) ? contact.tax_number : '';
|
||||||
this.form.contact_phone = (contact.phone) ? contact.phone : '';
|
this.form.contact_phone = (contact.phone) ? contact.phone : '';
|
||||||
this.form.contact_address = (contact.address) ? contact.address : '';
|
this.form.contact_address = (contact.address) ? contact.address : '';
|
||||||
|
this.form.contact_country = (contact.country) ? contact.country : '';
|
||||||
|
this.form.contact_state = (contact.state) ? contact.state : '';
|
||||||
|
this.form.contact_zip_code = (contact.zip_code) ? contact.zip_code : '';
|
||||||
|
this.form.contact_city = (contact.city) ? contact.city : '';
|
||||||
|
|
||||||
let currency_code = (contact.currency_code) ? contact.currency_code : this.form.currency_code;
|
let currency_code = (contact.currency_code) ? contact.currency_code : this.form.currency_code;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
<p>
|
<p>
|
||||||
{!! nl2br(setting('company.address')) !!}
|
{!! nl2br(setting('company.address')) !!}
|
||||||
<br>
|
<br>
|
||||||
{!! $document->company->location !!}
|
{!! $document->contact_location !!}
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@
|
|||||||
<p>
|
<p>
|
||||||
{!! nl2br($document->contact_address) !!}
|
{!! nl2br($document->contact_address) !!}
|
||||||
<br>
|
<br>
|
||||||
{!! $document->contact->location !!}
|
{!! $document->contact_location !!}
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
@stack('address_input_end')
|
@stack('address_input_end')
|
||||||
|
@ -89,7 +89,7 @@
|
|||||||
@if (!$hideContactAddress)
|
@if (!$hideContactAddress)
|
||||||
{!! nl2br($document->contact_address) !!}
|
{!! nl2br($document->contact_address) !!}
|
||||||
<br>
|
<br>
|
||||||
{!! $document->contact->location !!}
|
{!! $document->contact_location !!}
|
||||||
<br><br>
|
<br><br>
|
||||||
@endif
|
@endif
|
||||||
@stack('address_input_end')
|
@stack('address_input_end')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user