Merge pull request #1742 from cuneytsenturk/master

Add Document/Transaction/Contact types to the config vol 2
This commit is contained in:
Cüneyt Şentürk 2021-01-12 00:28:19 +03:00 committed by GitHub
commit de27dbf116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 1456 additions and 1093 deletions

View File

@ -0,0 +1,175 @@
<?php
namespace App\Abstracts\View\Components;
use Illuminate\View\Component;
use Illuminate\Support\Str;
abstract class Document extends Component
{
public function getTextFromConfig($type, $config_key, $default_key = '', $trans_type = 'trans')
{
$translation = '';
// if set config trasnlation config_key
if ($translation = config('type.' . $type . '.translation.' . $config_key)) {
return $translation;
}
$alias = config('type.' . $type . '.alias');
$prefix = config('type.' . $type . '.translation.prefix');
if (!empty($alias)) {
$alias .= '::';
}
// This magic trans key..
$translations = [
'general' => $alias . 'general.' . $default_key,
'prefix' => $alias . $prefix . '.' . $default_key,
'config_general' => $alias . 'general.' . $config_key,
'config_prefix' => $alias . $prefix . '.' . $config_key,
];
switch ($trans_type) {
case 'trans':
foreach ($translations as $trans) {
if (trans($trans) !== $trans) {
return $trans;
}
}
break;
case 'trans_choice':
foreach ($translations as $trans_choice) {
if (trans_choice($trans_choice, 1) !== $trans_choice) {
return $trans_choice;
}
}
break;
}
return $translation;
}
public function getRouteFromConfig($type, $config_key, $config_parameters = [])
{
$route = '';
// if set config trasnlation config_key
if ($route = config('type.' . $type . '.route.' . $config_key)) {
return $route;
}
$alias = config('type.' . $type . '.alias');
$prefix = config('type.' . $type . '.route.prefix');
// if use module set module alias
if (!empty($alias)) {
$route .= $alias . '.';
}
if (!empty($prefix)) {
$route .= $prefix . '.';
}
$route .= $config_key;
try {
route($route, $config_parameters);
} catch (\Exception $e) {
try {
$route = Str::plural($type, 2) . '.' . $config_key;
route($route, $config_parameters);
} catch (\Exception $e) {
$route = '';
}
}
return $route;
}
public function getPermissionFromConfig($type, $config_key)
{
$permission = '';
// if set config trasnlation config_key
if ($permission = config('type.' . $type . '.permission.' . $config_key)) {
return $permission;
}
$alias = config('type.' . $type . '.alias');
$group = config('type.' . $type . '.group');
$prefix = config('type.' . $type . '.permission.prefix');
$permission = $config_key . '-';
// if use module set module alias
if (!empty($alias)) {
$permission .= $alias . '-';
}
// if controller in folder it must
if (!empty($group)) {
$permission .= $group . '-';
}
$permission .= $prefix;
return $permission;
}
public function getHideFromConfig($type, $config_key)
{
$hide = false;
$hides = config('type.' . $type . '.hide');
if (!empty($hides) && (in_array($config_key, $hides))) {
$hide = true;
}
return $hide;
}
public function getClassFromConfig($type, $config_key)
{
$class_key = 'type.' . $type . '.class.' . $config_key;
return config($class_key, '');
}
public function getCategoryFromConfig($type)
{
$category_type = '';
// if set config trasnlation config_key
if ($category_type = config('type.' . $type . '.category_type')) {
return $category_type;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$category_type = 'expense';
break;
case 'item':
$category_type = 'item';
break;
case 'other':
$category_type = 'other';
break;
case 'transfer':
$category_type = 'transfer';
break;
default:
$category_type = 'income';
break;
}
return $category_type;
}
}

View File

