diff --git a/bin/controls/DiscountEdit.html b/bin/controls/DiscountEdit.html index 27083e9ceb7bcb7f52fb0e7e97ee599f4cfde353..9b872ff41a7cfb93d22b29a16d937c51b9c7e044 100644 --- a/bin/controls/DiscountEdit.html +++ b/bin/controls/DiscountEdit.html @@ -9,7 +9,7 @@ </thead> <tbody> - <tr class="odd"> + <tr> <td> <label class="field-container"> <span class="field-container-item"> @@ -19,7 +19,7 @@ </label> </td> </tr> - <tr class="even"> + <tr> <td> <label class="field-container"> <span class="field-container-item"> @@ -29,7 +29,7 @@ </label> </td> </tr> - <tr class="even"> + <tr> <td> <label class="field-container"> <span class="field-container-item"> @@ -46,7 +46,7 @@ </label> </td> </tr> - <tr class="even"> + <tr> <td> <label class="field-container"> <span class="field-container-item" title="{{calculationBasis}}"> @@ -61,6 +61,22 @@ </label> </td> </tr> + <tr> + <td> + <label class="field-container"> + <span class="field-container-item" title="{{calculationBasis}}"> + {{considerVat}} + </span> + <select type="text" name="consider_vat" + class="field-container-field" style="width: 100%" + > + <option value="auto">{{considerVatAuto}}</option> + <option value="brutto">{{considerVatBrutto}}</option> + <option value="netto">{{considerVatNetto}}</option> + </select> + </label> + </td> + </tr> <tr> <td> <label class="field-container"> @@ -91,8 +107,7 @@ <span class="fa fa-calendar"></span> {{usageFrom}} </span> - <input type="datetime" name="date_from" - class="field-container-field"/> + <input type="datetime" name="date_from" class="field-container-field"/> </label> </td> <td> @@ -101,8 +116,7 @@ <span class="fa fa-calendar"></span> {{usageTo}} </span> - <input type="datetime" name="date_until" - class="field-container-field"/> + <input type="datetime" name="date_until" class="field-container-field"/> </label> </td> </tr> @@ -112,8 +126,7 @@ <span class="field-container-item"> {{usageAmountOf}} </span> - <input type="number" min="0" name="purchase_quantity_from" - class="field-container-field"/> + <input type="number" min="0" name="purchase_quantity_from" class="field-container-field"/> </label> </td> <td> @@ -121,8 +134,7 @@ <span class="field-container-item"> {{usageAmountTo}} </span> - <input type="number" min="0" name="purchase_quantity_until" - class="field-container-field"/> + <input type="number" min="0" name="purchase_quantity_until" class="field-container-field"/> </label> </td> </tr> @@ -133,8 +145,7 @@ <span class="fa fa-money"></span> {{usageValueOf}} </span> - <input type="number" min="0" name="purchase_value_from" - class="field-container-field"/> + <input type="number" min="0" name="purchase_value_from" class="field-container-field"/> </label> </td> <td> @@ -143,8 +154,7 @@ <span class="fa fa-money"></span> {{usageValueTo}} </span> - <input type="number" min="0" name="purchase_value_until" - class="field-container-field"/> + <input type="number" min="0" name="purchase_value_until" class="field-container-field"/> </label> </td> </tr> @@ -297,4 +307,4 @@ </tr> </tbody> </table> -</form> \ No newline at end of file +</form> diff --git a/bin/controls/DiscountEdit.js b/bin/controls/DiscountEdit.js index 2ba308df04a45c5c55def62ec1b37087c23c0e26..9c9b6f4349477a7a630083d47993be1044479d00 100644 --- a/bin/controls/DiscountEdit.js +++ b/bin/controls/DiscountEdit.js @@ -87,6 +87,11 @@ define('package/quiqqer/discount/bin/controls/DiscountEdit', [ calculationBasisCalcBrutto: QUILocale.get(lg, 'control.edit.template.calculationBasis.calculationBasisCalcBrutto'), calculationPriority : QUILocale.get(lg, 'control.edit.template.calculationPriority'), + considerVat : QUILocale.get(lg, 'control.edit.template.considerVat'), + considerVatAuto : QUILocale.get(lg, 'control.edit.template.considerVat.auto'), + considerVatNetto : QUILocale.get(lg, 'control.edit.template.considerVat.netto'), + considerVatBrutto: QUILocale.get(lg, 'control.edit.template.considerVat.brutto'), + usageAssignmentProduct : QUILocale.get(lg, 'control.edit.template.assignment.product'), usageAssignmentCategory: QUILocale.get(lg, 'control.edit.template.assignment.category'), usageAssignmentUser : QUILocale.get(lg, 'control.edit.template.assignment.user'), diff --git a/locale.xml b/locale.xml index 999902e30cdb9d7304c5590610a67e5bca4ffdb8..ea10495321d91475b779cb99737f7726849e2273 100644 --- a/locale.xml +++ b/locale.xml @@ -278,6 +278,22 @@ <de><![CDATA[Zonen]]></de> <en><![CDATA[Areas]]></en> </locale> + <locale name="control.edit.template.considerVat"> + <de><![CDATA[MwSt. beachten]]></de> + <en><![CDATA[Consider VAT]]></en> + </locale> + <locale name="control.edit.template.considerVat.auto"> + <de><![CDATA[automatisch]]></de> + <en><![CDATA[automatic]]></en> + </locale> + <locale name="control.edit.template.considerVat.netto"> + <de><![CDATA[netto]]></de> + <en><![CDATA[net]]></en> + </locale> + <locale name="control.edit.template.considerVat.brutto"> + <de><![CDATA[brutto]]></de> + <en><![CDATA[gross]]></en> + </locale> <locale name="control.select.search.placeholder"> <de><![CDATA[Suche nach einem Rabatt ...]]></de> @@ -346,4 +362,4 @@ Automatic: This discount is automatically added to an order if the conditions ap </groups> -</locales> \ No newline at end of file +</locales> diff --git a/src/QUI/ERP/Discount/Discount.php b/src/QUI/ERP/Discount/Discount.php index f7199d2eb3fb15394f19aae861bd8f7fb9074a62..c32a23230adcef6c6fecd634249d4ca52644f555 100644 --- a/src/QUI/ERP/Discount/Discount.php +++ b/src/QUI/ERP/Discount/Discount.php @@ -41,6 +41,10 @@ public function __construct($id, Handler $Factory) break; } + if ($this->getAttribute('consider_vat') === false) { + $this->setAttribute('consider_vat', 'auto'); + } + $scope = (int)$this->getAttribute('scope'); switch ($scope) { @@ -452,9 +456,11 @@ public function verifyUser(User $User) * Parse the discount to a price factor * * @param null|QUI\Locale $Locale - optional, locale object + * @param null|QUI\Interfaces\Users\User $Customer - optional, + * * @return QUI\ERP\Products\Interfaces\PriceFactorWithVatInterface|QUI\ERP\Products\Interfaces\PriceFactorInterface */ - public function toPriceFactor($Locale = null) + public function toPriceFactor($Locale = null, $Customer = null) { switch ($this->getAttribute('discount_type')) { case QUI\ERP\Accounting\Calc::CALCULATION_PERCENTAGE: @@ -476,6 +482,15 @@ public function toPriceFactor($Locale = null) $basis = QUI\ERP\Accounting\Calc::CALCULATION_BASIS_CURRENTPRICE; } + // check calculation basis VAT + $useAuto = $this->getAttribute('consider_vat') === 'auto' + && $Customer + && QUI\ERP\Utils\User::isNettoUser($Customer) === false; + + if ($useAuto || $this->getAttribute('consider_vat') === 'brutto') { + $basis = QUI\ERP\Accounting\Calc::CALCULATION_BASIS_VAT_BRUTTO; + } + try { $Plugin = QUI::getPackage('quiqqer/products'); $Config = $Plugin->getConfig(); diff --git a/src/QUI/ERP/Discount/EventHandling.php b/src/QUI/ERP/Discount/EventHandling.php index 14fd306a09875ccff819dd6290f95dc5a9738a02..4bac048444862f130603beb002e66e9d283d3b03 100644 --- a/src/QUI/ERP/Discount/EventHandling.php +++ b/src/QUI/ERP/Discount/EventHandling.php @@ -7,6 +7,7 @@ namespace QUI\ERP\Discount; use QUI; +use QUI\ERP\Accounting\Calc as ErpCalc; use QUI\ERP\Products\Product\UniqueProduct; use QUI\ERP\Products\Utils\Calc; use QUI\ERP\Products\Product\ProductList; @@ -106,7 +107,7 @@ protected static function isDiscountUsableWithPurchaseValue(Discount $Discount, // wenn complement, z.B. 10€, muss geprüft werden // ob meine value grösser ist als der gegebene value - if ((int)$Discount->getAttribute('discount_type') === Calc::CALCULATION_COMPLEMENT + if ((int)$Discount->getAttribute('discount_type') === ErpCalc::CALCULATION_COMPLEMENT && $Discount->getAttribute('discount') > $value) { return false; } @@ -182,7 +183,8 @@ public static function onQuiqqerProductsCalcListProduct( $Product->getPriceFactors()->addToEnd( $Discount->toPriceFactor( - $Calc->getUser()->getLocale() + $Calc->getUser()->getLocale(), + $Calc->getUser() ) ); @@ -296,7 +298,8 @@ public static function onQuiqqerProductsCalcList( $List->getPriceFactors()->addToEnd( $Discount->toPriceFactor( - $Calc->getUser()->getLocale() + $Calc->getUser()->getLocale(), + $Calc->getUser() ) );