Config type add hide for Document item columns..

This commit is contained in:
Cüneyt Şentürk 2021-01-09 18:56:11 +03:00
parent 78996c35dd
commit 0a4e5cd0d6
5 changed files with 283 additions and 234 deletions

View File

@ -62,9 +62,7 @@ abstract class Document extends Component
return $route; return $route;
} }
$prefix = config("type.' . $type . '.route.prefix"); $prefix = config("type.' . $type . '.route.prefix");
} }
public function getPermissionFromConfig($type, $config_key, $action) public function getPermissionFromConfig($type, $config_key, $action)
@ -96,4 +94,17 @@ abstract class Document extends Component
return $permission; 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;
}
} }

View File

@ -758,6 +758,12 @@ abstract class DocumentForm extends Base
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;
@ -769,18 +775,19 @@ abstract class DocumentForm extends Base
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)
@ -789,18 +796,19 @@ abstract class DocumentForm extends Base
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)
@ -809,18 +817,19 @@ abstract class DocumentForm extends Base
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)
@ -829,18 +838,19 @@ abstract class DocumentForm extends Base
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)
@ -849,18 +859,19 @@ abstract class DocumentForm extends Base
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)
@ -869,17 +880,18 @@ abstract class DocumentForm extends Base
return $hideAmount; return $hideAmount;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideAmount = setting($type . '.hide_amount', false)) {
case 'expense': return $hideAmount;
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
} }
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

@ -1317,7 +1317,7 @@ abstract class DocumentShow extends Base
} }
protected function getTextTimelineGetPaidAddPayment($type, $textTimelineGetPaidAddPayment) protected function getTextTimelineGetPaidAddPayment($type, $textTimelineGetPaidAddPayment)
{ {
if (!empty($textTimelineGetPaidAddPayment)) { if (!empty($textTimelineGetPaidAddPayment)) {
return $textTimelineGetPaidAddPayment; return $textTimelineGetPaidAddPayment;
} }
@ -1331,134 +1331,146 @@ abstract class DocumentShow extends Base
return 'invoices.add_payment'; return 'invoices.add_payment';
} }
protected function getHideItems($type, $hideItems, $hideName, $hideDescription) protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
{ {
if (!empty($hideItems)) { if (!empty($hideItems)) {
return $hideItems; return $hideItems;
} }
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false; $hide = $this->getHideFromConfig($type, 'items');
return $hideItems; if ($hide) {
} return $hide;
}
protected function getHideName($type, $hideName) $hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false;
{
if (!empty($hideName)) {
return $hideName;
}
switch ($type) { return $hideItems;
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; protected function getHideName($type, $hideName)
} {
if (!empty($hideName)) {
return $hideName;
}
protected function getHideDescription($type, $hideDescription) // if you use settting translation
{ if ($hideName = setting($type . '.hide_item_name', false)) {
if (!empty($hideDescription)) { return $hideName;
return $hideDescription; }
}
switch ($type) { $hide = $this->getHideFromConfig($type, 'name');
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; if ($hide) {
} return $hide;
}
protected function getHideQuantity($type, $hideQuantity) // @todo what return value invoice or always false??
{ return setting('invoice.hide_item_name', $hideName);
if (!empty($hideQuantity)) { }
return $hideQuantity;
}
switch ($type) { protected function getHideDescription($type, $hideDescription)
case 'bill': {
case 'expense': if (!empty($hideDescription)) {
case 'purchase': return $hideDescription;
$hideQuantity = setting('bill.hide_quantity', $hideQuantity); }
break;
default:
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
break;
}
return $hideQuantity; // if you use settting translation
} if ($hideDescription = setting($type . '.hide_item_description', false)) {
return $hideDescription;
}
protected function getHidePrice($type, $hidePrice) $hide = $this->getHideFromConfig($type, 'description');
{
if (!empty($hidePrice)) {
return $hidePrice;
}
switch ($type) { if ($hide) {
case 'bill': return $hide;
case 'expense': }
case 'purchase':
$hidePrice = setting('bill.hide_price', $hidePrice);
break;
default:
$hidePrice = setting('invoice.hide_price', $hidePrice);
break;
}
return $hidePrice; // @todo what return value invoice or always false??
} return setting('invoice.hide_item_description', $hideDescription);
}
protected function getHideDiscount($type, $hideDiscount) protected function getHideQuantity($type, $hideQuantity)
{ {
if (!empty($hideDiscount)) { if (!empty($hideQuantity)) {
return $hideDiscount; return $hideQuantity;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideQuantity = setting($type . '.hide_quantity', false)) {
case 'expense': return $hideQuantity;
case 'purchase': }
$hideDiscount = setting('bill.hide_discount', $hideDiscount);
break;
default:
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
break;
}
return $hideDiscount; $hide = $this->getHideFromConfig($type, 'quantity');
}
protected function getHideAmount($type, $hideAmount) if ($hide) {
{ return $hide;
if (!empty($hideAmount)) { }
return $hideAmount;
}
switch ($type) { // @todo what return value invoice or always false??
case 'bill': return setting('invoice.hide_quantity', $hideQuantity);
case 'expense': }
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
}
return $hideAmount; protected function getHidePrice($type, $hidePrice)
} {
if (!empty($hidePrice)) {
return $hidePrice;
}
// if you use settting translation
if ($hidePrice = setting($type . '.hide_price', false)) {
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)
{
if (!empty($hideDiscount)) {
return $hideDiscount;
}
// if you use settting translation
if ($hideDiscount = setting($type . '.hide_discount', false)) {
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)
{
if (!empty($hideAmount)) {
return $hideAmount;
}
// if you use settting translation
if ($hideAmount = setting($type . '.hide_amount', false)) {
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

@ -434,6 +434,12 @@ abstract class DocumentTemplate extends Base
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 +451,19 @@ abstract class DocumentTemplate extends Base
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 +472,19 @@ abstract class DocumentTemplate extends Base
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 +493,19 @@ abstract class DocumentTemplate extends Base
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 +514,19 @@ abstract class DocumentTemplate extends Base
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 +535,19 @@ abstract class DocumentTemplate extends Base
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 +556,18 @@ abstract class DocumentTemplate extends Base
return $hideAmount; return $hideAmount;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideAmount = setting($type . '.hide_amount', false)) {
case 'expense': return $hideAmount;
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
} }
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

@ -24,6 +24,7 @@ return [
'due_at' => 'invoices.due_date', 'due_at' => 'invoices.due_date',
], ],
'contact_type' => 'customer', // use contact type 'contact_type' => 'customer', // use contact type
'hide' => [], // for document items
], ],
Document::BILL_TYPE => [ Document::BILL_TYPE => [
@ -44,6 +45,7 @@ return [
'due_at' => 'bills.due_date', 'due_at' => 'bills.due_date',
], ],
'contact_type' => 'vendor', 'contact_type' => 'vendor',
'hide' => [],
], ],
// Contacts // Contacts