@ -2,13 +2,14 @@
namespace App\Abstracts\View\Components; namespace App\Abstracts\View\Components;
use App\Abstracts\View\Components\Document as Base;
use App\Models\Common\Contact; use App\Models\Common\Contact;
use App\Models\Document\Document; use App\Models\Document\Document;
use App\Traits\Documents; use App\Traits\Documents;
use Date; use Date;
use Illuminate\View\Component;
use Illuminate\Support\Str; use Illuminate\Support\Str;
abstract class DocumentForm extends Component
abstract class DocumentForm extends Base
{ {
use Documents; use Documents;
@ -17,6 +18,9 @@ abstract class DocumentForm extends Component
public $document; public $document;
/** Advanced Component Start */ /** Advanced Component Start */
/** @var string */
public $categoryType;
/** @var bool */ /** @var bool */
public $hideRecurring; public $hideRecurring;
@ -43,7 +47,13 @@ abstract class DocumentForm extends Component
/** Content Component Start */ /** Content Component Start */
/** @var string */ /** @var string */
public $formRoute; public $routeStore;
/** @var string */
public $routeUpdate;
/** @var string */
public $routeCancel;
/** @var string */ /** @var string */
public $formId; public $formId;
@ -185,13 +195,13 @@ abstract class DocumentForm extends Component
public function __construct( public function __construct(
$type, $document = false, $type, $document = false,
/** Advanced Component Start */ /** Advanced Component Start */
bool $hideRecurring = false, bool $hideCategory = false, bool $hideAttachment = false, string $categoryType = '', bool $hideRecurring = false, bool $hideCategory = false, bool $hideAttachment = false,
/** Advanced Component End */ /** Advanced Component End */
/** Company Component Start */ /** Company Component Start */
bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false, bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false,
/** Company Component End */ /** Company Component End */
/** Content Component Start */ /** Content Component Start */
string $formRoute = '', string $formId = 'document', string $formSubmit = 'onSubmit', string $routeStore = '', string $routeUpdate = '', string $formId = 'document', string $formSubmit = 'onSubmit', string $routeCancel = '',
bool $hideCompany = false, bool $hideAdvanced = false, bool $hideFooter = false, bool $hideButtons = false, bool $hideCompany = false, bool $hideAdvanced = false, bool $hideFooter = false, bool $hideButtons = false,
/** Content Component End */ /** Content Component End */
/** Metadata Component Start */ /** Metadata Component Start */
@ -213,6 +223,7 @@ abstract class DocumentForm extends Component
$this->document = $document; $this->document = $document;
/** Advanced Component Start */ /** Advanced Component Start */
$this->categoryType = $this->getCategoryType($type, $categoryType);
$this->hideRecurring = $hideRecurring; $this->hideRecurring = $hideRecurring;
$this->hideCategory = $hideCategory; $this->hideCategory = $hideCategory;
$this->hideAttachment = $hideAttachment; $this->hideAttachment = $hideAttachment;
@ -226,7 +237,9 @@ abstract class DocumentForm extends Component
/** Company Component End */ /** Company Component End */
/** Content Component Start */ /** Content Component Start */
$this->formRoute = ($formRoute) ? $formRoute : $this->getRoute($type, $document); $this->routeStore = $this->getRouteStore($type, $routeStore);
$this->routeUpdate = $this->getRouteUpdate($type, $routeUpdate, $document);
$this->routeCancel = $this->getRouteCancel($type, $routeCancel);
$this->formId = $formId; $this->formId = $formId;
$this->formSubmit = $formSubmit; $this->formSubmit = $formSubmit;
@ -283,29 +296,71 @@ abstract class DocumentForm extends Component
/** Items Component End */ /** Items Component End */
} }
protected function getRoute($type, $document, $parameters = []) protected function getRouteStore($type, $routeStore)
{ {
$page = config("type.{$type}.route_name"); if (!empty($routeStore)) {
return $routeStore;
}
$route = $page . '.store'; $route = $this->getRouteFromConfig($type, 'store');
if (!empty($route)) {
return $route;
}
return 'invoices.store';
}
protected function getRouteUpdate($type, $routeUpdate, $document, $parameters = [])
{
if (!empty($routeUpdate)) {
return $routeUpdate;
}
if ($document) {
$parameters = [ $parameters = [
config("type.{$type}.route_parameter") => $document->id config('type.' . $type. '.route.parameter') => ($document) ? $document->id : 1,
]; ];
$route = $page . '.update'; $route = $this->getRouteFromConfig($type, 'update', $parameters);
}
try {
route($route, $parameters);
} catch (\Exception $e) {
$route = '';
}
if (!empty($route)) {
return $route; return $route;
} }
return 'invoices.update';
}
protected function getRouteCancel($type, $routeCancel)
{
if (!empty($routeCancel)) {
return $routeCancel;
}
$route = $this->getRouteFromConfig($type, 'index');
if (!empty($route)) {
return $route;
}
return 'invoices.index';
}
protected function getCategoryType($type, $categoryType)
{
if (!empty($categoryType)) {
return $categoryType;
}
if ($category_type = config('type.' . $type . '.category_type')) {
return $category_type;
}
// set default type
$type = Document::INVOICE_TYPE;
return config('type.' . $type . '.category_type');
}
protected function getContacts($type, $contacts) protected function getContacts($type, $contacts)
{ {
if (!empty($contacts)) { if (!empty($contacts)) {
@ -338,13 +393,20 @@ abstract class DocumentForm extends Component
return $contact; return $contact;
} }
protected function getContactType($type, $contact_type) protected function getContactType($type, $contactType)
{ {
if (!empty($contact_type)) { if (!empty($contactType)) {
return $contactType;
}
if ($contact_type = config('type.' . $type . '.contact_type')) {
return $contact_type; return $contact_type;
} }
return config("type.{$type}.contact_type"); // set default type
$type = Document::INVOICE_TYPE;
return config('type.' . $type . '.contact_type');
} }
protected function getTextAddContact($type, $textAddContact) protected function getTextAddContact($type, $textAddContact)
@ -353,24 +415,21 @@ abstract class DocumentForm extends Component
return $textAddContact; return $textAddContact;
} }
switch ($type) { $default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
case 'bill':
case 'expense': $translation = $this->getTextFromConfig($type, 'add_contact', $default_key, 'trans_choice');
case 'purchase':
$textAddContact = [ if (!empty($translation)) {
return [
'general.form.add', 'general.form.add',
'general.vendors' $translation,
]; ];
break;
default:
$textAddContact = [
'general.form.add',
'general.customers'
];
break;
} }
return $textAddContact; return [
'general.form.add',
'general.customers',
];
} }
protected function getTextCreateNewContact($type, $textCreateNewContact) protected function getTextCreateNewContact($type, $textCreateNewContact)
@ -379,24 +438,21 @@ abstract class DocumentForm extends Component
return $textCreateNewContact; return $textCreateNewContact;
} }
switch ($type) { $default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
case 'bill':
case 'expense': $translation = $this->getTextFromConfig($type, 'create_new_contact', $default_key, 'trans_choice');
case 'purchase':
$textCreateNewContact = [ if (!empty($translation)) {
return [
'general.form.add_new', 'general.form.add_new',
'general.vendors' $translation,
]; ];
break;
default:
$textCreateNewContact = [
'general.form.add_new',
'general.customers'
];
break;
} }
return $textCreateNewContact; return [
'general.form.add_new',
'general.customers',
];
} }
protected function getTextEditContact($type, $textEditContact) protected function getTextEditContact($type, $textEditContact)
@ -405,18 +461,13 @@ abstract class DocumentForm extends Component
return $textEditContact; return $textEditContact;
} }
switch ($type) { $translation = $this->getTextFromConfig($type, 'edit_contact', 'form.edit');
case 'bill':
case 'expense': if (!empty($translation)) {
case 'purchase': return $translation;
$textEditContact = 'general.form.edit';
break;
default:
$textEditContact = 'general.form.edit';
break;
} }
return $textEditContact; return 'general.form.edit';
} }
protected function getTextContactInfo($type, $textContactInfo) protected function getTextContactInfo($type, $textContactInfo)
@ -429,14 +480,20 @@ abstract class DocumentForm extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textContactInfo = 'bills.bill_from'; $default_key = 'bill_from';
break; break;
default: default:
$textContactInfo = 'invoices.bill_to'; $default_key = 'bill_to';
break; break;
} }
return $textContactInfo; $translation = $this->getTextFromConfig($type, 'contact_info', $default_key);
if (!empty($translation)) {
return $translation;
}
return 'invoices.bill_to';
} }
protected function getTextChooseDifferentContact($type, $textChooseDifferentContact) protected function getTextChooseDifferentContact($type, $textChooseDifferentContact)
@ -445,84 +502,75 @@ abstract class DocumentForm extends Component
return $textChooseDifferentContact; return $textChooseDifferentContact;
} }
switch ($type) { $default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
case 'bill':
case 'expense': $translation = $this->getTextFromConfig($type, 'choose_different_contact', $default_key, 'trans_choice');
case 'purchase':
$textChooseDifferentContact = [ if (!empty($translation)) {
return [
'general.form.choose_different', 'general.form.choose_different',
'general.vendors' $translation,
]; ];
break;
default:
$textChooseDifferentContact = [
'general.form.choose_different',
'general.customers'
];
break;
} }
return $textChooseDifferentContact; return [
'general.form.choose_different',
'general.customers',
];
} }
protected function getIssuedAt($type, $document, $issued_at) protected function getIssuedAt($type, $document, $issuedAt)
{ {
if (!empty($issued_at)) { if (!empty($issuedAt)) {
return $issued_at; return $issuedAt;
} }
if ($document) { if ($document) {
return $document->issued_at; return $document->issued_at;
} }
switch ($type) { $issued_at = $type . '_at';
case 'bill':
case 'expense': if (request()->has($issued_at)) {
case 'purchase': $issuedAt = request()->get($issued_at);
$issued_at = request()->get('billed_at', Date::now()->toDateString()); } else {
break; $issuedAt = request()->get('invoiced_at', Date::now()->toDateString());
default:
$issued_at = request()->get('invoiced_at', Date::now()->toDateString());
break;
} }
return $issued_at; return $issuedAt;
} }
protected function getDocumentNumber($type, $document, $document_number) protected function getDocumentNumber($type, $document, $documentNumber)
{ {
if (!empty($document_number)) { if (!empty($documentNumber)) {
return $document_number; return $documentNumber;
} }
if ($document) { if ($document) {
return $document->document_number; return $document->document_number;
} }
switch ($type) { $document_number = $this->getNextDocumentNumber($type);
case 'bill':
case 'expense': if (empty($document_number)) {
case 'purchase':
$document_number = $this->getNextDocumentNumber(Document::BILL_TYPE);
break;
default:
$document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE); $document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE);
break;
} }
return $document_number; return $document_number;
} }
protected function getDueAt($type, $document, $due_at) protected function getDueAt($type, $document, $dueAt)
{ {
if (!empty($due_at)) { if (!empty($dueAt)) {
return $due_at; return $dueAt;
} }
if ($document) { if ($document) {
return $document->due_at; return $document->due_at;
} }
$addDays = (setting($type . '.payment_terms', 0)) ? setting($type . '.payment_terms', 0) : setting('invoice.payment_terms', 0);
switch ($type) { switch ($type) {
case 'bill': case 'bill':
case 'expense': case 'expense':
@ -530,17 +578,17 @@ abstract class DocumentForm extends Component
$due_at = request()->get('billed_at', Date::now()->toDateString()); $due_at = request()->get('billed_at', Date::now()->toDateString());
break; break;
default: default:
$due_at = Date::parse(request()->get('invoiced_at', Date::now()->toDateString()))->addDays(setting('invoice.payment_terms', 0))->toDateString(); $due_at = Date::parse(request()->get('invoiced_at', Date::now()->toDateString()))->addDays($addDays)->toDateString();
break; break;
} }
return $due_at; return $due_at;
} }
protected function getOrderNumber($type, $document, $order_number) protected function getOrderNumber($type, $document, $orderNumber)
{ {
if (!empty($order_number)) { if (!empty($orderNumber)) {
return $order_number; return $orderNumber;
} }
if ($document) { if ($document) {
@ -560,14 +608,20 @@ abstract class DocumentForm extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textDocumentNumber = 'bills.bill_number'; $default_key = 'bill_number';
break; break;
default: default:
$textDocumentNumber = 'invoices.invoice_number'; $default_key = 'invoice_number';
break; break;
} }
return $textDocumentNumber; $translation = $this->getTextFromConfig($type, 'document_number', $default_key);
if (!empty($translation)) {
return $translation;
}
return 'invoices.invoice_number';
} }
protected function getTextOrderNumber($type, $textOrderNumber) protected function getTextOrderNumber($type, $textOrderNumber)
@ -576,18 +630,13 @@ abstract class DocumentForm extends Component
return $textOrderNumber; return $textOrderNumber;
} }
switch ($type) { $translation = $this->getTextFromConfig($type, 'order_number');
case 'bill':
case 'expense': if (!empty($translation)) {
case 'purchase': return $translation;
$textOrderNumber = 'bills.order_number';
break;
default:
$textOrderNumber = 'invoices.order_number';
break;
} }
return $textOrderNumber; return 'invoices.order_number';
} }
protected function getTextIssuedAt($type, $textIssuedAt) protected function getTextIssuedAt($type, $textIssuedAt)
@ -600,14 +649,20 @@ abstract class DocumentForm extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textIssuedAt = 'bills.bill_date'; $default_key = 'bill_date';
break; break;
default: default:
$textIssuedAt = 'invoices.invoice_date'; $default_key = 'invoice_date';
break; break;
} }
return $textIssuedAt; $translation = $this->getTextFromConfig($type, 'issued_at', $default_key);
if (!empty($translation)) {
return $translation;
}
return 'invoices.invoice_date';
} }
protected function getTextDueAt($type, $textDueAt) protected function getTextDueAt($type, $textDueAt)
@ -616,101 +671,88 @@ abstract class DocumentForm extends Component
return $textDueAt; return $textDueAt;
} }
switch ($type) { $translation = $this->getTextFromConfig($type, 'due_at', 'due_date');
case 'bill':
case 'expense': if (!empty($translation)) {
case 'purchase': return $translation;
$textDueAt = 'bills.due_date';
break;
default:
$textDueAt = 'invoices.due_date';
break;
} }
return $textDueAt; return 'invoices.due_date';
} }
protected function getTextItems($type, $text_items) protected function getTextItems($type, $textItems)
{ {
if (!empty($text_items)) { if (!empty($textItems)) {
return $text_items; return $textItems;
} }
switch ($type) { // if you use settting translation
case 'bill': if (setting($type . '.item_name', 'items') == 'custom') {
case 'expense': return setting($type . '.item_name_input');
case 'purchase':
$text_items = 'general.items';
break;
default:
$text_items = setting('invoice.item_name', 'general.items');
if ($text_items == 'custom') {
$text_items = setting('invoice.item_name_input');
}
break;
} }
return $text_items; $translation = $this->getTextFromConfig($type, 'items');
if (!empty($translation)) {
return $translation;
} }
protected function getTextQuantity($type, $text_quantity) return 'general.items';
}
protected function getTextQuantity($type, $textQuantity)
{ {
if (!empty($text_quantity)) { if (!empty($textQuantity)) {
return $text_quantity; return $textQuantity;
} }
switch ($type) { // if you use settting translation
case 'bill': if (setting($type . '.quantity_name', 'quantity') == 'custom') {
case 'expense': return setting($type . '.quantity_name_input');
case 'purchase':
$text_quantity = 'bills.quantity';
break;
default:
$text_quantity = setting('invoice.quantity_name', 'invoices.quantity');
if ($text_quantity == 'custom') {
$text_quantity = setting('invoice.quantity_name_input');
}
break;
} }
return $text_quantity; $translation = $this->getTextFromConfig($type, 'quantity');
if (!empty($translation)) {
return $translation;
} }
protected function getTextPrice($type, $text_price) return 'invoices.quantity';
}
protected function getTextPrice($type, $textPrice)
{ {
if (!empty($text_price)) { if (!empty($textPrice)) {
return $text_price; return $textPrice;
} }
switch ($type) { // if you use settting translation
case 'bill': if (setting($type . '.price_name', 'price') == 'custom') {
case 'expense': return setting($type . '.price_name_input');
case 'purchase':
$text_price = 'bills.price';
break;
default:
$text_price = setting('invoice.price_name', 'invoices.price');
if ($text_price == 'custom') {
$text_price = setting('invoice.price_name_input');
}
break;
} }
return $text_price; $translation = $this->getTextFromConfig($type, 'price');
if (!empty($translation)) {
return $translation;
} }
protected function getTextAmount($type, $text_amount) return 'invoices.price';
}
protected function getTextAmount($type, $textAmount)
{ {
if (!empty($text_amount)) { if (!empty($textAmount)) {
return $text_amount; return $textAmount;
} }
$text_amount = 'general.amount'; $translation = $this->getTextFromConfig($type, 'amount');
return $text_amount; if (!empty($translation)) {
return $translation;
}
return 'general.amount';
} }
protected function getHideItems($type, $hideItems, $hideName, $hideDescription) protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
@ -719,6 +761,12 @@ abstract class DocumentForm extends Component
return $hideItems; return $hideItems;
} }
$hide = $this->getHideFromConfig($type, 'items');
if ($hide) {
return $hide;
}
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false; $hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false;
return $hideItems; return $hideItems;
@ -730,18 +778,19 @@ abstract class DocumentForm extends Component
return $hideName; return $hideName;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideName = setting($type . '.hide_item_name', false)) {
case 'expense': return $hideName;
case 'purchase':
$hideName = setting('bill.hide_item_name', $hideName);
break;
default:
$hideName = setting('invoice.hide_item_name', $hideName);
break;
} }
return $hideName; $hide = $this->getHideFromConfig($type, 'name');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_item_name', $hideName);
} }
protected function getHideDescription($type, $hideDescription) protected function getHideDescription($type, $hideDescription)
@ -750,18 +799,19 @@ abstract class DocumentForm extends Component
return $hideDescription; return $hideDescription;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideDescription = setting($type . '.hide_item_description', false)) {
case 'expense': return $hideDescription;
case 'purchase':
$hideDescription = setting('bill.hide_item_description', $hideDescription);
break;
default:
$hideDescription = setting('invoice.hide_item_description', $hideDescription);
break;
} }
return $hideDescription; $hide = $this->getHideFromConfig($type, 'description');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_item_description', $hideDescription);
} }
protected function getHideQuantity($type, $hideQuantity) protected function getHideQuantity($type, $hideQuantity)
@ -770,18 +820,19 @@ abstract class DocumentForm extends Component
return $hideQuantity; return $hideQuantity;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideQuantity = setting($type . '.hide_quantity', false)) {
case 'expense': return $hideQuantity;
case 'purchase':
$hideQuantity = setting('bill.hide_quantity', $hideQuantity);
break;
default:
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
break;
} }
return $hideQuantity; $hide = $this->getHideFromConfig($type, 'quantity');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_quantity', $hideQuantity);
} }
protected function getHidePrice($type, $hidePrice) protected function getHidePrice($type, $hidePrice)
@ -790,18 +841,19 @@ abstract class DocumentForm extends Component
return $hidePrice; return $hidePrice;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hidePrice = setting($type . '.hide_price', false)) {
case 'expense': return $hidePrice;
case 'purchase':
$hidePrice = setting('bill.hide_price', $hidePrice);
break;
default:
$hidePrice = setting('invoice.hide_price', $hidePrice);
break;
} }
return $hidePrice; $hide = $this->getHideFromConfig($type, 'price');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_price', $hidePrice);
} }
protected function getHideDiscount($type, $hideDiscount) protected function getHideDiscount($type, $hideDiscount)
@ -810,18 +862,19 @@ abstract class DocumentForm extends Component
return $hideDiscount; return $hideDiscount;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideDiscount = setting($type . '.hide_discount', false)) {
case 'expense': return $hideDiscount;
case 'purchase':
$hideDiscount = setting('bill.hide_discount', $hideDiscount);
break;
default:
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
break;
} }
return $hideDiscount; $hide = $this->getHideFromConfig($type, 'discount');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_discount', $hideDiscount);
} }
protected function getHideAmount($type, $hideAmount) protected function getHideAmount($type, $hideAmount)
@ -830,17 +883,18 @@ abstract class DocumentForm extends Component
return $hideAmount; return $hideAmount;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideAmount = setting($type . '.hide_amount', false)) {
case 'expense':
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
}
return $hideAmount; return $hideAmount;
} }
$hide = $this->getHideFromConfig($type, 'amount');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_amount', $hideAmount);
}
} }

