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

@ -63,8 +63,6 @@ abstract class Document extends Component
} }
$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':
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
}
return $hideAmount; 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

@ -1337,6 +1337,12 @@ abstract class DocumentShow 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;
@ -1348,18 +1354,19 @@ abstract class DocumentShow 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)
@ -1368,18 +1375,19 @@ abstract class DocumentShow 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)
@ -1388,18 +1396,19 @@ abstract class DocumentShow 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)
@ -1408,18 +1417,19 @@ abstract class DocumentShow 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)
@ -1428,18 +1438,19 @@ abstract class DocumentShow 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)
@ -1448,17 +1459,18 @@ abstract class DocumentShow extends Base
return $hideAmount; return $hideAmount;
} }
switch ($type) { // if you use settting translation
case 'bill': if ($hideAmount = setting($type . '.hide_amount', false)) {
case 'expense':
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
}
return $hideAmount; 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':
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
}
return $hideAmount; 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