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;
}
$prefix = config("type.' . $type . '.route.prefix");
$prefix = config("type.' . $type . '.route.prefix");
}
public function getPermissionFromConfig($type, $config_key, $action)
@ -96,4 +94,17 @@ abstract class Document extends Component
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;
}
$hide = $this->getHideFromConfig($type, 'items');
if ($hide) {
return $hide;
}
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false;
return $hideItems;
@ -769,18 +775,19 @@ abstract class DocumentForm extends Base
return $hideName;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideName = setting('bill.hide_item_name', $hideName);
break;
default:
$hideName = setting('invoice.hide_item_name', $hideName);
break;
// if you use settting translation
if ($hideName = setting($type . '.hide_item_name', false)) {
return $hideName;
}
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)
@ -789,18 +796,19 @@ abstract class DocumentForm extends Base
return $hideDescription;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideDescription = setting('bill.hide_item_description', $hideDescription);
break;
default:
$hideDescription = setting('invoice.hide_item_description', $hideDescription);
break;
// if you use settting translation
if ($hideDescription = setting($type . '.hide_item_description', false)) {
return $hideDescription;
}
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)
@ -809,18 +817,19 @@ abstract class DocumentForm extends Base
return $hideQuantity;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideQuantity = setting('bill.hide_quantity', $hideQuantity);
break;
default:
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
break;
// if you use settting translation
if ($hideQuantity = setting($type . '.hide_quantity', false)) {
return $hideQuantity;
}
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)
@ -829,18 +838,19 @@ abstract class DocumentForm extends Base
return $hidePrice;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hidePrice = setting('bill.hide_price', $hidePrice);
break;
default:
$hidePrice = setting('invoice.hide_price', $hidePrice);
break;
// if you use settting translation
if ($hidePrice = setting($type . '.hide_price', false)) {
return $hidePrice;
}
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)
@ -849,18 +859,19 @@ abstract class DocumentForm extends Base
return $hideDiscount;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideDiscount = setting('bill.hide_discount', $hideDiscount);
break;
default:
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
break;
// if you use settting translation
if ($hideDiscount = setting($type . '.hide_discount', false)) {
return $hideDiscount;
}
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)
@ -869,17 +880,18 @@ abstract class DocumentForm extends Base
return $hideAmount;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
// if you use settting translation
if ($hideAmount = setting($type . '.hide_amount', false)) {
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

@ -1317,7 +1317,7 @@ abstract class DocumentShow extends Base
}
protected function getTextTimelineGetPaidAddPayment($type, $textTimelineGetPaidAddPayment)
{
{
if (!empty($textTimelineGetPaidAddPayment)) {
return $textTimelineGetPaidAddPayment;
}
@ -1331,134 +1331,146 @@ abstract class DocumentShow extends Base
return 'invoices.add_payment';
}
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
{
if (!empty($hideItems)) {
return $hideItems;
}
protected function getHideItems($type, $hideItems, $hideName, $hideDescription)
{
if (!empty($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)
{
if (!empty($hideName)) {
return $hideName;
}
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false;
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideName = setting('bill.hide_item_name', $hideName);
break;
default:
$hideName = setting('invoice.hide_item_name', $hideName);
break;
}
return $hideItems;
}
return $hideName;
}
protected function getHideName($type, $hideName)
{
if (!empty($hideName)) {
return $hideName;
}
protected function getHideDescription($type, $hideDescription)
{
if (!empty($hideDescription)) {
return $hideDescription;
}
// if you use settting translation
if ($hideName = setting($type . '.hide_item_name', false)) {
return $hideName;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideDescription = setting('bill.hide_item_description', $hideDescription);
break;
default:
$hideDescription = setting('invoice.hide_item_description', $hideDescription);
break;
}
$hide = $this->getHideFromConfig($type, 'name');
return $hideDescription;
}
if ($hide) {
return $hide;
}
protected function getHideQuantity($type, $hideQuantity)
{
if (!empty($hideQuantity)) {
return $hideQuantity;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_item_name', $hideName);
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideQuantity = setting('bill.hide_quantity', $hideQuantity);
break;
default:
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
break;
}
protected function getHideDescription($type, $hideDescription)
{
if (!empty($hideDescription)) {
return $hideDescription;
}
return $hideQuantity;
}
// if you use settting translation
if ($hideDescription = setting($type . '.hide_item_description', false)) {
return $hideDescription;
}
protected function getHidePrice($type, $hidePrice)
{
if (!empty($hidePrice)) {
return $hidePrice;
}
$hide = $this->getHideFromConfig($type, 'description');
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hidePrice = setting('bill.hide_price', $hidePrice);
break;
default:
$hidePrice = setting('invoice.hide_price', $hidePrice);
break;
}
if ($hide) {
return $hide;
}
return $hidePrice;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_item_description', $hideDescription);
}
protected function getHideDiscount($type, $hideDiscount)
{
if (!empty($hideDiscount)) {
return $hideDiscount;
}
protected function getHideQuantity($type, $hideQuantity)
{
if (!empty($hideQuantity)) {
return $hideQuantity;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideDiscount = setting('bill.hide_discount', $hideDiscount);
break;
default:
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
break;
}
// if you use settting translation
if ($hideQuantity = setting($type . '.hide_quantity', false)) {
return $hideQuantity;
}
return $hideDiscount;
}
$hide = $this->getHideFromConfig($type, 'quantity');
protected function getHideAmount($type, $hideAmount)
{
if (!empty($hideAmount)) {
return $hideAmount;
}
if ($hide) {
return $hide;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
}
// @todo what return value invoice or always false??
return setting('invoice.hide_quantity', $hideQuantity);
}
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;
}
$hide = $this->getHideFromConfig($type, 'items');
if ($hide) {
return $hide;
}
$hideItems = ($this->getHideName($type, $hideName) & $this->getHideDescription($type, $hideDescription)) ? true : false;
return $hideItems;
@ -445,18 +451,19 @@ abstract class DocumentTemplate extends Base
return $hideName;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideName = setting('bill.hide_item_name', $hideName);
break;
default:
$hideName = setting('invoice.hide_item_name', $hideName);
break;
// if you use settting translation
if ($hideName = setting($type . '.hide_item_name', false)) {
return $hideName;
}
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)
@ -465,18 +472,19 @@ abstract class DocumentTemplate extends Base
return $hideDescription;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideDescription = setting('bill.hide_item_description', $hideDescription);
break;
default:
$hideDescription = setting('invoice.hide_item_description', $hideDescription);
break;
// if you use settting translation
if ($hideDescription = setting($type . '.hide_item_description', false)) {
return $hideDescription;
}
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)
@ -485,18 +493,19 @@ abstract class DocumentTemplate extends Base
return $hideQuantity;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideQuantity = setting('bill.hide_quantity', $hideQuantity);
break;
default:
$hideQuantity = setting('invoice.hide_quantity', $hideQuantity);
break;
// if you use settting translation
if ($hideQuantity = setting($type . '.hide_quantity', false)) {
return $hideQuantity;
}
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)
@ -505,18 +514,19 @@ abstract class DocumentTemplate extends Base
return $hidePrice;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hidePrice = setting('bill.hide_price', $hidePrice);
break;
default:
$hidePrice = setting('invoice.hide_price', $hidePrice);
break;
// if you use settting translation
if ($hidePrice = setting($type . '.hide_price', false)) {
return $hidePrice;
}
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)
@ -525,18 +535,19 @@ abstract class DocumentTemplate extends Base
return $hideDiscount;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideDiscount = setting('bill.hide_discount', $hideDiscount);
break;
default:
$hideDiscount = setting('invoice.hide_discount', $hideDiscount);
break;
// if you use settting translation
if ($hideDiscount = setting($type . '.hide_discount', false)) {
return $hideDiscount;
}
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)
@ -545,17 +556,18 @@ abstract class DocumentTemplate extends Base
return $hideAmount;
}
switch ($type) {
case 'bill':
case 'expense':
case 'purchase':
$hideAmount = setting('bill.hide_amount', $hideAmount);
break;
default:
$hideAmount = setting('invoice.hide_amount', $hideAmount);
break;
// if you use settting translation
if ($hideAmount = setting($type . '.hide_amount', false)) {
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',
],
'contact_type' => 'customer', // use contact type
'hide' => [], // for document items
],
Document::BILL_TYPE => [
@ -44,6 +45,7 @@ return [
'due_at' => 'bills.due_date',
],
'contact_type' => 'vendor',
'hide' => [],
],
// Contacts