View File

@ -2,11 +2,12 @@
namespace App\Abstracts\View\Components; namespace App\Abstracts\View\Components;
use Illuminate\View\Component; use Akaunting\Module\Module;
use Illuminate\Support\Str; use App\Abstracts\View\Components\Document as Base;
use App\Events\Common\BulkActionsAdding; use App\Events\Common\BulkActionsAdding;
use Illuminate\Support\Str;
abstract class DocumentIndex extends Component abstract class DocumentIndex extends Base
{ {
/** @var string */ /** @var string */
public $type; public $type;
@ -235,7 +236,7 @@ abstract class DocumentIndex extends Component
/* -- Card Header End -- */ /* -- Card Header End -- */
/* -- Card Body Start -- */ /* -- Card Body Start -- */
$this->textDocumentNumber = $this->getTextDocumentNumber($textDocumentNumber); $this->textDocumentNumber = $this->getTextDocumentNumber($type, $textDocumentNumber);
$this->textContactName = $this->getTextContactName($type, $textContactName); $this->textContactName = $this->getTextContactName($type, $textContactName);
$this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt); $this->textIssuedAt = $this->getTextIssuedAt($type, $textIssuedAt);
$this->textDueAt = $this->getTextDueAt($type, $textDueAt); $this->textDueAt = $this->getTextDueAt($type, $textDueAt);
@ -267,7 +268,7 @@ abstract class DocumentIndex extends Component
$this->classDocumentNumber = $this->getClassDocumentNumber($type, $classDocumentNumber); $this->classDocumentNumber = $this->getClassDocumentNumber($type, $classDocumentNumber);
$this->classContactName = $this->getClassContactName($type, $classContactName); $this->classContactName = $this->getClassContactName($type, $classContactName);
$this->classAmount = $this->getClassAmount($type, $classAmount); $this->classAmount = $this->getClassAmount($type, $classAmount);
$this->classIssuedAt = $this->getclassIssuedAt($type, $classIssuedAt); $this->classIssuedAt = $this->getClassIssuedAt($type, $classIssuedAt);
$this->classDueAt = $this->getClassDueAt($type, $classDueAt); $this->classDueAt = $this->getClassDueAt($type, $classDueAt);
$this->classStatus = $this->getClassStatus($type, $classStatus); $this->classStatus = $this->getClassStatus($type, $classStatus);
$this->classActions = $this->getClassActions($type, $classActions); $this->classActions = $this->getClassActions($type, $classActions);
@ -292,7 +293,7 @@ abstract class DocumentIndex extends Component
return $page; return $page;
} }
return config("type.{$type}.route_name"); return config('type.' . $type . '.route.prefix', 'invoices');
} }
protected function getDocsPath($type, $docsPath) protected function getDocsPath($type, $docsPath)
@ -301,6 +302,12 @@ abstract class DocumentIndex extends Component
return $docsPath; return $docsPath;
} }
$docs_path = config('type.' . $type . '.docs_path');
if (!empty($docs_path)) {
return $docs_path;
}
switch ($type) { switch ($type) {
case 'sale': case 'sale':
case 'income': case 'income':
@ -323,17 +330,13 @@ abstract class DocumentIndex extends Component
return $createRoute; return $createRoute;
} }
$page = config("type.{$type}.route_name"); $route = $this->getRouteFromConfig($type, 'create');
$route = $page . '.create'; if (!empty($route)) {
return $route;
try {
route($route);
} catch (\Exception $e) {
$route = '';
} }
return $route; return 'invoices.create';
} }
protected function getImportRoute($importRoute) protected function getImportRoute($importRoute)
@ -353,9 +356,21 @@ abstract class DocumentIndex extends Component
return $importRouteParameters; return $importRouteParameters;
} }
$route = $this->getRouteFromConfig($type, 'import');
$alias = config('type.' . $type . '.alias');
$group = config('type.' . $type . '.group');
if (empty($group) && !empty($alias)){
$group = $alias;
} else if (empty($group) && empty($alias)) {
$group = 'sales';
}
$importRouteParameters = [ $importRouteParameters = [
'group' => config("type.{$type}.group"), 'group' => $group,
'type' => config("type.{$type}.route_name") 'type' => config('type.' . $type . '.route.prefix'),
'route' => ($route) ? $route : 'invoices.import',
]; ];
return $importRouteParameters; return $importRouteParameters;
@ -367,17 +382,13 @@ abstract class DocumentIndex extends Component
return $exportRoute; return $exportRoute;
} }
$page = config("type.{$type}.route_name"); $route = $this->getRouteFromConfig($type, 'export');
$route = $page . '.export'; if (!empty($route)) {
return $route;
try {
route($route);
} catch (\Exception $e) {
$route = '';
} }
return $route; return 'invoices.export';
} }
protected function getRoute($type, $formCardHeaderRoute) protected function getRoute($type, $formCardHeaderRoute)
@ -386,17 +397,13 @@ abstract class DocumentIndex extends Component
return $formCardHeaderRoute; return $formCardHeaderRoute;
} }
$page = config("type.{$type}.route_name"); $route = $this->getRouteFromConfig($type, 'index');
$route = $page . '.index'; if (!empty($route)) {
return $route;
try {
route($route);
} catch (\Exception $e) {
$route = '';
} }
return $route; return 'invoices.index';
} }
protected function getSearchStringModel($type, $searchStringModel) protected function getSearchStringModel($type, $searchStringModel)
@ -405,17 +412,22 @@ abstract class DocumentIndex extends Component
return $searchStringModel; return $searchStringModel;
} }
switch ($type) { $search_string_model = config('type.' . $type . '.search_string_model');
case 'sale':
case 'income': if (!empty($search_string_model)) {
case 'invoice': return $search_string_model;
$searchStringModel = 'App\Models\Sale\Invoice'; }
break;
case 'bill': if ($group = config('type.' . $type . '.group')) {
case 'expense': $group = Str::studly(Str::singular($group)) . '\\';
case 'purchase': }
$searchStringModel = 'App\Models\Purchase\Bill';
break; $prefix = Str::studly(Str::singular(config('type.' . $type . '.route.prefix')));
if ($alias = config('type.' . $type . '.alias')) {
$searchStringModel = 'Modules\\' . Str::studly($alias) .'\Models\\' . $group . $prefix;
} else {
$searchStringModel = 'App\Models\\' . $group . $prefix;
} }
return $searchStringModel; return $searchStringModel;
@ -427,9 +439,15 @@ abstract class DocumentIndex extends Component
return $textBulkAction; return $textBulkAction;
} }
$textBulkAction = 'general.' . config("type.{$type}.translation_key"); $default_key = config('type.' . $type . '.translation.prefix');
return $textBulkAction; $translation = $this->getTextFromConfig($type, 'bulk_action', $default_key, 'trans_choice');
if (!empty($translation)) {
return $translation;
}
return 'general.invoices';
} }
protected function getBulkActions($type, $bulkActions, $bulkActionClass) protected function getBulkActions($type, $bulkActions, $bulkActionClass)
@ -438,17 +456,37 @@ abstract class DocumentIndex extends Component
return $bulkActions; return $bulkActions;
} }
switch ($type) { $bulk_actions = config('type.' . $type . '.bulk_actions');
case 'sale':
case 'income': if (!empty($bulk_actions)) {
case 'invoice': return $bulk_actions;
$bulkActionClass = 'App\BulkActions\Sales\Invoices'; }
break;
case 'bill': $file_name = '';
case 'expense':
case 'purchase': if ($group = config('type.' . $type . '.group')) {
$bulkActionClass = 'App\BulkActions\Purchases\Bills'; $file_name .= Str::studly($group) . '\\';
break; }
if ($prefix = config('type.' . $type . '.route.prefix')) {
$file_name .= Str::studly($prefix);
}
if ($alias = config('type.' . $type . '.alias')) {
$module = module($alias);
if (!$module instanceof Module) {
$b = new \stdClass();
$b->actions = [];
event(new BulkActionsAdding($b));
return $b->actions;
}
$bulkActionClass = 'Modules\\' . $module->getStudlyName() . '\BulkActions\\' . $file_name;
} else {
$bulkActionClass = 'App\BulkActions\\' . $file_name;
} }
if (class_exists($bulkActionClass)) { if (class_exists($bulkActionClass)) {
@ -473,9 +511,15 @@ abstract class DocumentIndex extends Component
return $bulkActionRouteParameters; return $bulkActionRouteParameters;
} }
$group = config('type.' . $type . '.group');
if (!empty(config('type.' . $type . '.alias'))) {
$group = config('type.' . $type . '.alias');
}
$bulkActionRouteParameters = [ $bulkActionRouteParameters = [
'group' => config("type.{$type}.group"), 'group' => $group,
'type' => config("type.{$type}.route_name") 'type' => config('type.' . $type . '.route.prefix')
]; ];
return $bulkActionRouteParameters; return $bulkActionRouteParameters;
@ -487,15 +531,27 @@ abstract class DocumentIndex extends Component
return $classBulkAction; return $classBulkAction;
} }
$class = $this->getClassFromConfig($type, 'bulk_action');
if (!empty($class)) {
return $class;
}
return 'col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block'; return 'col-sm-2 col-md-1 col-lg-1 col-xl-1 d-none d-sm-block';
} }
protected function getTextDocumentNumber($textDocumentNumber) protected function getTextDocumentNumber($type, $textDocumentNumber)
{ {
if (!empty($textDocumentNumber)) { if (!empty($textDocumentNumber)) {
return $textDocumentNumber; return $textDocumentNumber;
} }
$translation = $this->getTextFromConfig($type, 'document_number', 'numbers');
if (!empty($translation)) {
return $translation;
}
return 'general.numbers'; return 'general.numbers';
} }
@ -509,6 +565,12 @@ abstract class DocumentIndex extends Component
return $classDocumentNumber; return $classDocumentNumber;
} }
$class = $this->getClassFromConfig($type, 'document_number');
if (!empty($class)) {
return $class;
}
return 'col-md-2 col-lg-1 col-xl-1 d-none d-md-block'; return 'col-md-2 col-lg-1 col-xl-1 d-none d-md-block';
} }
@ -518,18 +580,15 @@ abstract class DocumentIndex extends Component
return $textContactName; return $textContactName;
} }
switch ($type) { $default_key = Str::plural(config('type.' . $type . '.contact_type'), 2);
case 'bill':
case 'expense': $translation = $this->getTextFromConfig($type, 'contact_name', $default_key, 'trans_choice');
case 'purchase':
$textContactName = 'general.vendors'; if (!empty($translation)) {
break; return $translation;
default:
$textContactName = 'general.customers';
break;
} }
return $textContactName; return 'general.customers';
} }
protected function getClassContactName($type, $classContactName) protected function getClassContactName($type, $classContactName)
@ -542,6 +601,12 @@ abstract class DocumentIndex extends Component
return $classContactName; return $classContactName;
} }
$class = $this->getClassFromConfig($type, 'contact_name');
if (!empty($class)) {
return $class;
}
return 'col-xs-4 col-sm-4 col-md-4 col-lg-2 col-xl-2 text-left'; return 'col-xs-4 col-sm-4 col-md-4 col-lg-2 col-xl-2 text-left';
} }
@ -555,6 +620,12 @@ abstract class DocumentIndex extends Component
return $classAmount; return $classAmount;
} }
$class = $this->getClassFromConfig($type, 'amount');
if (!empty($class)) {
return $class;
}
return 'col-xs-4 col-sm-4 col-md-3 col-lg-2 col-xl-2 text-right'; return 'col-xs-4 col-sm-4 col-md-3 col-lg-2 col-xl-2 text-right';
} }
@ -568,17 +639,23 @@ abstract class DocumentIndex extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textIssuedAt = 'bills.bill_date'; $default_key = 'bill_date';
break; break;
default: default:
$textIssuedAt = 'invoices.invoice_date'; $default_key = 'invoice_date';
break; break;
} }
return $textIssuedAt; $translation = $this->getTextFromConfig($type, 'issued_at', $default_key);
if (!empty($translation)) {
return $translation;
} }
protected function getclassIssuedAt($type, $classIssuedAt) return 'invoices.invoice_date';
}
protected function getClassIssuedAt($type, $classIssuedAt)
{ {
if (!empty($classIssuedAt)) { if (!empty($classIssuedAt)) {
return $classIssuedAt; return $classIssuedAt;
@ -588,6 +665,12 @@ abstract class DocumentIndex extends Component
return $classIssuedAt; return $classIssuedAt;
} }
$class = $this->getClassFromConfig($type, 'issued_at');
if (!empty($class)) {
return $class;
}
return 'col-lg-2 col-xl-2 d-none d-lg-block text-left'; return 'col-lg-2 col-xl-2 d-none d-lg-block text-left';
} }
@ -597,18 +680,13 @@ abstract class DocumentIndex extends Component
return $textDueAt; return $textDueAt;
} }
switch ($type) { $translation = $this->getTextFromConfig($type, 'due_at', 'due_date');
case 'bill':
case 'expense': if (!empty($translation)) {
case 'purchase': return $translation;
$textDueAt = 'bills.due_date';
break;
default:
$textDueAt = 'invoices.due_date';
break;
} }
return $textDueAt; return 'invoices.due_date';
} }
protected function getClassDueAt($type, $classDueAt) protected function getClassDueAt($type, $classDueAt)
@ -617,6 +695,12 @@ abstract class DocumentIndex extends Component
return $classDueAt; return $classDueAt;
} }
$class = $this->getClassFromConfig($type, 'due_at');
if (!empty($class)) {
return $class;
}
if ($classDueAt = $this->getClass('classDueAt')) { if ($classDueAt = $this->getClass('classDueAt')) {
return $classDueAt; return $classDueAt;
} }
@ -630,18 +714,23 @@ abstract class DocumentIndex extends Component
return $textDocumentStatus; return $textDocumentStatus;
} }
switch ($type) { $translation = $this->getTextFromConfig($type, 'document_status', 'statuses.');
case 'bill':
case 'expense': if (!empty($translation)) {
case 'purchase': return $translation;
$textDocumentStatus = 'bills.statuses.';
break;
default:
$textDocumentStatus = 'invoices.statuses.';
break;
} }
return $textDocumentStatus; $alias = config('type.' . $type . '.alias');
if (!empty($alias)) {
$translation = $alias . '::' . config('type.' . $type . '.translation.prefix') . '.statuses';
if (is_array(trans($translation))) {
return $translation . '.';
}
}
return 'documents.statuses.';
} }
protected function getClassStatus($type, $classStatus) protected function getClassStatus($type, $classStatus)
@ -654,6 +743,12 @@ abstract class DocumentIndex extends Component
return $classStatus; return $classStatus;
} }
$class = $this->getClassFromConfig($type, 'status');
if (!empty($class)) {
return $class;
}
return 'col-lg-1 col-xl-1 d-none d-lg-block text-center'; return 'col-lg-1 col-xl-1 d-none d-lg-block text-center';
} }
@ -667,6 +762,12 @@ abstract class DocumentIndex extends Component
return $classActions; return $classActions;
} }
$class = $this->getClassFromConfig($type, 'actions');
if (!empty($class)) {
return $class;
}
return 'col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center'; return 'col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center';
} }
@ -676,20 +777,16 @@ abstract class DocumentIndex extends Component
return $routeButtonShow; return $routeButtonShow;
} }
$page = config("type.{$type}.route_name");
$route = $page . '.show';
try {
//example route parameter. //example route parameter.
$parameter = 1; $parameter = 1;
route($route, $parameter); $route = $this->getRouteFromConfig($type, 'show', $parameter);
} catch (\Exception $e) {
$route = ''; if (!empty($route)) {
return $route;
} }
return $route; return 'invoices.show';
} }
protected function getRouteButtonEdit($type, $routeButtonEdit) protected function getRouteButtonEdit($type, $routeButtonEdit)
@ -698,20 +795,16 @@ abstract class DocumentIndex extends Component
return $routeButtonEdit; return $routeButtonEdit;
} }
$page = config("type.{$type}.route_name");
$route = $page . '.edit';
try {
//example route parameter. //example route parameter.
$parameter = 1; $parameter = 1;
route($route, $parameter); $route = $this->getRouteFromConfig($type, 'edit', $parameter);
} catch (\Exception $e) {
$route = ''; if (!empty($route)) {
return $route;
} }
return $route; return 'invoices.edit';
} }
protected function getRouteButtonDuplicate($type, $routeButtonDuplicate) protected function getRouteButtonDuplicate($type, $routeButtonDuplicate)
@ -720,20 +813,16 @@ abstract class DocumentIndex extends Component
return $routeButtonDuplicate; return $routeButtonDuplicate;
} }
$page = config("type.{$type}.route_name");
$route = $page . '.duplicate';
try {
//example route parameter. //example route parameter.
$parameter = 1; $parameter = 1;
route($route, $parameter); $route = $this->getRouteFromConfig($type, 'duplicate', $parameter);
} catch (\Exception $e) {
$route = ''; if (!empty($route)) {
return $route;
} }
return $route; return 'invoices.duplicate';
} }
protected function getRouteButtonCancelled($type, $routeButtonCancelled) protected function getRouteButtonCancelled($type, $routeButtonCancelled)
@ -742,20 +831,16 @@ abstract class DocumentIndex extends Component
return $routeButtonCancelled; return $routeButtonCancelled;
} }
$page = config("type.{$type}.route_name");
$route = $page . '.cancelled';
try {
//example route parameter. //example route parameter.
$parameter = 1; $parameter = 1;
route($route, $parameter); $route = $this->getRouteFromConfig($type, 'cancelled', $parameter);
} catch (\Exception $e) {
$route = ''; if (!empty($route)) {
return $route;
} }
return $route; return 'invoices.cancelled';
} }
protected function getRouteButtonDelete($type, $routeButtonDelete) protected function getRouteButtonDelete($type, $routeButtonDelete)
@ -764,20 +849,16 @@ abstract class DocumentIndex extends Component
return $routeButtonDelete; return $routeButtonDelete;
} }
$page = config("type.{$type}.route_name");
$route = $page . '.destroy';
try {
//example route parameter. //example route parameter.
$parameter = 1; $parameter = 1;
route($route, $parameter); $route = $this->getRouteFromConfig($type, 'destroy', $parameter);
} catch (\Exception $e) {
$route = ''; if (!empty($route)) {
return $route;
} }
return $route; return 'invoices.destroy';
} }
protected function getPermissionCreate($type, $permissionCreate) protected function getPermissionCreate($type, $permissionCreate)
@ -786,18 +867,7 @@ abstract class DocumentIndex extends Component
return $permissionCreate; return $permissionCreate;
} }
switch ($type) { $permissionCreate = $this->getPermissionFromConfig($type, 'create');
case 'sale':
case 'income':
case 'invoice':
$permissionCreate = 'create-sales-invoices';
break;
case 'bill':
case 'expense':
case 'purchase':
$permissionCreate = 'create-purchases-bills';
break;
}
return $permissionCreate; return $permissionCreate;
} }
@ -808,18 +878,7 @@ abstract class DocumentIndex extends Component
return $permissionUpdate; return $permissionUpdate;
} }
switch ($type) { $permissionUpdate = $this->getPermissionFromConfig($type, 'update');
case 'sale':
case 'income':
case 'invoice':
$permissionUpdate = 'update-sales-invoices';
break;
case 'bill':
case 'expense':
case 'purchase':
$permissionUpdate = 'update-purchases-bills';
break;
}
return $permissionUpdate; return $permissionUpdate;
} }
@ -830,18 +889,7 @@ abstract class DocumentIndex extends Component
return $permissionDelete; return $permissionDelete;
} }
switch ($type) { $permissionDelete = $this->getPermissionFromConfig($type, 'delete');
case 'sale':
case 'income':
case 'invoice':
$permissionDelete = 'delete-sales-invoices';
break;
case 'bill':
case 'expense':
case 'purchase':
$permissionDelete = 'delete-purchases-bills';
break;
}
return $permissionDelete; return $permissionDelete;
} }

