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

fix: shipping validation if no shipping entry is valid

Übergeordneter 0e666d58
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -83,6 +83,7 @@ define('package/quiqqer/shipping/bin/backend/controls/shippingRules/RuleWindow',
this.$Rule.update().then(function () {
self.Loader.hide();
self.fireEvent('updateEnd', [self]);
self.close();
});
}
});
......
......@@ -40,17 +40,22 @@ public function getIcon()
/**
* @param QUI\ERP\Order\OrderInterface $Order
* @param QUI\ERP\Shipping\Api\ShippingInterface $ShippingEntry
* @param QUI\ERP\Shipping\Types\ShippingEntry $ShippingEntry
* @return bool
*/
public function canUsedInOrder(
QUI\ERP\Order\OrderInterface $Order,
QUI\ERP\Shipping\Api\ShippingInterface $ShippingEntry
QUI\ERP\Shipping\Types\ShippingEntry $ShippingEntry
) {
if ($ShippingEntry->isActive() === false) {
return false;
}
if (!$ShippingEntry->isValid()) {
return false;
}
// assignment
$articles = $ShippingEntry->getAttribute('articles');
$categories = $ShippingEntry->getAttribute('categories');
......
......@@ -66,7 +66,9 @@ public function getBody()
foreach ($userShipping as $ShippingEntry) {
$ShippingEntry->setOrder($Order);
if ($ShippingEntry->canUsedInOrder($Order) && $ShippingEntry->canUsedBy($User)) {
if ($ShippingEntry->isValid()
&& $ShippingEntry->canUsedInOrder($Order)
&& $ShippingEntry->canUsedBy($User)) {
$shippingList[] = $ShippingEntry;
}
}
......
......@@ -89,20 +89,19 @@ public function __construct($id, Factory $Factory)
}
// purchase
if (empty($attributes['purchase_quantity_from'])) {
$attributes['purchase_quantity_from'] = null;
}
if (empty($attributes['purchase_quantity_to'])) {
$attributes['purchase_quantity_until'] = null;
}
if (empty($attributes['purchase_value_to'])) {
$attributes['purchase_value_until'] = null;
}
if (empty($attributes['purchase_value_to'])) {
$attributes['purchase_value_until'] = null;
$nullEmpty = [
'purchase_quantity_from',
'purchase_quantity_until',
'purchase_value_from',
'purchase_value_until',
'unit_value',
'unit'
];
foreach ($nullEmpty as $k) {
if (empty($attributes[$k])) {
$attributes[$k] = null;
}
}
// update for saving
......
......@@ -594,6 +594,33 @@ public function getShippingRules()
return $result;
}
/**
* Can the shipping be used basically?
*
* @return bool
*/
public function isValid()
{
if (!$this->isActive()) {
return false;
}
$shippingRules = $this->getAttribute('shipping_rules');
$shippingRules = \json_decode($shippingRules, true);
if (!\is_array($shippingRules)) {
return true;
}
$rules = $this->getShippingRules();
if (empty($rules)) {
return false;
}
return true;
}
//endregion
/**
......
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