Document field default name

This commit is contained in:
Cüneyt Şentürk
2020-12-28 22:10:43 +03:00
parent 50eaa40327
commit 918c5af23e
5 changed files with 197 additions and 338 deletions

View File

@ -176,7 +176,7 @@ abstract class DocumentForm extends Component
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 */
@ -323,16 +323,14 @@ abstract class DocumentForm extends Component
}
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;
@ -349,16 +347,14 @@ abstract class DocumentForm extends Component
}
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;
@ -375,16 +371,14 @@ abstract class DocumentForm extends Component
}
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;
@ -401,16 +395,14 @@ abstract class DocumentForm extends Component
}
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;
@ -436,16 +428,14 @@ abstract class DocumentForm extends Component
}
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;
@ -458,16 +448,14 @@ abstract class DocumentForm extends Component
}
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;
@ -480,16 +468,14 @@ abstract class DocumentForm extends Component
}
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;
@ -502,16 +488,14 @@ abstract class DocumentForm extends Component
}
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;
@ -524,20 +508,18 @@ abstract class DocumentForm extends Component
}
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;
@ -550,20 +532,18 @@ abstract class DocumentForm extends Component
}
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;
@ -576,20 +556,18 @@ abstract class DocumentForm extends Component
}
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;
@ -601,16 +579,7 @@ abstract class DocumentForm extends Component
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;
}
@ -633,16 +602,14 @@ abstract class DocumentForm extends Component
}
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;
@ -655,16 +622,14 @@ abstract class DocumentForm extends Component
}
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;
@ -677,16 +642,14 @@ abstract class DocumentForm extends Component
}
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;
@ -699,16 +662,14 @@ abstract class DocumentForm extends Component
}
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;
@ -721,16 +682,14 @@ abstract class DocumentForm extends Component
}
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;
@ -743,16 +702,14 @@ abstract class DocumentForm extends Component
}
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;