akaunting 3.0 (the last dance)

This commit is contained in:
Burak Civan
2022-06-01 10:15:55 +03:00
parent cead09f6d4
commit d9c0764572
3812 changed files with 126831 additions and 102949 deletions

View File

@ -2,8 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Models\Setting\Category;
use App\Abstracts\View\Components\Documents\Form as Component;
class Advanced extends Component
{
@ -14,39 +13,6 @@ class Advanced extends Component
*/
public function render()
{
$category_type = $this->categoryType;
if ($category_type) {
$categories = Category::$category_type()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
} else {
$categories = Category::enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
}
if (!empty($this->document) && ($this->document->category && !$categories->has($this->document->category_id))) {
$categories->put($this->document->category->id, $this->document->category->name);
}
$recurring_class = 'col-sm-6 col-md-6 col-lg-6 col-xl-6';
$more_class = 'col-sm-6 col-md-6 col-lg-6 col-xl-6';
$more_form_class = 'col-md-12';
if ($this->hideRecurring && (!$this->hideCategory || !$this->hideAttachment)) {
$more_class = 'col-sm-12 col-md-12 col-lg-12 col-xl-12';
$more_form_class = 'col-md-6';
} else if ($this->hideRecurring && ($this->hideCategory && $this->hideAttachment)) {
$recurring_class = 'col-sm-12 col-md-12 col-lg-12 col-xl-12';
}
$file_type_mimes = explode(',', config('filesystems.mimes'));
$file_types = [];
foreach ($file_type_mimes as $mime) {
$file_types[] = '.' . $mime;
}
$file_types = implode(',', $file_types);
return view('components.documents.form.advanced', compact('categories', 'category_type', 'recurring_class', 'more_class', 'more_form_class', 'file_types'));
return view('components.documents.form.advanced');
}
}

View File

@ -2,7 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Abstracts\View\Components\Documents\Form as Component;
class Buttons extends Component
{

View File

@ -2,7 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Abstracts\View\Components\Documents\Form as Component;
use App\Models\Common\Company as Model;
class Company extends Component
@ -16,7 +16,7 @@ class Company extends Component
{
$company = Model::find(company_id());
$inputNameType = config('type.' . $this->type . '.route.parameter');
$inputNameType = config('type.document.' . $this->type . '.route.parameter');
return view('components.documents.form.company', compact('company', 'inputNameType'));
}

View File

@ -0,0 +1,230 @@
<?php
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Component;
use App\Models\Common\Contact as Model;
use Illuminate\Support\Str;
class Contact extends Component
{
public $type;
public $contact;
public $placeholder;
public $contacts;
public $searchRoute;
public $createRoute;
/** @var string */
public $textAddContact;
/** @var string */
public $textCreateNewContact;
/** @var string */
public $textEditContact;
/** @var string */
public $textContactInfo;
/** @var string */
public $textChooseDifferentContact;
/** @var $error */
public $error;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
$type, $contact = false, $contacts = [], $searchRoute = '', $createRoute = '', string $error = '',
$textAddContact = '', $textCreateNewContact = '', $textEditContact = '', $textContactInfo = '', $textChooseDifferentContact = ''
) {
$this->type = $type;
$this->contact = $contact;
$this->contacts = $contacts;
$this->searchRoute = $searchRoute;
$this->createRoute = $createRoute;
$this->error = ($error) ?: "form.errors.get('contact_id')" ;
$this->textAddContact = $this->getTextAddContact($type, $textAddContact);
$this->textCreateNewContact = $this->getTextCreateNewContact($type, $textCreateNewContact);
$this->textEditContact = $this->getTextEditContact($type, $textEditContact);
$this->textContactInfo = $this->getTextContactInfo($type, $textContactInfo);
$this->textChooseDifferentContact = $this->getTextChooseDifferentContact($type, $textChooseDifferentContact);
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
if (empty($this->contacts)) {
$this->contacts = Model::{$this->type}()->enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
if (!empty($this->contact) && (!$this->contacts->contains('id', $contact->id))) {
$this->contacts->push($this->contact);
}
}
if (empty($this->searchRoute)) {
switch ($this->type) {
case 'customer':
$this->searchRoute = route('customers.index');
break;
case 'vendor':
$this->searchRoute = route('vendors.index');
break;
}
}
if (empty($this->createRoute)) {
switch ($this->type) {
case 'customer':
$this->createRoute = route('modals.customers.create');
break;
case 'vendor':
$this->createRoute = route('modals.vendors.create');
break;
}
}
#todo 3rd part apps
$this->placeholder = trans('general.placeholder.contact_search', ['type' => trans_choice('general.' . Str::plural($this->type, 2), 1)]);
return view('components.documents.form.contact');
}
protected function getTextAddContact($type, $textAddContact)
{
if (!empty($textAddContact)) {
return $textAddContact;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textAddContact = [
'general.form.add',
'general.vendors'
];
break;
default:
$textAddContact = [
'general.form.add',
'general.customers'
];
break;
}
return $textAddContact;
}
protected function getTextCreateNewContact($type, $textCreateNewContact)
{
if (!empty($textCreateNewContact)) {
return $textCreateNewContact;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textCreateNewContact = [
'general.form.add_new',
'general.vendors'
];
break;
default:
$textCreateNewContact = [
'general.form.add_new',
'general.customers'
];
break;
}
return $textCreateNewContact;
}
protected function getTextEditContact($type, $textEditContact)
{
if (!empty($textEditContact)) {
return $textEditContact;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textEditContact = [
'general.form.contact_edit',
'general.vendors'
];
break;
default:
$textEditContact = [
'general.form.contact_edit',
'general.customers'
];
break;
}
return $textEditContact;
}
protected function getTextContactInfo($type, $textContactInfo)
{
if (!empty($textContactInfo)) {
return $textContactInfo;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textContactInfo = 'bills.bill_from';
break;
default:
$textContactInfo = 'invoices.bill_to';
break;
}
return $textContactInfo;
}
protected function getTextChooseDifferentContact($type, $textChooseDifferentContact)
{
if (!empty($textChooseDifferentContact)) {
return $textChooseDifferentContact;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$textChooseDifferentContact = [
'general.form.choose_different',
'general.vendors'
];
break;
default:
$textChooseDifferentContact = [
'general.form.choose_different',
'general.customers'
];
break;
}
return $textChooseDifferentContact;
}
}

View File

@ -2,7 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Abstracts\View\Components\Documents\Form as Component;
class Content extends Component
{
@ -15,7 +15,7 @@ class Content extends Component
{
$status = 'draft';
if (!empty($this->document)) {
if (! empty($this->document)) {
$status = $this->document->status;
}

View File

@ -2,7 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Abstracts\View\Components\Documents\Form as Component;
class Footer extends Component
{

View File

@ -0,0 +1,81 @@
<?php
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Component;
use App\Models\Common\Item;
class ItemButton extends Component
{
/** @var string */
public $type;
/** @var bool */
public $isSale;
/** @var bool */
public $isPurchase;
/** @var int */
public $searchCharLimit;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(string $type = 'sale', bool $isSale = false, bool $isPurchase = false, int $searchCharLimit = 3)
{
$this->type = $type;
$this->isSale = $isSale;
$this->isPurchase = $isPurchase;
$this->searchCharLimit = $searchCharLimit;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
$items = Item::enabled()->orderBy('name')->take(setting('default.select_limit'))->get();
$price_type = $this->getPriceType($this->type, $this->isSale, $this->isPurchase);
foreach ($items as $item) {
$price = $item->{$price_type . '_price'};
$item->price = $price;
}
$price = $price_type . '_price';
return view('components.documents.form.item-button', compact('items', 'price'));
}
protected function getPriceType($type, $is_sale, $is_purchase)
{
if (!empty($is_sale)) {
return 'sale';
}
if (!empty($is_purchase)) {
return 'purchase';
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$type = 'purchase';
break;
case 'sale':
case 'income':
case 'invoice':
default:
$type = 'sale';
}
return $type;
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Component;
class ItemColumns extends Component
{
/* string */
public $type;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(string $type = 'invoice')
{
$this->type = $type;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view('components.documents.form.item-columns');
}
}

View File

@ -2,7 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Abstracts\View\Components\Documents\Form as Component;
use App\Models\Setting\Tax;
class Items extends Component

View File

@ -2,7 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Abstracts\View\Components\Documents\Form as Component;
class LineItem extends Component
{

View File

@ -2,7 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Abstracts\View\Components\Documents\Form as Component;
class Main extends Component
{

View File

@ -2,7 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Abstracts\View\Components\Documents\Form as Component;
class Metadata extends Component
{

View File

@ -2,7 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Abstracts\View\Components\Documents\Form as Component;
class Note extends Component
{

View File

@ -0,0 +1,18 @@
<?php
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\Documents\Form as Component;
class Recurring extends Component
{
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view('components.documents.form.recurring');
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\Documents\Form as Component;
class RecurringMetadata extends Component
{
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
$payment_terms = [
'0' => trans('settings.invoice.due_receipt'),
'15' => trans('settings.invoice.due_days', ['days' => 15]),
'30' => trans('settings.invoice.due_days', ['days' => 30]),
'45' => trans('settings.invoice.due_days', ['days' => 45]),
'60' => trans('settings.invoice.due_days', ['days' => 60]),
'90' => trans('settings.invoice.due_days', ['days' => 90]),
];
return view('components.documents.form.recurring_metadata', compact('payment_terms'));
}
}

View File

@ -2,7 +2,7 @@
namespace App\View\Components\Documents\Form;
use App\Abstracts\View\Components\DocumentForm as Component;
use App\Abstracts\View\Components\Documents\Form as Component;
class Totals extends Component
{