Merge branch 'master' of github.com:mervekaraman/akaunting
This commit is contained in:
commit
ac75c3e279
@ -48,13 +48,18 @@ abstract class Export implements FromCollection, HasLocalePreference, ShouldAuto
|
|||||||
{
|
{
|
||||||
$map = [];
|
$map = [];
|
||||||
|
|
||||||
$date_fields = ['paid_at', 'invoiced_at', 'billed_at', 'due_at', 'issued_at', 'created_at', 'transferred_at'];
|
$date_fields = ['paid_at', 'invoiced_at', 'billed_at', 'due_at', 'issued_at', 'transferred_at'];
|
||||||
|
|
||||||
$evil_chars = ['=', '+', '-', '@'];
|
$evil_chars = ['=', '+', '-', '@'];
|
||||||
|
|
||||||
foreach ($this->fields as $field) {
|
foreach ($this->fields as $field) {
|
||||||
$value = $model->$field;
|
$value = $model->$field;
|
||||||
|
|
||||||
|
// created_by is equal to the owner id. Therefore, the value in export is owner email.
|
||||||
|
if ($field == 'created_by') {
|
||||||
|
$value = $model->owner->email ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array($field, $date_fields)) {
|
if (in_array($field, $date_fields)) {
|
||||||
$value = ExcelDate::PHPToExcel(Date::parse($value)->format('Y-m-d'));
|
$value = ExcelDate::PHPToExcel(Date::parse($value)->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,12 @@ abstract class Import implements HasLocalePreference, ShouldQueue, SkipsEmptyRow
|
|||||||
public function map($row): array
|
public function map($row): array
|
||||||
{
|
{
|
||||||
$row['company_id'] = company_id();
|
$row['company_id'] = company_id();
|
||||||
$row['created_by'] = $this->user->id;
|
|
||||||
|
// created_by is equal to the owner id. Therefore, the value in export is owner email.
|
||||||
|
if (isset($row['created_by'])) {
|
||||||
|
$row['created_by'] = $this->getCreatedById($row);
|
||||||
|
}
|
||||||
|
|
||||||
$row['created_from'] = $this->getSourcePrefix() . 'import';
|
$row['created_from'] = $this->getSourcePrefix() . 'import';
|
||||||
|
|
||||||
// Make enabled field integer
|
// Make enabled field integer
|
||||||
|
@ -22,6 +22,8 @@ class Customers extends Export
|
|||||||
|
|
||||||
$model->country = $country;
|
$model->country = $country;
|
||||||
|
|
||||||
|
$model->can_login = $model->user_id ? true : false;
|
||||||
|
|
||||||
return parent::map($model);
|
return parent::map($model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,6 +43,7 @@ class Customers extends Export
|
|||||||
'currency_code',
|
'currency_code',
|
||||||
'reference',
|
'reference',
|
||||||
'enabled',
|
'enabled',
|
||||||
|
'can_login',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,10 @@ class Transfers extends Import
|
|||||||
return [
|
return [
|
||||||
'from_account_id' => 'required|integer',
|
'from_account_id' => 'required|integer',
|
||||||
'from_currency_code' => 'required|string|currency',
|
'from_currency_code' => 'required|string|currency',
|
||||||
'from_currency_rate' => 'required',
|
'from_currency_rate' => 'required|gt:0',
|
||||||
'to_account_id' => 'required|integer',
|
'to_account_id' => 'required|integer',
|
||||||
'to_currency_code' => 'required|string|currency',
|
'to_currency_code' => 'required|string|currency',
|
||||||
'to_currency_rate' => 'required',
|
'to_currency_rate' => 'required|gt:0',
|
||||||
'amount' => 'required|amount',
|
'amount' => 'required|amount',
|
||||||
'transferred_at' => 'required|date_format:Y-m-d',
|
'transferred_at' => 'required|date_format:Y-m-d',
|
||||||
'payment_method' => 'required|string',
|
'payment_method' => 'required|string',
|
||||||
|
@ -43,7 +43,7 @@ class Bills extends Import
|
|||||||
{
|
{
|
||||||
$rules['bill_number'] = Str::replaceFirst('unique:documents,NULL', 'unique:documents,document_number', $rules['document_number']);
|
$rules['bill_number'] = Str::replaceFirst('unique:documents,NULL', 'unique:documents,document_number', $rules['document_number']);
|
||||||
$rules['billed_at'] = $rules['issued_at'];
|
$rules['billed_at'] = $rules['issued_at'];
|
||||||
$rules['currency_rate'] = 'required';
|
$rules['currency_rate'] = 'required|gt:0';
|
||||||
|
|
||||||
unset($rules['document_number'], $rules['issued_at'], $rules['type']);
|
unset($rules['document_number'], $rules['issued_at'], $rules['type']);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Imports\Sales;
|
namespace App\Imports\Sales;
|
||||||
|
|
||||||
use App\Abstracts\Import;
|
use App\Abstracts\Import;
|
||||||
|
use App\Models\Auth\User;
|
||||||
use App\Http\Requests\Common\Contact as Request;
|
use App\Http\Requests\Common\Contact as Request;
|
||||||
use App\Models\Common\Contact as Model;
|
use App\Models\Common\Contact as Model;
|
||||||
|
|
||||||
@ -26,6 +27,10 @@ class Customers extends Import
|
|||||||
$row['currency_code'] = $this->getCurrencyCode($row);
|
$row['currency_code'] = $this->getCurrencyCode($row);
|
||||||
$row['user_id'] = null;
|
$row['user_id'] = null;
|
||||||
|
|
||||||
|
if (isset($row['can_login']) && isset($row['email'])) {
|
||||||
|
$row['user_id'] = User::where('email', $row['email'])->first()?->id ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class Invoices extends Import
|
|||||||
{
|
{
|
||||||
$rules['invoice_number'] = Str::replaceFirst('unique:documents,NULL', 'unique:documents,document_number', $rules['document_number']);
|
$rules['invoice_number'] = Str::replaceFirst('unique:documents,NULL', 'unique:documents,document_number', $rules['document_number']);
|
||||||
$rules['invoiced_at'] = $rules['issued_at'];
|
$rules['invoiced_at'] = $rules['issued_at'];
|
||||||
$rules['currency_rate'] = 'required';
|
$rules['currency_rate'] = 'required|gt:0';
|
||||||
|
|
||||||
unset($rules['document_number'], $rules['issued_at'], $rules['type']);
|
unset($rules['document_number'], $rules['issued_at'], $rules['type']);
|
||||||
|
|
||||||
|
@ -538,17 +538,29 @@ class Document extends Model
|
|||||||
|
|
||||||
if ($this->status != 'paid' && (empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) {
|
if ($this->status != 'paid' && (empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) {
|
||||||
try {
|
try {
|
||||||
$actions[] = [
|
if ($this->totals->count()) {
|
||||||
'type' => 'button',
|
$actions[] = [
|
||||||
'title' => trans('invoices.add_payment'),
|
'type' => 'button',
|
||||||
'icon' => 'paid',
|
'title' => trans('invoices.add_payment'),
|
||||||
'url' => route('modals.documents.document.transactions.create', $this->id),
|
'icon' => 'paid',
|
||||||
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
'url' => route('modals.documents.document.transactions.create', $this->id),
|
||||||
'attributes' => [
|
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||||
'id' => 'index-line-actions-payment-' . $this->type . '-' . $this->id,
|
'attributes' => [
|
||||||
'@click' => 'onAddPayment("' . route('modals.documents.document.transactions.create', $this->id) . '")',
|
'id' => 'index-line-actions-payment-' . $this->type . '-' . $this->id,
|
||||||
],
|
'@click' => 'onAddPayment("' . route('modals.documents.document.transactions.create', $this->id) . '")',
|
||||||
];
|
],
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$actions[] = [
|
||||||
|
'type' => 'button',
|
||||||
|
'title' => trans('invoices.messages.totals_required', ['type' => $this->type]),
|
||||||
|
'icon' => 'paid',
|
||||||
|
'permission' => 'read-' . $group . '-' . $permission_prefix,
|
||||||
|
'attributes' => [
|
||||||
|
"disabled" => "disabled",
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
} catch (\Exception $e) {}
|
} catch (\Exception $e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ use App\Jobs\Common\CreateItem;
|
|||||||
use App\Jobs\Setting\CreateCategory;
|
use App\Jobs\Setting\CreateCategory;
|
||||||
use App\Jobs\Setting\CreateCurrency;
|
use App\Jobs\Setting\CreateCurrency;
|
||||||
use App\Jobs\Setting\CreateTax;
|
use App\Jobs\Setting\CreateTax;
|
||||||
|
use App\Models\Auth\User;
|
||||||
use App\Models\Banking\Account;
|
use App\Models\Banking\Account;
|
||||||
use App\Models\Common\Contact;
|
use App\Models\Common\Contact;
|
||||||
use App\Models\Common\Item;
|
use App\Models\Common\Item;
|
||||||
@ -110,6 +111,17 @@ trait Import
|
|||||||
return $currency->code;
|
return $currency->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCreatedById($row)
|
||||||
|
{
|
||||||
|
$user = User::where('email', $row['created_by'])->first();
|
||||||
|
|
||||||
|
if (! empty($user)) {
|
||||||
|
return $user->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->user->id;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDocumentId($row)
|
public function getDocumentId($row)
|
||||||
{
|
{
|
||||||
$id = isset($row['document_id']) ? $row['document_id'] : null;
|
$id = isset($row['document_id']) ? $row['document_id'] : null;
|
||||||
|
@ -50,6 +50,8 @@ return [
|
|||||||
|
|
||||||
'messages' => [
|
'messages' => [
|
||||||
'email_required' => 'No email address for this customer!',
|
'email_required' => 'No email address for this customer!',
|
||||||
|
'totals_required' => 'Invoice totals are required Please edit the :type and save it again.',
|
||||||
|
|
||||||
'draft' => 'This is a <b>DRAFT</b> invoice and will be reflected to charts after it gets sent.',
|
'draft' => 'This is a <b>DRAFT</b> invoice and will be reflected to charts after it gets sent.',
|
||||||
|
|
||||||
'status' => [
|
'status' => [
|
||||||
|
@ -34,6 +34,10 @@
|
|||||||
@if ($document->status == 'draft')
|
@if ($document->status == 'draft')
|
||||||
<x-documents.show.message type="status" background-color="bg-red-100" text-color="text-red-600" message="{!! trans($textStatusMessage) !!}" />
|
<x-documents.show.message type="status" background-color="bg-red-100" text-color="text-red-600" message="{!! trans($textStatusMessage) !!}" />
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if (! $document->totals->count())
|
||||||
|
<x-documents.show.message type="status" background-color="bg-red-100" text-color="text-red-600" message="{!! trans('invoices.messages.totals_required', ['type' => $type]) !!}" />
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@stack('status_message_end')
|
@stack('status_message_end')
|
||||||
|
@ -11,15 +11,23 @@
|
|||||||
@stack('timeline_get_paid_body_button_payment_start')
|
@stack('timeline_get_paid_body_button_payment_start')
|
||||||
|
|
||||||
@if (! $hideAddPayment)
|
@if (! $hideAddPayment)
|
||||||
@if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)))
|
@if ($document->totals->count())
|
||||||
<x-button
|
@if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)))
|
||||||
@click="onAddPayment('{{ route('modals.documents.document.transactions.create', $document->id) }}')"
|
<x-button
|
||||||
id="show-slider-actions-payment-{{ $document->type }}"
|
@click="onAddPayment('{{ route('modals.documents.document.transactions.create', $document->id) }}')"
|
||||||
class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
|
id="show-slider-actions-payment-{{ $document->type }}"
|
||||||
override="class"
|
class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
|
||||||
>
|
override="class"
|
||||||
{{ trans('invoices.add_payment') }}
|
>
|
||||||
</x-button>
|
{{ trans('invoices.add_payment') }}
|
||||||
|
</x-button>
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
<x-tooltip message="{{ trans('invoices.messages.totals_required', ['type' => $type]) }}" placement="top">
|
||||||
|
<x-dropdown.button disabled="disabled">
|
||||||
|
{{ trans('invoices.add_payment') }}
|
||||||
|
</x-dropdown.button>
|
||||||
|
</x-tooltip>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@ -11,15 +11,23 @@
|
|||||||
@stack('timeline_get_paid_body_button_payment_start')
|
@stack('timeline_get_paid_body_button_payment_start')
|
||||||
|
|
||||||
@if (! $hideAddPayment)
|
@if (! $hideAddPayment)
|
||||||
@if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)) )
|
@if ($document->totals->count())
|
||||||
<x-button
|
@if ($document->status != 'paid' && (empty($document->transactions->count()) || (! empty($document->transactions->count()) && $document->paid != $document->amount)) )
|
||||||
@click="onAddPayment('{{ route('modals.documents.document.transactions.create', $document->id) }}')"
|
<x-button
|
||||||
id="show-slider-actions-payment-{{ $document->type }}"
|
@click="onAddPayment('{{ route('modals.documents.document.transactions.create', $document->id) }}')"
|
||||||
class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
|
id="show-slider-actions-payment-{{ $document->type }}"
|
||||||
override="class"
|
class="px-3 py-1.5 mb-3 sm:mb-0 rounded-lg text-xs font-medium leading-6 bg-green hover:bg-green-700 text-white disabled:bg-green-100"
|
||||||
>
|
override="class"
|
||||||
{{ trans('invoices.add_payment') }}
|
>
|
||||||
</x-button>
|
{{ trans('invoices.add_payment') }}
|
||||||
|
</x-button>
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
<x-tooltip message="{{ trans('invoices.messages.totals_required', ['type' => $type]) }}" placement="top">
|
||||||
|
<x-button disabled="disabled">
|
||||||
|
{{ trans('invoices.add_payment') }}
|
||||||
|
</x-button>
|
||||||
|
</x-tooltip>
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user