diff --git a/bin/controls/DiscountEdit.html b/bin/controls/DiscountEdit.html index 78e9882fc9fc12826ec434d949f634524f1d48ea..e5f690e89259a5549228038115afe0c347479684 100644 --- a/bin/controls/DiscountEdit.html +++ b/bin/controls/DiscountEdit.html @@ -38,7 +38,7 @@ <input type="text" name="discount" class="field-container-field"/> <select name="discount_type" class="field-container-item" - style="width: 100px;" + style="width: 50px;" > <option value="1">%</option> <option value="2">€</option> @@ -165,6 +165,9 @@ <label class="field-container"> <span class="field-container-item" title="{{usageScope}}"> {{usageScope}} + + <span class="field-container-item-help" + title="{{scopeDescription}}"></span> </span> <select name="scope" class="field-container-field"> diff --git a/bin/controls/DiscountEdit.js b/bin/controls/DiscountEdit.js index f3aa29188e3dc6a26f71d8eeca8f687203aaee07..9c2a53ddd911304d342c528ae03682addf534484 100644 --- a/bin/controls/DiscountEdit.js +++ b/bin/controls/DiscountEdit.js @@ -80,6 +80,7 @@ define('package/quiqqer/discount/bin/controls/DiscountEdit', [ usageScopeEvery : QUILocale.get(lg, 'control.edit.template.usageScopeEvery'), usageScopeTotal : QUILocale.get(lg, 'control.edit.template.usageScopeTotal'), usageScopeUnique: QUILocale.get(lg, 'control.edit.template.usageScopeUnique'), + scopeDescription: QUILocale.get(lg, 'control.edit.template.usage.description'), calculationBasis : QUILocale.get(lg, 'control.edit.template.calculationBasis'), calculationBasisNetto : QUILocale.get(lg, 'control.edit.template.calculationBasis.netto'), diff --git a/bin/controls/search/Search.html b/bin/controls/search/Search.html index 036a9d5954441343e2ad95098aefd85dcd1677ae..6be17e34b73046eb58ea9b5d2cd3b1171b7bde96 100644 --- a/bin/controls/search/Search.html +++ b/bin/controls/search/Search.html @@ -30,7 +30,7 @@ class="field-container-field"/> <select name="discount_type" class="field-container-item" - style="width: 100px;" + style="width: 50px;" > <option value="%">%</option> <option value="currency">€</option> @@ -117,4 +117,4 @@ </tr> </tbody> </table> -</form> \ No newline at end of file +</form> diff --git a/locale.xml b/locale.xml index 93f78af2078f32429db9792118933a38b5d3f006..ed686a835b6d2cea715077062c8dc963fb5dfdbd 100644 --- a/locale.xml +++ b/locale.xml @@ -237,6 +237,14 @@ <de><![CDATA[Auf ein Produkt (Einmalig)]]></de> <en><![CDATA[On one product (Unique)]]></en> </locale> + <locale name="control.edit.template.usage.description"> + <de><![CDATA[ + 'Für jedes Produkt' und 'Auf ein Produkt (Einmalig)' wird auf den Einzelpreis des Produktes angewendet. + ]]></de> + <en><![CDATA[ + 'For each product' and 'On one product (Unique)' is applied to the single price of the product. + ]]></en> + </locale> <locale name="control.edit.template.shopping.amount.of"> <de><![CDATA[Einkaufsmenge von]]></de> diff --git a/src/QUI/ERP/Discount/Discount.php b/src/QUI/ERP/Discount/Discount.php index 048660dc33682c645b382a529fb922c68a50d563..cf4eac7d0f695dd289ee8b8d685f264c09f5c994 100644 --- a/src/QUI/ERP/Discount/Discount.php +++ b/src/QUI/ERP/Discount/Discount.php @@ -56,7 +56,7 @@ public function __construct($id, Handler $Factory) break; default: - $this->setAttribute('scope', 0); + $this->setAttribute('scope', Handler::DISCOUNT_SCOPE_TOTAL); } @@ -539,11 +539,17 @@ public function toPriceFactor($Locale = null, $Customer = null) $hideDiscounts = false; } - if ($this->getAttribute('scope') === Handler::DISCOUNT_SCOPE_TOTAL) { + if ($this->getAttribute('discount_type') === QUI\ERP\Accounting\Calc::CALCULATION_PERCENTAGE) { + $valueText = false; + } else { + $valueText = $this->getTitle($Locale); + } + return new PriceFactor([ 'identifier' => 'discount-'.$this->getId(), 'title' => $this->getTitle($Locale), + 'valueText' => $valueText, 'description' => '', 'priority' => (int)$this->getAttribute('priority'), 'calculation' => $calculation, @@ -554,9 +560,11 @@ public function toPriceFactor($Locale = null, $Customer = null) ]); } + // to product return new QUI\ERP\Products\Utils\PriceFactor([ 'identifier' => 'discount-'.$this->getId(), 'title' => $this->getTitle($Locale), +// 'valueText' => $this->getTitle($Locale), 'description' => '', 'priority' => (int)$this->getAttribute('priority'), 'calculation' => $calculation, diff --git a/src/QUI/ERP/Discount/Handler.php b/src/QUI/ERP/Discount/Handler.php index ca42496dbb2f9ff6e7894da97f1b85218786f8dd..5d5a41bc2c67e8c1797542c16fc42aee26595f1b 100644 --- a/src/QUI/ERP/Discount/Handler.php +++ b/src/QUI/ERP/Discount/Handler.php @@ -79,6 +79,10 @@ public function __construct() $childData['active'] = 0; } + if (empty($childData['scope'])) { + $childData['scope'] = self::DISCOUNT_SCOPE_TOTAL; + } + if (empty($childData['price_calculation_basis'])) { $childData['price_calculation_basis'] = QUI\ERP\Accounting\Calc::CALCULATION_BASIS_NETTO; }