File diff suppressed because it is too large Load Diff

View File

@ -2,15 +2,15 @@
namespace App\Abstracts\View\Components; namespace App\Abstracts\View\Components;
use Illuminate\View\Component; use App\Abstracts\View\Components\Document as Base;
use Illuminate\Support\Str;
use App\Traits\DateTime; use App\Traits\DateTime;
use App\Models\Common\Media; use App\Models\Common\Media;
use File; use File;
use Image; use Image;
use Storage; use Storage;
use Illuminate\Support\Str;
abstract class DocumentTemplate extends Component abstract class DocumentTemplate extends Base
{ {
use DateTime; use DateTime;
@ -175,18 +175,12 @@ abstract class DocumentTemplate extends Component
return $documentTemplate; return $documentTemplate;
} }
// $documentTemplate = 'components.documents.template.default'; if ($template = config('type.' . $type . 'template', false)) {
$documentTemplate = 'default'; return $template;
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
// $documentTemplate = 'components.documents.template.' . setting('invoice.template', 'default');
$documentTemplate = setting('invoice.template', 'default');
break;
} }
$documentTemplate = setting($type . '.template', 'default');
return $documentTemplate; return $documentTemplate;
} }
@ -229,19 +223,12 @@ abstract class DocumentTemplate extends Component
return $backgroundColor; return $backgroundColor;
} }
$backgroundColor = '#55588b'; if ($background_color = config('type.' . $type . 'color', false)) {
return $background_color;
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$backgroundColor = setting('bill.color');
break;
default:
$backgroundColor = setting('invoice.color');
break;
} }
$backgroundColor = setting($type . '.color', '#55588b');
return $backgroundColor; return $backgroundColor;
} }
@ -255,14 +242,20 @@ abstract class DocumentTemplate extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textDocumentNumber = 'bills.bill_number'; $default_key = 'bill_number';
break; break;
default: default:
$textDocumentNumber = 'invoices.invoice_number'; $default_key = 'invoice_number';
break; break;
} }
return $textDocumentNumber; $translation = $this->getTextFromConfig($type, 'document_number', $default_key);
if (!empty($translation)) {
return $translation;
}
return 'general.numbers';
} }
protected function getTextOrderNumber($type, $textOrderNumber) protected function getTextOrderNumber($type, $textOrderNumber)
@ -271,18 +264,13 @@ abstract class DocumentTemplate extends Component
return $textOrderNumber; return $textOrderNumber;
} }
switch ($type) { $translation = $this->getTextFromConfig($type, 'order_number');
case 'bill':
case 'expense': if (!empty($translation)) {
case 'purchase': return $translation;
$textOrderNumber = 'bills.order_number';
break;
default:
$textOrderNumber = 'invoices.order_number';
break;
} }
return $textOrderNumber; return 'invoices.order_number';
} }
protected function getTextContactInfo($type, $textContactInfo) protected function getTextContactInfo($type, $textContactInfo)
@ -295,14 +283,20 @@ abstract class DocumentTemplate extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textContactInfo = 'bills.bill_from'; $default_key = 'bill_from';
break; break;
default: default:
$textContactInfo = 'invoices.bill_to'; $default_key = 'bill_to';
break; break;
} }
return $textContactInfo; $translation = $this->getTextFromConfig($type, 'contact_info', $default_key);
if (!empty($translation)) {
return $translation;
}
return 'invoices.bill_to';
} }
protected function getTextIssuedAt($type, $textIssuedAt) protected function getTextIssuedAt($type, $textIssuedAt)
@ -315,14 +309,20 @@ abstract class DocumentTemplate extends Component
case 'bill': case 'bill':
case 'expense': case 'expense':
case 'purchase': case 'purchase':
$textIssuedAt = 'bills.bill_date'; $default_key = 'bill_date';
break; break;
default: default:
$textIssuedAt = 'invoices.invoice_date'; $default_key = 'invoice_date';
break; break;
} }
return $textIssuedAt; $translation = $this->getTextFromConfig($type, 'issued_at', $default_key);
if (!empty($translation)) {
return $translation;
}
return 'invoices.invoice_date';
} }
protected function getTextDueAt($type, $textDueAt) protected function getTextDueAt($type, $textDueAt)
@ -331,18 +331,13 @@ abstract class DocumentTemplate extends Component
return $textDueAt; return $textDueAt;
} }
switch ($type) { $translation = $this->getTextFromConfig($type, 'due_at', 'due_date');
case 'bill':
case 'expense': if (!empty($translation)) {
case 'purchase': return $translation;
$textDueAt = 'bills.due_date';
break;
default:
$textDueAt = 'invoices.due_date';
break;
} }
return $textDueAt; return 'invoices.due_date';
} }
protected function getTextItems($type, $textItems) protected function getTextItems($type, $textItems)
@ -351,22 +346,18 @@ abstract class DocumentTemplate extends Component
return $textItems; return $textItems;
} }
switch ($type) { // if you use settting translation
case 'bill': if (setting($type . '.item_name', 'items') == 'custom') {
case 'expense': return setting($type . '.item_name_input');
case 'purchase':
$textItems = 'general.items';
break;
default:
$textItems = setting('invoice.item_name', 'general.items');
if ($textItems == 'custom') {
$textItems = setting('invoice.item_name_input');
}
break;
} }
return $textItems; $translation = $this->getTextFromConfig($type, 'items');
if (!empty($translation)) {
return $translation;
}
return 'general.items';
} }
protected function getTextQuantity($type, $textQuantity) protected function getTextQuantity($type, $textQuantity)
@ -375,46 +366,38 @@ abstract class DocumentTemplate extends Component
return $textQuantity; return $textQuantity;
} }
switch ($type) { // if you use settting translation
case 'bill': if (setting($type . '.quantity_name', 'quantity') == 'custom') {
case 'expense': return setting($type . '.quantity_name_input');
case 'purchase':
$textQuantity = 'bills.quantity';
break;
default:
$textQuantity = setting('invoice.quantity_name', 'invoices.quantity');
if ($textQuantity == 'custom') {
$textQuantity = setting('invoice.quantity_name_input');
}
break;
} }
return $textQuantity; $translation = $this->getTextFromConfig($type, 'quantity');
if (!empty($translation)) {
return $translation;
} }
protected function getTextPrice($type, $text_price) return 'invoices.quantity';
}
protected function getTextPrice($type, $textPrice)
{ {
if (!empty($text_price)) { if (!empty($textPrice)) {
return $text_price; return $textPrice;
} }
switch ($type) { // if you use settting translation
case 'bill': if (setting($type . '.price_name', 'price') == 'custom') {
case 'expense': return setting($type . '.price_name_input');
case 'purchase':
$text_price = 'bills.price';
break;
default:
$text_price = setting('invoice.price_name', 'invoices.price');
if ($text_price == 'custom') {
$text_price = setting('invoice.price_name_input');
}
break;
} }
return $text_price; $translation = $this->getTextFromConfig($type, 'price');
if (!empty($translation)) {
return $translation;
}
return 'invoices.price';
} }
protected function getTextAmount($type, $textAmount) protected function getTextAmount($type, $textAmount)
@ -423,9 +406,13 @@ abstract class DocumentTemplate extends Component
return $textAmount; return $textAmount;
} }
$textAmount = 'general.amount'; $translation = $this->getTextFromConfig($type, 'amount');
return $textAmount; if (!empty($translation)) {
return $translation;
}
return 'general.amount';
} }
protected function getHideItems($type, $hideItems, $hideName, $hideDescription) protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
@ -434,6 +421,12 @@ abstract class DocumentTemplate extends Component
return $hideItems; return $hideItems;
} }
$hide = $this->getHideFromConfig($type, 'items');
if ($hide) {
return $hide;
}
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false; $hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false;
return $hideItems; return $hideItems;
@ -445,18 +438,19 @@ abstract class DocumentTemplate extends Component
return $hideName; return $hideName;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideName = setting($type . '.hide_item_name', false)) {
case 'expense': return $hideName;
case 'purchase':
$hideName = setting('bill.hide_item_name', $hideName);
break;
default:
$hideName = setting('invoice.hide_item_name', $hideName);
break;
} }
return $hideName; $hide = $this->getHideFromConfig($type, 'name');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_item_name', $hideName);
} }
protected function getHideDescription($type, $hideDescription) protected function getHideDescription($type, $hideDescription)
@ -465,18 +459,19 @@ abstract class DocumentTemplate extends Component
return $hideDescription; return $hideDescription;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideDescription = setting($type . '.hide_item_description', false)) {
case 'expense': return $hideDescription;
case 'purchase':
$hideDescription = setting('bill.hide_item_description', $hideDescription);
break;
default:
$hideDescription = setting('invoice.hide_item_description', $hideDescription);
break;
} }
return $hideDescription; $hide = $this->getHideFromConfig($type, 'description');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_item_description', $hideDescription);
} }
protected function getHideQuantity($type, $hideQuantity) protected function getHideQuantity($type, $hideQuantity)
@ -485,18 +480,19 @@ abstract class DocumentTemplate extends Component
return $hideQuantity; return $hideQuantity;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideQuantity = setting($type . '.hide_quantity', false)) {
case 'expense': return $hideQuantity;
case 'purchase':
$hideQuantity = setting('bill.hide_quantity', $hideQuantity);
break;
default:
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
break;
} }
return $hideQuantity; $hide = $this->getHideFromConfig($type, 'quantity');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_quantity', $hideQuantity);
} }
protected function getHidePrice($type, $hidePrice) protected function getHidePrice($type, $hidePrice)
@ -505,18 +501,19 @@ abstract class DocumentTemplate extends Component
return $hidePrice; return $hidePrice;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hidePrice = setting($type . '.hide_price', false)) {
case 'expense': return $hidePrice;
case 'purchase':
$hidePrice = setting('bill.hide_price', $hidePrice);
break;
default:
$hidePrice = setting('invoice.hide_price', $hidePrice);
break;
} }
return $hidePrice; $hide = $this->getHideFromConfig($type, 'price');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_price', $hidePrice);
} }
protected function getHideDiscount($type, $hideDiscount) protected function getHideDiscount($type, $hideDiscount)
@ -525,18 +522,19 @@ abstract class DocumentTemplate extends Component
return $hideDiscount; return $hideDiscount;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideDiscount = setting($type . '.hide_discount', false)) {
case 'expense': return $hideDiscount;
case 'purchase':
$hideDiscount = setting('bill.hide_discount', $hideDiscount);
break;
default:
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
break;
} }
return $hideDiscount; $hide = $this->getHideFromConfig($type, 'discount');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_discount', $hideDiscount);
} }
protected function getHideAmount($type, $hideAmount) protected function getHideAmount($type, $hideAmount)
@ -545,17 +543,18 @@ abstract class DocumentTemplate extends Component
return $hideAmount; return $hideAmount;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideAmount = setting($type . '.hide_amount', false)) {
case 'expense':
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
}
return $hideAmount; return $hideAmount;
} }
$hide = $this->getHideFromConfig($type, 'amount');
if ($hide) {
return $hide;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_amount', $hideAmount);
}
} }

