Skip to content
Code-Schnipsel Gruppen Projekte
Commit 73d5bfd3 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: refactor: consider_vat option for discounts

Übergeordneter a7de19e4
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -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>
......@@ -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'),
......
......@@ -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>
......@@ -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();
......
......@@ -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()
)
);
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren