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

fix: refactor: percent fix in articles; discount calculation fixed; erp user attributes fixed;

Übergeordneter e04937d1
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
/**
* @module package/quiqqer/erp/bin/backend/utils/Discount
* @author www.pcsg.de (Henning Leutz)
*/
define('package/quiqqer/erp/bin/backend/utils/Discount', function () {
"use strict";
return {
/**
* Unserialize a discount
*
......@@ -12,7 +14,6 @@ define('package/quiqqer/erp/bin/backend/utils/Discount', function () {
* @return {Object|null}
*/
unserialize: function (discount) {
if (typeOf(discount) === 'number') {
return {
value: discount,
......@@ -44,7 +45,7 @@ define('package/quiqqer/erp/bin/backend/utils/Discount', function () {
}
}
if (discount.toString().match('%')) {
if (discount.toString().indexOf('%') !== -1) {
return {
value: discount,
type : 1
......
......@@ -207,6 +207,10 @@ public function toHTML($template = false)
$Engine = QUI::getTemplateManager()->getEngine();
$vatArray = [];
if (!$this->count()) {
return '';
}
$Currency = QUI\ERP\Currency\Handler::getCurrency(
$this->calculations['currencyData']['code']
);
......
......@@ -319,13 +319,13 @@ public function calcArticlePrice(Article $Article, $callback = false)
switch ($Discount->getCalculation()) {
// einfache Zahl, Währung --- kein Prozent
case Calc::CALCULATION_COMPLEMENT:
$nettoPrice = $nettoPrice + ($Discount->getValue() / $Article->getQuantity());
$nettoPrice = $nettoPrice - ($Discount->getValue() / $Article->getQuantity());
break;
// Prozent Angabe
case Calc::CALCULATION_PERCENTAGE:
$percentage = $Discount->getValue() / 100 * $nettoPrice;
$nettoPrice = $nettoPrice + $percentage;
$nettoPrice = $nettoPrice - $percentage;
break;
}
}
......
......@@ -289,8 +289,13 @@ public function getAttributes()
$attributes['country'] = '';
}
$attributes['id'] = $this->getId();
$attributes['lang'] = $this->getLang();
$attributes['isCompany'] = $this->isCompany();
$attributes['firstname'] = $this->getAttribute('firstname');
$attributes['lastname'] = $this->getAttribute('lastname');
$attributes['username'] = $this->getAttribute('username');
$attributes['isCompany'] = $this->getAttribute('isCompany');
return $attributes;
}
......@@ -355,13 +360,18 @@ public function setAddress(QUI\Users\Address $Address)
*/
public function getCountry()
{
if (empty($this->country)) {
return QUI\ERP\Defaults::getCountry();
if (!empty($this->address) && isset($this->address['country'])) {
try {
return QUI\Countries\Manager::get($this->address['country']);
} catch (QUI\Exception $Exception) {
}
}
try {
return QUI\Countries\Manager::get($this->country);
} catch (QUI\Exception $Exception) {
if (!empty($this->country)) {
try {
return QUI\Countries\Manager::get($this->country);
} catch (QUI\Exception $Exception) {
}
}
return QUI\ERP\Defaults::getCountry();
......
......@@ -209,7 +209,7 @@ public static function getShopArea()
* Filter unwanted user attributes
* Therefore we can use the attributes in the ERP stack
*
* @param $attributes
* @param array $attributes
* @return array
*/
public static function filterCustomerAttributes($attributes = [])
......
......@@ -50,6 +50,7 @@
name="quiqqer.erp.address"
class="field-container-field"
data-qui="controls/users/address/Select"
data-value="{$User->getAttribute('quiqqer.erp.address')}"
></select>
</label>
</td>
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren