Skip to content

Commit

Permalink
Document field default name
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Dec 28, 2020
1 parent 50eaa40 commit 918c5af
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 338 deletions.
167 changes: 62 additions & 105 deletions app/Abstracts/View/Components/DocumentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function __construct(
bool $hideLogo = false, bool $hideDocumentTitle = false, bool $hideDocumentSubheading = false, bool $hideCompanyEdit = false,
/** Company Component End */
/** Content Component Start */
string $formRoute = '', string $formId = 'document', string $formSubmit = 'onSubmit',
string $formRoute = '', string $formId = 'document', string $formSubmit = 'onSubmit',
bool $hideCompany = false, bool $hideAdvanced = false, bool $hideFooter = false, bool $hideButtons = false,
/** Content Component End */
/** Metadata Component Start */
Expand Down Expand Up @@ -323,16 +323,14 @@ protected function getContactType($type, $contact_type)
}

switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$contact_type = 'customer';
break;
case 'bill':
case 'expense':
case 'purchase':
$contact_type = 'vendor';
break;
default:
$contact_type = 'customer';
break;
}

return $contact_type;
Expand All @@ -349,16 +347,14 @@ protected function getIssuedAt($type, $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;
default:
$issued_at = request()->get('invoiced_at', Date::now()->toDateString());
break;
}

return $issued_at;
Expand All @@ -375,16 +371,14 @@ protected function getDocumentNumber($type, $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;
default:
$document_number = $this->getNextDocumentNumber(Document::INVOICE_TYPE);
break;
}

return $document_number;
Expand All @@ -401,16 +395,14 @@ protected function getDueAt($type, $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;
default:
$due_at = Date::parse(request()->get('invoiced_at', Date::now()->toDateString()))->addDays(setting('invoice.payment_terms', 0))->toDateString();
break;
}

return $due_at;
Expand All @@ -436,16 +428,14 @@ protected function getTextDocumentNumber($type, $textDocumentNumber)
}

switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textDocumentNumber = 'invoices.invoice_number';
break;
case 'bill':
case 'expense':
case 'purchase':
$textDocumentNumber = 'bills.bill_number';
break;
default:
$textDocumentNumber = 'invoices.invoice_number';
break;
}

return $textDocumentNumber;
Expand All @@ -458,16 +448,14 @@ protected function getTextOrderNumber($type, $textOrderNumber)
}

switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textOrderNumber = 'invoices.order_number';
break;
case 'bill':
case 'expense':
case 'purchase':
$textOrderNumber = 'bills.order_number';
break;
default:
$textOrderNumber = 'invoices.order_number';
break;
}

return $textOrderNumber;
Expand All @@ -480,16 +468,14 @@ protected function getTextIssuedAt($type, $textIssuedAt)
}

switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textIssuedAt = 'invoices.invoice_date';
break;
case 'bill':
case 'expense':
case 'purchase':
$textIssuedAt = 'bills.bill_date';
break;
default:
$textIssuedAt = 'invoices.invoice_date';
break;
}

return $textIssuedAt;
Expand All @@ -502,16 +488,14 @@ protected function getTextDueAt($type, $textDueAt)
}

switch ($type) {
case 'sale':
case 'income':
case 'invoice':
$textDueAt = 'invoices.due_date';
break;
case 'bill':
case 'expense':
case 'purchase':
$textDueAt = 'bills.due_date';
break;
default:
$textDueAt = 'invoices.due_date';
break;
}

return $textDueAt;
Expand All @@ -524,20 +508,18 @@ protected function getTextItems($type, $text_items)
}

switch ($type) {
case 'sale':
case 'income':
case 'invoice':
case 'bill':
case 'expense':
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;
case 'bill':
case 'expense':
case 'purchase':
$text_items = 'general.items';
break;
}

return $text_items;
Expand All @@ -550,20 +532,18 @@ protected function getTextQuantity($type, $text_quantity)
}

switch ($type) {
case 'sale':
case 'income':
case 'invoice':
case 'bill':
case 'expense':
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;
case 'bill':
case 'expense':
case 'purchase':
$text_quantity = 'bills.quantity';
break;
}

return $text_quantity;
Expand All @@ -576,20 +556,18 @@ protected function getTextPrice($type, $text_price)
}

switch ($type) {
case 'sale':
case 'income':
case 'invoice':
case 'bill':
case 'expense':
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;
case 'bill':
case 'expense':
case 'purchase':
$text_price = 'bills.price';
break;
}

return $text_price;
Expand All @@ -601,16 +579,7 @@ protected function getTextAmount($type, $text_amount)
return $text_amount;
}

switch ($type) {
case 'sale':
case 'income':
case 'invoice':
case 'bill':
case 'expense':
case 'purchase':
$text_amount = 'general.amount';
break;
}
$text_amount = 'general.amount';

return $text_amount;
}
Expand All @@ -633,16 +602,14 @@ protected function getHideName($type, $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;
default:
$hideName = setting('invoice.hide_item_name', $hideName);
break;
}

return $hideName;
Expand All @@ -655,16 +622,14 @@ protected function getHideDescription($type, $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;
default:
$hideDescription = setting('invoice.hide_item_description', $hideDescription);
break;
}

return $hideDescription;
Expand All @@ -677,16 +642,14 @@ protected function getHideQuantity($type, $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;
default:
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
break;
}

return $hideQuantity;
Expand All @@ -699,16 +662,14 @@ protected function getHidePrice($type, $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;
default:
$hidePrice = setting('invoice.hide_price', $hidePrice);
break;
}

return $hidePrice;
Expand All @@ -721,16 +682,14 @@ protected function getHideDiscount($type, $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;
default:
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
break;
}

return $hideDiscount;
Expand All @@ -743,16 +702,14 @@ protected function getHideAmount($type, $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;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
}

return $hideAmount;
Expand Down

0 comments on commit 918c5af

Please sign in to comment.