View File

@ -28,7 +28,7 @@ class Document extends FormRequest
{ {
$type = $this->request->get('type', Model::INVOICE_TYPE); $type = $this->request->get('type', Model::INVOICE_TYPE);
$type = config("type.{$type}.route_parameter"); $type = config('type.' . $type . '.route.parameter');
// Check if store or update // Check if store or update
if ($this->getMethod() == 'PATCH') { if ($this->getMethod() == 'PATCH') {

View File

@ -21,11 +21,15 @@ class MarkDocumentCancelled
{ {
$this->dispatch(new CancelDocument($event->document)); $this->dispatch(new CancelDocument($event->document));
$type = trans_choice( $type_text = '';
config("type.{$event->document->type}.alias", '') .
'general.' . config("type.{$event->document->type}.translation_key"), if ($alias = config('type.' . $event->document->type . '.alias', '')) {
1 $type_text .= $alias . '::';
); }
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
$type = trans_choice($type_text, 1);
$this->dispatch( $this->dispatch(
new CreateDocumentHistory( new CreateDocumentHistory(

View File

@ -24,11 +24,15 @@ class MarkDocumentReceived
$event->document->save(); $event->document->save();
} }
$type = trans_choice( $type_text = '';
config("type.{$event->document->type}.alias", '') .
'general.' . config("type.{$event->document->type}.translation_key"), if ($alias = config('type.' . $event->document->type . '.alias', '')) {
1 $type_text .= $alias . '::';
); }
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
$type = trans_choice($type_text, 1);
$this->dispatch( $this->dispatch(
new CreateDocumentHistory( new CreateDocumentHistory(

View File

@ -24,11 +24,15 @@ class MarkDocumentSent
$event->document->save(); $event->document->save();
} }
$type = trans_choice( $type_text = '';
config("type.{$event->document->type}.alias", '') .
'general.' . config("type.{$event->document->type}.translation_key"), if ($alias = config('type.' . $event->document->type . '.alias', '')) {
1 $type_text .= $alias . '::';
); }
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
$type = trans_choice($type_text, 1);
$this->dispatch( $this->dispatch(
new CreateDocumentHistory( new CreateDocumentHistory(

View File

@ -29,11 +29,15 @@ class MarkDocumentViewed
$document->status = 'viewed'; $document->status = 'viewed';
$document->save(); $document->save();
$type = trans_choice( $type_text = '';
config("type.{$event->document->type}.alias", '') .
'general.' . config("type.{$event->document->type}.translation_key"), if ($alias = config('type.' . $event->document->type . '.alias', '')) {
1 $type_text .= $alias . '::';
); }
$type_text .= 'general.' . config('type.' . $event->document->type .'.translation.prefix');
$type = trans_choice($type_text, 1);
$this->dispatch( $this->dispatch(
new CreateDocumentHistory( new CreateDocumentHistory(

View File

@ -104,7 +104,7 @@ class PaymentReceived extends Notification
$this->invoice->document_number, $this->invoice->document_number,
money($this->invoice->amount, $this->invoice->currency_code, true), money($this->invoice->amount, $this->invoice->currency_code, true),
company_date($this->invoice->due_at), company_date($this->invoice->due_at),
trans('invoices.statuses.' . $this->invoice->status), trans('documents.statuses.' . $this->invoice->status),
URL::signedRoute('signed.invoices.show', [$this->invoice->id, 'company_id' => $this->invoice->company_id]), URL::signedRoute('signed.invoices.show', [$this->invoice->id, 'company_id' => $this->invoice->company_id]),
route('invoices.show', $this->invoice->id), route('invoices.show', $this->invoice->id),
route('portal.invoices.show', $this->invoice->id), route('portal.invoices.show', $this->invoice->id),

View File

@ -3,6 +3,7 @@
namespace App\Traits; namespace App\Traits;
use App\Models\Document\Document; use App\Models\Document\Document;
use App\Abstracts\View\Components\Document as DocumentComponent;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -50,10 +51,14 @@ trait Documents
], ],
]; ];
$statuses = collect($list[$type])->each(function ($code) use ($type) { // @todo get dynamic path
//$trans_key = $this->getTextDocumentStatuses($type);
$trans_key = 'documents.statuses.';
$statuses = collect($list[$type])->each(function ($code) use ($type, $trans_key) {
$item = new \stdClass(); $item = new \stdClass();
$item->code = $code; $item->code = $code;
$item->name = trans(Str::plural($type) . '.statuses.' . $code); $item->name = trans($trans_key . $code);
return $item; return $item;
}); });
@ -70,4 +75,27 @@ trait Documents
{ {
return Str::slug($document->document_number, $separator, language()->getShortCode()); return Str::slug($document->document_number, $separator, language()->getShortCode());
} }
protected function getTextDocumentStatuses($type)
{
$default_key = config('type.' . $type . '.translation.prefix') . '.statuses.';
$translation = DocumentComponent::getTextFromConfig($type, 'document_status', $default_key);
if (!empty($translation)) {
return $translation;
}
$alias = config('type.' . $type . '.alias');
if (!empty($alias)) {
$translation = $alias . '::' . config('type.' . $type . '.translation.prefix') . '.statuses';
if (is_array(trans($translation))) {
return $translation . '.';
}
}
return 'documents.statuses.';
}
} }

View File

@ -405,7 +405,25 @@ trait Permissions
// Fire event to find the proper controller for common API endpoints // Fire event to find the proper controller for common API endpoints
if (in_array($table, ['contacts', 'documents', 'transactions'])) { if (in_array($table, ['contacts', 'documents', 'transactions'])) {
$controller = config('type.' . request()->get('type') . '.permission_name'); $controller = '';
$type = request()->get('type');
$alias = config('type.' . $type . '.alias');
$group = config('type.' . $type . '.group');
$prefix = config('type.' . $type . '.permission.prefix');
// if use module set module alias
if (!empty($alias)) {
$controller .= $alias . '-';
}
// if controller in folder it must
if (!empty($group)) {
$controller .= $group . '-';
}
$controller .= $prefix;
} else { } else {
$route = app(Route::class); $route = app(Route::class);

View File

@ -14,7 +14,7 @@ class Advanced extends Component
*/ */
public function render() public function render()
{ {
$category_type = $this->getCategoryType(); $category_type = $this->categoryType;
if ($category_type) { if ($category_type) {
$categories = Category::$category_type()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $categories = Category::$category_type()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
@ -24,31 +24,4 @@ class Advanced extends Component
return view('components.documents.form.advanced', compact('categories', 'category_type')); return view('components.documents.form.advanced', compact('categories', 'category_type'));
} }
protected function getCategoryType()
{
$type = '';
switch ($this->type) {
case 'bill':
case 'expense':
case 'purchase':
$type = 'expense';
break;
case 'item':
$type = 'item';
break;
case 'other':
$type = 'other';
break;
case 'transfer':
$type = 'transfer';
break;
default:
$type = 'income';
break;
}
return $type;
}
} }

View File

@ -16,7 +16,7 @@ class Company extends Component
{ {
$company = user()->companies()->first(); $company = user()->companies()->first();
$inputNameType = config("type.{$this->type}.route_parameter"); $inputNameType = config('type.' . $this->type . '.route.parameter');
return view('components.documents.form.company', compact('company','inputNameType')); return view('components.documents.form.company', compact('company','inputNameType'));
} }

View File

@ -3,42 +3,87 @@
use App\Models\Document\Document; use App\Models\Document\Document;
return [ return [
// Documents // Documents
Document::INVOICE_TYPE => [ Document::INVOICE_TYPE => [
'group' => 'sales', 'alias' => '', // core empty but module write own alias
'route_name' => 'invoices', 'group' => 'sales', // controller folder name for permission and route
'route_parameter' => 'invoice', 'route' => [
'permission_name' => 'sales-invoices', 'prefix' => 'invoices', // core use with group + prefix, module ex. estimates
'translation_key' => 'invoices', 'parameter' => 'invoice', // sales/invoices/{parameter}/edit
'contact_type' => 'customer', //'create' => 'invoices.create', // if you change route, you can write full path
],
'permission' => [
'prefix' => 'invoices', // this controller file name.
//'create' => 'create-sales-invoices', // if you change action permission key, you can write full permission
],
'translation' => [
'prefix' => 'invoices', // this translation file name.
'add_contact' => 'general.customers', //
'issued_at' => 'invoices.invoice_date',
'due_at' => 'invoices.due_date',
],
'category_type' => 'income',
'contact_type' => 'customer', // use contact type
'hide' => [], // for document items
'class' => [],
], ],
Document::BILL_TYPE => [ Document::BILL_TYPE => [
'alias' => '',
'group' => 'purchases', 'group' => 'purchases',
'route_name' => 'bills', 'route' => [
'route_parameter' => 'bill', 'prefix' => 'bills',
'permission_name' => 'purchases-bills', 'parameter' => 'bill',
'translation_key' => 'bills', //'create' => 'bilss.create',
],
'permission' => [
'prefix' => 'bills',
//'create' => 'create-purchases-bills',
],
'translation' => [
'prefix' => 'bills',
'issued_at' => 'bills.bill_date',
'due_at' => 'bills.due_date',
],
'category_type' => 'expense',
'contact_type' => 'vendor', 'contact_type' => 'vendor',
'hide' => [],
], ],
// Contacts // Contacts
'customer' => [ 'customer' => [
'permission_name' => 'sales-customers', 'group' => 'sales',
'permission' => [
'prefix' => 'customers',
//'create' => 'create-sales-customers',
],
], ],
'vendor' => [ 'vendor' => [
'permission_name' => 'purchases-vendors', 'group' => 'purchases',
'permission' => [
'prefix' => 'vendors',
//'create' => 'create-purchases-vendors',
],
], ],
// Transactions // Transactions
'income' => [ 'income' => [
'permission_name' => 'sales-revenues', 'group' => 'sales',
'permission' => [
'prefix' => 'revenues',
//'create' => 'create-sales-revenues',
],
'contact_type' => 'customer', 'contact_type' => 'customer',
], ],
'expense' => [ 'expense' => [
'permission_name' => 'purchases-payments', 'group' => 'purchases',
'permission' => [
'prefix' => 'payments',
//'create' => 'create-purchases-payments',
],
'contact_type' => 'vendor', 'contact_type' => 'vendor',
], ],
]; ];

View File

@ -38,16 +38,6 @@ return [
'receive_bill' => 'Receive Bill', 'receive_bill' => 'Receive Bill',
'make_payment' => 'Make Payment', 'make_payment' => 'Make Payment',
'statuses' => [
'draft' => 'Draft',
'received' => 'Received',
'partial' => 'Partial',
'paid' => 'Paid',
'overdue' => 'Overdue',
'unpaid' => 'Unpaid',
'cancelled' => 'Cancelled',
],
'messages' => [ 'messages' => [
'draft' => 'This is a <b>DRAFT</b> bill and will be reflected to charts after it gets received.', 'draft' => 'This is a <b>DRAFT</b> bill and will be reflected to charts after it gets received.',

View File

@ -1,8 +1,42 @@
<?php <?php
return [ return [
'statuses' => [
'draft' => 'Draft',
'sent' => 'Sent',
'expired' => 'Expired',
'viewed' => 'Viewed',
'approved' => 'Approved',
'received' => 'Received',
'refused' => 'Refused',
'restored' => 'Restored',
'reversed' => 'Reversed',
'partial' => 'Partial',
'paid' => 'Paid',
'pending' => 'Pending',
'invoiced' => 'Invoiced',
'overdue' => 'Overdue',
'unpaid' => 'Unpaid',
'cancelled' => 'Cancelled',
'voided' => 'Voided',
'completed' => 'Completed',
'shipped' => 'Shipped',
'refunded' => 'Refunded',
'failed' => 'Failed',
'denied' => 'Denied',
'processed' => 'Processed',
'open' => 'Open',
'closed' => 'Closed',
'billed' => 'Billed',
'delivered' => 'Delivered',
'returned' => 'Returned',
'drawn' => 'Drawn',
],
'messages' => [ 'messages' => [
'email_sent' => ':type email has been sent!', 'email_sent' => ':type email has been sent!',
'marked_as' => ':type marked as :status!',
'marked_sent' => ':type marked as sent!', 'marked_sent' => ':type marked as sent!',
'marked_paid' => ':type marked as paid!', 'marked_paid' => ':type marked as paid!',
'marked_viewed' => ':type marked as viewed!', 'marked_viewed' => ':type marked as viewed!',

View File

@ -40,18 +40,6 @@ return [
'get_paid' => 'Get Paid', 'get_paid' => 'Get Paid',
'accept_payments' => 'Accept Online Payments', 'accept_payments' => 'Accept Online Payments',
'statuses' => [
'draft' => 'Draft',
'sent' => 'Sent',
'viewed' => 'Viewed',
'approved' => 'Approved',
'partial' => 'Partial',
'paid' => 'Paid',
'overdue' => 'Overdue',
'unpaid' => 'Unpaid',
'cancelled' => 'Cancelled',
],
'messages' => [ 'messages' => [
'email_required' => 'No email address for this customer!', 'email_required' => 'No email address for this customer!',
'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.',

View File

@ -15,7 +15,7 @@
<div class="col-sm-6 col-md-6 col-lg-6 col-xl-6"> <div class="col-sm-6 col-md-6 col-lg-6 col-xl-6">
@if (!$hideCategory) @if (!$hideCategory)
{{ Form::selectRemoteAddNewGroup('category_id', trans_choice('general.categories', 1), 'folder', $categories, setting('default.' . $category_type . '_category'), ['required' => 'required', 'path' => route('modals.categories.create') . '?type=' . $category_type, 'remote_action' => route('categories.index'). '?type=' . $category_type], 'col-md-12') }} {{ Form::selectRemoteAddNewGroup('category_id', trans_choice('general.categories', 1), 'folder', $categories, setting('default.' . $categoryType . '_category'), ['required' => 'required', 'path' => route('modals.categories.create') . '?type=' . $categoryType, 'remote_action' => route('categories.index'). '?type=' . $categoryType], 'col-md-12') }}
@endif @endif
@if (!$hideAttachment) @if (!$hideAttachment)

View File

@ -2,7 +2,7 @@
<div class="card"> <div class="card">
<div class="card-footer"> <div class="card-footer">
<div class="row save-buttons"> <div class="row save-buttons">
{{ Form::saveButtons('invoices.index') }} {{ Form::saveButtons($routeCancel) }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,6 +1,6 @@
@if (empty($document)) @if (empty($document))
{!! Form::open([ {!! Form::open([
'route' => $formRoute, 'route' => $routeStore,
'id' => $formId, 'id' => $formId,
'@submit.prevent' => $formSubmit, '@submit.prevent' => $formSubmit,
'@keydown' => 'form.errors.clear($event.target.name)', '@keydown' => 'form.errors.clear($event.target.name)',
@ -11,7 +11,7 @@
]) !!} ]) !!}
@else @else
{!! Form::model($document, [ {!! Form::model($document, [
'route' => [$formRoute, $document->id], 'route' => [$routeUpdate, $document->id],
'id' => $formId, 'id' => $formId,
'method' => 'PATCH', 'method' => 'PATCH',
'@submit.prevent' => $formSubmit, '@submit.prevent' => $formSubmit,
@ -78,6 +78,7 @@
<x-documents.form.advanced <x-documents.form.advanced
type="{{ $type }}" type="{{ $type }}"
:document="$document" :document="$document"
category-type="{{ $categoryType }}"
hide-recurring="{{ $hideRecurring }}" hide-recurring="{{ $hideRecurring }}"
hide-category="{{ $hideCategory }}" hide-category="{{ $hideCategory }}"
hide-attachment="{{ $hideAttachment }}" hide-attachment="{{ $hideAttachment }}"
@ -88,6 +89,7 @@
<x-documents.form.buttons <x-documents.form.buttons
type="{{ $type }}" type="{{ $type }}"
:document="$document" :document="$document"
route-cancel="{{ $routeCancel }}"
/> />
@endif @endif

View File

@ -57,7 +57,7 @@
@if($item->bill) @if($item->bill)
@if ($item->bill->status == 'paid') @if ($item->bill->status == 'paid')
<el-tooltip content="{{ $item->bill->document_number }} / {{ trans('bills.statuses.paid') }}" <el-tooltip content="{{ $item->bill->document_number }} / {{ trans('documents.statuses.paid') }}"
effect="success" effect="success"
:open-delay="100" :open-delay="100"
placement="top"> placement="top">
@ -66,7 +66,7 @@
</span> </span>
</el-tooltip> </el-tooltip>
@elseif ($item->bill->status == 'partial') @elseif ($item->bill->status == 'partial')
<el-tooltip content="{{ $item->bill->document_number }} / {{ trans('bills.statuses.partial') }}" <el-tooltip content="{{ $item->bill->document_number }} / {{ trans('documents.statuses.partial') }}"
effect="info" effect="info"
:open-delay="100" :open-delay="100"
placement="top"> placement="top">

View File

@ -194,7 +194,7 @@
<td class="col-xs-4 col-sm-3 text-right">@money($item->amount, $item->currency_code, true)</td> <td class="col-xs-4 col-sm-3 text-right">@money($item->amount, $item->currency_code, true)</td>
<td class="col-sm-3 d-none d-sm-block text-left">@date($item->issued_at)</td> <td class="col-sm-3 d-none d-sm-block text-left">@date($item->issued_at)</td>
<td class="col-sm-3 d-none d-sm-block text-left">@date($item->due_at)</td> <td class="col-sm-3 d-none d-sm-block text-left">@date($item->due_at)</td>
<td class="col-xs-4 col-sm-2"><span class="badge badge-pill badge-{{ $item->status_label }} my--2">{{ trans('bills.statuses.' . $item->status) }}</span></td> <td class="col-xs-4 col-sm-2"><span class="badge badge-pill badge-{{ $item->status_label }} my--2">{{ trans('documents.statuses.' . $item->status) }}</span></td>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>

View File

@ -194,7 +194,7 @@
<td class="col-xs-4 col-sm-3 text-right">@money($item->amount, $item->currency_code, true)</td> <td class="col-xs-4 col-sm-3 text-right">@money($item->amount, $item->currency_code, true)</td>
<td class="col-sm-3 d-none d-sm-block text-left">@date($item->issued_at)</td> <td class="col-sm-3 d-none d-sm-block text-left">@date($item->issued_at)</td>
<td class="col-sm-3 d-none d-sm-block text-left">@date($item->due_at)</td> <td class="col-sm-3 d-none d-sm-block text-left">@date($item->due_at)</td>
<td class="col-xs-4 col-sm-2"><span class="badge badge-pill badge-{{ $item->status_label }} my--2">{{ trans('invoices.statuses.' . $item->status) }}</span></td> <td class="col-xs-4 col-sm-2"><span class="badge badge-pill badge-{{ $item->status_label }} my--2">{{ trans('documents.statuses.' . $item->status) }}</span></td>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>

View File

@ -57,7 +57,7 @@
@if($item->invoice) @if($item->invoice)
@if ($item->invoice->status == 'paid') @if ($item->invoice->status == 'paid')
<el-tooltip content="{{ $item->invoice->document_number }} / {{ trans('invoices.statuses.paid') }}" <el-tooltip content="{{ $item->invoice->document_number }} / {{ trans('documents.statuses.paid') }}"
effect="success" effect="success"
:open-delay="100" :open-delay="100"
placement="top"> placement="top">
@ -66,7 +66,7 @@
</span> </span>
</el-tooltip> </el-tooltip>
@elseif ($item->invoice->status == 'partial') @elseif ($item->invoice->status == 'partial')
<el-tooltip content="{{ $item->invoice->document_number }} / {{ trans('invoices.statuses.partial') }}" <el-tooltip content="{{ $item->invoice->document_number }} / {{ trans('documents.statuses.partial') }}"
effect="info" effect="info"
:open-delay="100" :open-delay="100"
placement="top"> placement="top">