Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix always fallback invoice item column settings #2932

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 28 additions & 25 deletions app/Abstracts/View/Components/Documents/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,15 +867,17 @@ protected function getHideItems($type, $hideItems, $hideItemName, $hideItemDescr
return $hideItems;
}

protected function getHideItemName($type, $hideItemName)
protected function getHideItemName($type, $hideItemName): bool
{
if (! empty($hideItemName)) {
return $hideItemName;
}

$hideItemName = setting($this->getSettingKey($type, 'item_name'), false);

// if you use settting translation
if ($hideItemName = setting($this->getSettingKey($type, 'item_name'), false) && $hideItemName == 'hide') {
return $hideItemName;
if ($hideItemName === 'hide') {
return true;
}

$hide = $this->getHideFromConfig($type, 'name');
Expand All @@ -884,8 +886,7 @@ protected function getHideItemName($type, $hideItemName)
return $hide;
}

// @todo what return value invoice or always false??
return setting('invoice.item_name', $hideItemName) == 'hide' ? true : false;
return false;
}

protected function getTextItemName($type, $textItemName)
Expand Down Expand Up @@ -918,15 +919,17 @@ protected function getTextItemName($type, $textItemName)
return 'general.items';
}

protected function getHideItemDescription($type, $hideItemDescription)
protected function getHideItemDescription($type, $hideItemDescription): bool
{
if (! empty($hideItemDescription)) {
return $hideItemDescription;
}



// if you use settting translation
if ($hideItemDescription = setting($this->getSettingKey($type, 'hide_item_description'), false) && $hideItemDescription == 'hide') {
return $hideItemDescription;
if (setting($this->getSettingKey($type, 'hide_item_description'), false)) {
return true;
}

$hide = $this->getHideFromConfig($type, 'description');
Expand All @@ -935,8 +938,7 @@ protected function getHideItemDescription($type, $hideItemDescription)
return $hide;
}

// @todo what return value invoice or always false??
return setting('invoice.hide_item_description', $hideItemDescription);
return false;
}

protected function getTextItemDescription($type, $textItemDescription)
Expand All @@ -954,15 +956,17 @@ protected function getTextItemDescription($type, $textItemDescription)
return 'general.description';
}

protected function getHideItemQuantity($type, $hideItemQuantity)
protected function getHideItemQuantity($type, $hideItemQuantity): bool
{
if (! empty($hideItemQuantity)) {
return $hideItemQuantity;
}

$hideItemQuantity = setting($this->getSettingKey($type, 'quantity_name'), false);

// if you use settting translation
if ($hideItemQuantity = setting($this->getSettingKey($type, 'hide_quantity'), false) && $hideItemQuantity == 'hide') {
return $hideItemQuantity;
if ($hideItemQuantity === 'hide') {
return true;
}

$hide = $this->getHideFromConfig($type, 'quantity');
Expand All @@ -971,8 +975,7 @@ protected function getHideItemQuantity($type, $hideItemQuantity)
return $hide;
}

// @todo what return value invoice or always false??
return setting('invoice.quantity_name', $hideItemQuantity) == 'hide' ? true : false;
return false;
}

protected function getTextItemQuantity($type, $textItemQuantity)
Expand Down Expand Up @@ -1005,15 +1008,17 @@ protected function getTextItemQuantity($type, $textItemQuantity)
return 'invoices.quantity';
}

protected function getHideItemPrice($type, $hideItemPrice)
protected function getHideItemPrice($type, $hideItemPrice): bool
{
if (! empty($hideItemPrice)) {
return $hideItemPrice;
}

$hideItemPrice = setting($this->getSettingKey($type, 'price_name'), false);

// if you use settting translation
if ($hideItemPrice = setting($this->getSettingKey($type, 'hide_price'), false) && $hideItemPrice == 'hide') {
return $hideItemPrice;
if ($hideItemPrice === 'hide') {
return true;
}

$hide = $this->getHideFromConfig($type, 'price');
Expand All @@ -1022,8 +1027,7 @@ protected function getHideItemPrice($type, $hideItemPrice)
return $hide;
}

// @todo what return value invoice or always false??
return setting('invoice.price_name', $hideItemPrice) == 'hide' ? true : false;
return false;
}

protected function getTextItemPrice($type, $textItemPrice)
Expand Down Expand Up @@ -1056,15 +1060,15 @@ protected function getTextItemPrice($type, $textItemPrice)
return 'invoices.price';
}

protected function getHideItemAmount($type, $hideItemAmount)
protected function getHideItemAmount($type, $hideItemAmount): bool
{
if (! empty($hideItemAmount)) {
return $hideItemAmount;
}

// if you use settting translation
if ($hideAmount = setting($this->getSettingKey($type, 'hide_amount'), false)) {
return $hideAmount;
if (setting($this->getSettingKey($type, 'hide_amount'), false)) {
return true;
}

$hide = $this->getHideFromConfig($type, 'amount');
Expand All @@ -1073,8 +1077,7 @@ protected function getHideItemAmount($type, $hideItemAmount)
return $hide;
}

// @todo what return value invoice or always false??
return setting('invoice.hide_amount', $hideAmount);
return false;
}

protected function getTextItemAmount($type, $textItemAmount)
Expand Down