Merge Invoice and Bill into Document

This commit is contained in:
Burak Çakırel
2020-12-24 01:28:38 +03:00
parent 830cc05957
commit 0c1424db47
436 changed files with 31655 additions and 37350 deletions

View File

@ -0,0 +1,82 @@
<?php
namespace App\View\Components\Documents\Form;
use Illuminate\View\Component;
use App\Models\Setting\Category;
class Advanced extends Component
{
/** @var string */
public $type;
/** @var bool */
public $hideRecurring;
/** @var bool */
public $hideCategory;
/** @var bool */
public $hideAttachment;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(string $type, bool $hideRecurring = false, bool $hideCategory = false, bool $hideAttachment = false)
{
$this->type = $type;
$this->hideRecurring = $hideRecurring;
$this->hideCategory = $hideCategory;
$this->hideAttachment = $hideAttachment;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
$category_type = $this->getCategoryType();
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');
}
return view('components.documents.form.advanced', compact('categories', 'category_type'));
}
protected function getCategoryType()
{
$type = '';
switch ($this->type) {
case 'sale':
case 'income':
case 'invoice':
$type = 'income';
break;
case 'bill':
case 'expense':
case 'purchase':
$type = 'expense';
break;
case 'item':
$type = 'item';
break;
case 'other':
$type = 'other';
break;
case 'transfer':
$type = 'transfer';
break;
}
return $type;
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\View\Components\Documents\Form;
use Illuminate\View\Component;
class Buttons extends Component
{
/** @var string */
public $type;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($type)
{
$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.buttons');
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace App\View\Components\Documents\Form;
use Illuminate\Support\Str;
use Illuminate\View\Component;
class Company extends Component
{
/** @var string */
public $type;
/** @var bool */
public $hideLogo;
/** @var bool */
public $hideDocumentTitle;
/** @var bool */
public $hideDocumentSubheading;
/** @var bool */
public $hideCompanyEdit;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $type, bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false
) {
$this->type = $type;
$this->hideLogo = $hideLogo;
$this->hideDocumentTitle = $hideDocumentTitle;
$this->hideDocumentSubheading = $hideDocumentSubheading;
$this->hideCompanyEdit = $hideCompanyEdit;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
$company = user()->companies()->first();
$inputNameType = Str::replaceFirst('-', '_', $this->type);
return view('components.documents.form.company', compact('company','inputNameType'));
}
protected function getFilterName($column)
{
if (strpos($column, '_id') !== false) {
$column = str_replace('_id', '', $column);
} else if (strpos($column, '_code') !== false) {
$column = str_replace('_code', '', $column);
}
$plural = Str::plural($column, 2);
if (trans_choice('general.' . $plural, 1) !== 'general.' . $plural) {
return trans_choice('general.' . $plural, 1);
} elseif (trans_choice('search_string.columns.' . $plural, 1) !== 'search_string.columns.' . $plural) {
return trans_choice('search_string.columns.' . $plural, 1);
}
$name = trans('general.' . $column);
if ($name == 'general.' . $column) {
$name = trans('search_string.columns.' . $column);
}
return $name;
}
}

View File

@ -0,0 +1,183 @@
<?php
namespace App\View\Components\Documents\Form;
use Illuminate\View\Component;
use Illuminate\Support\Str;
class Content extends Component
{
/** @var string */
public $type;
public $document;
/** @var string */
public $formRoute;
/** @var string */
public $formId;
/** @var string */
public $formSubmit;
/** @var bool */
public $hideCompany;
/** @var bool */
public $hideAdvanced;
/** @var bool */
public $hideFooter;
/** @var bool */
public $hideButtons;
/* Company Component Field Status */
/** @var bool */
public $hideLogo;
/** @var bool */
public $hideDocumentTitle;
/** @var bool */
public $hideDocumentSubheading;
/** @var bool */
public $hideCompanyEdit;
/* Company Component Field Status */
/* Main.Header Fields */
/** @var string */
public $contactType;
/** @var string */
public $documentNumber;
/** @var string */
public $textIssuedAt;
/** @var string */
public $textDueAt;
/** @var string */
public $textDocumentNumber;
/** @var string */
public $textOrderNumber;
/* Main.Header Fields */
/* Main.Header Component Field Status */
/** @var bool */
public $hideContact;
/** @var bool */
public $hideIssuedAt;
/** @var bool */
public $hideDocumentNumber;
/** @var bool */
public $hideDueAt;
/** @var bool */
public $hideOrderNumber;
/* Main.Header Component Field Status */
/* Advanced Component Field Status */
/** @var bool */
public $hideRecurring;
/** @var bool */
public $hideCategory;
/** @var bool */
public $hideAttachment;
/* Advanced Component Field Status */
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $type, $document = false, string $formRoute = '', string $formId = 'document', string $formSubmit = 'onSubmit', bool $hideCompany = false, bool $hideAdvanced = false, bool $hideFooter = false, bool $hideButtons = false,
bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false, // Company
string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '', // Main.Header
string $contactType = '', string $documentNumber = '',
bool $hideContact = false, bool $hideIssuedAt = false, bool $hideDocumentNumber = false, bool $hideDueAt = false, bool $hideOrderNumber = false, // Main.Header
bool $hideRecurring = false, bool $hideCategory = false, bool $hideAttachment = false // Advanced
)
{
$this->type = $type;
$this->document = $document;
$this->formRoute = ($formRoute) ? $formRoute : $this->getRoute($type, $document);
$this->formId = $formId;
$this->formSubmit = $formSubmit;
$this->hideCompany = $hideCompany;
$this->hideAdvanced = $hideAdvanced;
$this->hideFooter = $hideFooter;
$this->hideButtons = $hideButtons;
// Company component fields status
$this->hideLogo = $hideLogo;
$this->hideDocumentTitle = $hideDocumentTitle;
$this->hideDocumentSubheading = $hideDocumentSubheading;
$this->hideCompanyEdit = $hideCompanyEdit;
// Main.Header fields
$this->contactType = $contactType;
$this->documentNumber = $documentNumber;
$this->textIssuedAt = $textIssuedAt;
$this->textDocumentNumber = $textDocumentNumber;
$this->textDueAt = $textDueAt;
$this->textOrderNumber = $textOrderNumber;
// Main.Header component fields status
$this->hideContact = $hideContact;
$this->hideIssuedAt = $hideIssuedAt;
$this->hideDocumentNumber = $hideDocumentNumber;
$this->hideDueAt = $hideDueAt;
$this->hideOrderNumber = $hideOrderNumber;
// Advanced component fields status
$this->hideRecurring = $hideRecurring;
$this->hideCategory = $hideCategory;
$this->hideAttachment = $hideAttachment;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view('components.documents.form.content');
}
protected function getRoute($type, $document, $parameters = [])
{
$page = Str::plural($type, 2);
$route = $page . '.store';
if ($document) {
$parameters = [
Str::replaceFirst('-', '_', $type) => $document->id
];
$route = $page . '.update';
}
try {
route($route, $parameters);
} catch (\Exception $e) {
$route = '';
}
return $route;
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\View\Components\Documents\Form;
use Illuminate\View\Component;
class Footer extends Component
{
/** @var string */
public $type;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($type)
{
$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.footer');
}
}

View File

@ -0,0 +1,338 @@
<?php
namespace App\View\Components\Documents\Form;
use Illuminate\View\Component;
use App\Models\Setting\Currency;
use App\Models\Setting\Tax;
class Items extends Component
{
/** @var string */
public $type;
public $document;
/** @var bool */
public $hideEditItemColumns;
/** @var string */
public $textItems;
/** @var string */
public $textQuantity;
/** @var string */
public $textPrice;
/** @var string */
public $textAmount;
/** @var bool */
public $hideItems;
/** @var bool */
public $hideName;
/** @var bool */
public $hideDescription;
/** @var bool */
public $hideQuantity;
/** @var bool */
public $hidePrice;
/** @var bool */
public $hideDiscount;
/** @var bool */
public $hideAmount;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $type, $document = false,
string $textItems = '', string $textQuantity = '', string $textPrice = '', string $textAmount = '',
bool $hideItems = false, bool $hideName = false, bool $hideDescription = false, bool $hideQuantity = false,
bool $hidePrice = false, bool $hideDiscount = false, bool $hideAmount = false,
bool $hideEditItemColumns = false
) {
$this->type = $type;
$this->document = $document;
$this->textItems = $this->getTextItems($type, $textItems);
$this->textQuantity = $this->getTextQuantity($type, $textQuantity);
$this->textPrice = $this->getTextPrice($type, $textPrice);
$this->textAmount = $this->getTextAmount($type, $textAmount);
$this->hideItems = $this->getHideItems($type, $hideItems, $hideName, $hideDescription);
$this->hideName = $this->getHideName($type, $hideName);
$this->hideDescription = $this->getHideDescription($type, $hideDescription);
$this->hideQuantity = $this->getHideQuantity($type, $hideQuantity);
$this->hidePrice = $this->getHidePrice($type, $hidePrice);
$this->hideDiscount = $this->getHideDiscount($type, $hideDiscount);
$this->hideAmount = $this->getHideAmount($type, $hideAmount);
$this->hideEditItemColumns = $hideEditItemColumns;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
$currency = Currency::where('code', setting('default.currency'))->first();
$taxes = Tax::enabled()->orderBy('name')->get();
return view('components.documents.form.items', compact('currency', 'taxes'));
}
protected function getTextItems($type, $text_items)
{
if (!empty($text_items)) {
return $text_items;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$text_items = trans_choice(setting('invoice.item_name', 'general.items'), 2);
if ($text_items == 'custom') {
$text_items = setting('invoice.item_name_input');
}
break;
case 'bill':
case 'expense':
case 'purchase':
$text_items = trans_choice('general.items', 2);
break;
}
return $text_items;
}
protected function getTextQuantity($type, $text_quantity)
{
if (!empty($text_quantity)) {
return $text_quantity;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$text_quantity = trans(setting('invoice.quantity_name', 'invoices.quantity'));
if ($text_quantity == 'custom') {
$text_quantity = setting('invoice.quantity_name_input');
}
break;
case 'bill':
case 'expense':
case 'purchase':
$text_quantity = trans('bills.quantity');
break;
}
return $text_quantity;
}
protected function getTextPrice($type, $text_price)
{
if (!empty($text_price)) {
return $text_price;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$text_price = trans(setting('invoice.price_name', 'invoices.price'));
if ($text_price == 'custom') {
$text_price = setting('invoice.price_name_input');
}
break;
case 'bill':
case 'expense':
case 'purchase':
$text_price = trans('bills.price');
break;
}
return $text_price;
}
protected function getTextAmount($type, $text_amount)
{
if (!empty($text_amount)) {
return $text_amount;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
case 'bill':
case 'expense':
case 'purchase':
$text_amount = trans('general.amount');
break;
}
return $text_amount;
}
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
{
if (!empty($hideItems)) {
return $hideItems;
}
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false;
return $hideItems;
}
protected function getHideName($type, $hideName)
{
if (!empty($hideName)) {
return $hideName;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hideName = setting('invoice.hide_item_name', $hideName);
break;
case 'bill':
case 'expense':
case 'purchase':
$hideName = setting('bill.hide_item_name', $hideName);
break;
}
return $hideName;
}
protected function getHideDescription($type, $hideDescription)
{
if (!empty($hideDescription)) {
return $hideDescription;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hideDescription = setting('invoice.hide_item_description', $hideDescription);
break;
case 'bill':
case 'expense':
case 'purchase':
$hideDescription = setting('bill.hide_item_description', $hideDescription);
break;
}
return $hideDescription;
}
protected function getHideQuantity($type, $hideQuantity)
{
if (!empty($hideQuantity)) {
return $hideQuantity;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
break;
case 'bill':
case 'expense':
case 'purchase':
$hideQuantity = setting('bill.hide_quantity', $hideQuantity);
break;
}
return $hideQuantity;
}
protected function getHidePrice($type, $hidePrice)
{
if (!empty($hidePrice)) {
return $hidePrice;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hidePrice = setting('invoice.hide_price', $hidePrice);
break;
case 'bill':
case 'expense':
case 'purchase':
$hidePrice = setting('bill.hide_price', $hidePrice);
break;
}
return $hidePrice;
}
protected function getHideDiscount($type, $hideDiscount)
{
if (!empty($hideDiscount)) {
return $hideDiscount;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
break;
case 'bill':
case 'expense':
case 'purchase':
$hideDiscount = setting('bill.hide_discount', $hideDiscount);
break;
}
return $hideDiscount;
}
protected function getHideAmount($type, $hideAmount)
{
if (!empty($hideAmount)) {
return $hideAmount;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
case 'bill':
case 'expense':
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
}
return $hideAmount;
}
}

View File

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

View File

@ -0,0 +1,91 @@
<?php
namespace App\View\Components\Documents\Form;
use Illuminate\View\Component;
class Main extends Component
{
/** @var string */
public $type;
public $document;
/* Main.Header Fields */
/** @var string */
public $contactType;
/** @var string */
public $documentNumber;
/** @var string */
public $textIssuedAt;
/** @var string */
public $textDueAt;
/** @var string */
public $textDocumentNumber;
/** @var string */
public $textOrderNumber;
/* Main.Header Fields */
/* Main.Header Component Field Status */
/** @var bool */
public $hideContact;
/** @var bool */
public $hideIssuedAt;
/** @var bool */
public $hideDocumentNumber;
/** @var bool */
public $hideDueAt;
/** @var bool */
public $hideOrderNumber;
/* Main.Header Component Field Status */
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
$type, $document = false,
string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '', // Main.Header
string $contactType = '', string $documentNumber = '',
bool $hideContact = false, bool $hideIssuedAt = false, bool $hideDocumentNumber = false, bool $hideDueAt = false, bool $hideOrderNumber = false // Main.Header
) {
$this->type = $type;
$this->document = $document;
// Main.Header fields
$this->contactType = $contactType;
$this->documentNumber = $documentNumber;
$this->textIssuedAt = $textIssuedAt;
$this->textDocumentNumber = $textDocumentNumber;
$this->textDueAt = $textDueAt;
$this->textOrderNumber = $textOrderNumber;
// Main.Header component fields status
$this->hideContact = $hideContact;
$this->hideIssuedAt = $hideIssuedAt;
$this->hideDocumentNumber = $hideDocumentNumber;
$this->hideDueAt = $hideDueAt;
$this->hideOrderNumber = $hideOrderNumber;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view('components.documents.form.main');
}
}

View File

@ -0,0 +1,324 @@
<?php
namespace App\View\Components\Documents\Form;
use App\Models\Common\Contact;
use App\Models\Document\Document;
use App\Traits\Documents;
use Date;
use Illuminate\View\Component;
use Illuminate\Support\Str;
class Metadata extends Component
{
use Documents;
/** @var string */
public $type;
public $document;
public $contacts;
/** @var string */
public $contactType;
/** @var bool */
public $hideContact;
/** @var bool */
public $hideIssuedAt;
/** @var bool */
public $hideDocumentNumber;
/** @var bool */
public $hideDueAt;
/** @var bool */
public $hideOrderNumber;
/** @var string */
public $issuedAt;
/** @var string */
public $documentNumber;
/** @var string */
public $dueAt;
/** @var string */
public $orderNumber;
/** @var string */
public $textIssuedAt;
/** @var string */
public $textDueAt;
/** @var string */
public $textDocumentNumber;
/** @var string */
public $textOrderNumber;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $type, $document = false, $contacts = [], string $contactType = '',
bool $hideContact = false, bool $hideIssuedAt = false, bool $hideDocumentNumber = false, bool $hideDueAt = false, bool $hideOrderNumber = false,
string $textDocumentNumber = '', string $textOrderNumber = '', string $textIssuedAt = '', string $textDueAt = '',
string $issuedAt = '', string $documentNumber = '', string $dueAt = '', string $orderNumber = ''
) {
$this->type = $type;
$this->document = $document;
$this->contacts = $this->getContacts($type, $contacts);
$this->contactType = $this->getContactType($type, $contactType);
$this->hideContact = $hideContact;
$this->hideIssuedAt = $hideIssuedAt;
$this->hideDocumentNumber = $hideDocumentNumber;
$this->hideDueAt = $hideDueAt;
$this->hideOrderNumber = $hideOrderNumber;
$this->issuedAt = $this->getissuedAt($type, $document, $issuedAt);
$this->documentNumber = $this->getDocumentNumber($type, $document, $documentNumber);
$this->dueAt = $this->getDueAt($type, $document, $dueAt);
$this->orderNumber = $this->getOrderNumber($type, $document, $orderNumber);
$this->textIssuedAt = $this->gettextIssuedAt($type, $textIssuedAt);
$this->textDocumentNumber = $this->getTextDocumentNumber($type, $textDocumentNumber);
$this->textDueAt = $this->getTextDueAt($type, $textDueAt);
$this->textOrderNumber = $this->getTextOrderNumber($type, $textOrderNumber);
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view('components.documents.form.metadata');
}
protected function getContacts($type, $contacts)
{
if (!empty($contacts)) {
return $contacts;
}
$contact_type = $this->getContactType($type, null);
if ($contact_type) {
$contacts = Contact::$contact_type()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
} else {
$contacts = Contact::enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id');
}
return $contacts;
}
protected function getContactType($type, $contact_type)
{
if (!empty($contact_type)) {
return $contact_type;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$contact_type = 'customer';
break;
case 'bill':
case 'expense':
case 'purchase':
$contact_type = 'vendor';
break;
}
return $contact_type;
}
protected function getissuedAt($type, $document, $issued_at)
{
if (!empty($issued_at)) {
return $issued_at;
}
if ($document) {
return $document->issued_at;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$issued_at = request()->get('invoiced_at', Date::now()->toDateString());
break;
case 'bill':
case 'expense':
case 'purchase':
$issued_at = request()->get('billed_at', Date::now()->toDateString());
break;
}
return $issued_at;
}
protected function getDocumentNumber($type, $document, $document_number)
{
if (!empty($document_number)) {
return $document_number;
}
if ($document) {
return $document->document_number;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE);
break;
case 'bill':
case 'expense':
case 'purchase':
$document_number = $this->getNextDocumentNumber(Document::BILL_TYPE);
break;
}
return $document_number;
}
protected function getDueAt($type, $document, $due_at)
{
if (!empty($due_at)) {
return $due_at;
}
if ($document) {
return $document->due_at;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$due_at = Date::parse(request()->get('invoiced_at', Date::now()->toDateString()))->addDays(setting('invoice.payment_terms', 0))->toDateString();
break;
case 'bill':
case 'expense':
case 'purchase':
$due_at = request()->get('billed_at', Date::now()->toDateString());
break;
}
return $due_at;
}
protected function getOrderNumber($type, $document, $order_number)
{
if (!empty($order_number)) {
return $order_number;
}
if ($document) {
return $document->order_number;
}
$order_number = null;
}
protected function getTextDocumentNumber($type, $textDocumentNumber)
{
if (!empty($textDocumentNumber)) {
return $textDocumentNumber;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textDocumentNumber = trans('invoices.invoice_number');
break;
case 'bill':
case 'expense':
case 'purchase':
$textDocumentNumber = trans('bills.bill_number');
break;
}
return $textDocumentNumber;
}
protected function getTextOrderNumber($type, $textOrderNumber)
{
if (!empty($textOrderNumber)) {
return $textOrderNumber;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textOrderNumber = trans('invoices.order_number');
break;
case 'bill':
case 'expense':
case 'purchase':
$textOrderNumber = trans('bills.order_number');
break;
}
return $textOrderNumber;
}
protected function gettextIssuedAt($type, $textIssuedAt)
{
if (!empty($textIssuedAt)) {
return $textIssuedAt;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textIssuedAt = trans('invoices.invoice_date');
break;
case 'bill':
case 'expense':
case 'purchase':
$textIssuedAt = trans('bills.bill_date');
break;
}
return $textIssuedAt;
}
protected function getTextDueAt($type, $textDueAt)
{
if (!empty($textDueAt)) {
return $textDueAt;
}
switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textDueAt = trans('invoices.due_date');
break;
case 'bill':
case 'expense':
case 'purchase':
$textDueAt = trans('bills.due_date');
break;
}
return $textDueAt;
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\View\Components\Documents\Form;
use Illuminate\View\Component;
class Note extends Component
{
/** @var string */
public $type;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($type)
{
$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.note');
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\View\Components\Documents\Form;
use Illuminate\View\Component;
use App\Models\Setting\Currency;
class Totals extends Component
{
/** @var string */
public $type;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($type)
{
$this->type = $type;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
$currencies = Currency::enabled()->pluck('name', 'code');
$currency = Currency::where('code', setting('default.currency'))->first();
return view('components.documents.form.totals', compact('currencies', 'currency'));
}
}