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

Merge branch 'next' into 'master'

Next

See merge request !2
Übergeordnete b5672d86 29a1646a
Branches 1.x next-1.x
Tags 1.2.0
2 Merge Requests!13Update 'next-3.x' with latest changes from 'main',!2Next
Pipeline #9398 mit Warnungen bestanden mit Phasen
in 53 Sekunden
include:
- project: 'quiqqer/stabilization/semantic-release'
file: '/ci-templates/.gitlab-ci.yml'
PCSG QEL-1.0
\ No newline at end of file
......@@ -14,10 +14,10 @@
QUI::$Ajax->registerFunction(
'package_quiqqer_discount_ajax_list',
function ($params) {
$Grid = new QUI\Utils\Grid();
$Grid = new QUI\Utils\Grid();
$Discounts = new QUI\ERP\Discount\Handler();
$result = [];
$Locale = QUI::getLocale();
$result = [];
$Locale = QUI::getLocale();
// search
$params = $Grid->parseDBParams(\json_decode($params, true));
......@@ -31,15 +31,15 @@ function ($params) {
foreach ($data as $entry) {
$entry['title'] = [
'quiqqer/discount',
'discount.'.$entry['id'].'.title'
'discount.' . $entry['id'] . '.title'
];
$entry['text'] = $Locale->get(
'quiqqer/discount',
'discount.'.$entry['id'].'.title'
'discount.' . $entry['id'] . '.title'
);
$type = (int)$entry['discount_type'];
$type = (int)$entry['discount_type'];
$usageType = (int)$entry['usage_type'];
// attributes
......
......@@ -15,12 +15,12 @@
'package_quiqqer_discount_ajax_search',
function ($fields, $params) {
$Discounts = new QUI\ERP\Discount\Handler();
$result = [];
$Locale = QUI::getLocale();
$result = [];
$Locale = QUI::getLocale();
$allowedFields = $Discounts->getChildAttributes();
$query = [];
$query = [];
$params = json_decode($params, true);
$fields = json_decode($fields, true);
......@@ -44,7 +44,7 @@ function ($fields, $params) {
}
$query['where_or'][$field] = [
'type' => '%LIKE%',
'type' => '%LIKE%',
'value' => $value
];
}
......@@ -55,12 +55,12 @@ function ($fields, $params) {
foreach ($data as $entry) {
$entry['title'] = [
'quiqqer/discount',
'discount.'.$entry['id'].'.title'
'discount.' . $entry['id'] . '.title'
];
$entry['text'] = $Locale->get(
'quiqqer/discount',
'discount.'.$entry['id'].'.title'
'discount.' . $entry['id'] . '.title'
);
$result[] = $entry;
......
......@@ -11,7 +11,6 @@
use QUI\Users\User;
use QUI\Permissions\Permission;
use QUI\Utils\Security\Orthos;
use QUI\ERP\Areas\Utils as AreaUtils;
/**
......@@ -65,7 +64,7 @@ public function __construct($id, Handler $Factory)
$cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) {
$cleanup = ','.$cleanup.',';
$cleanup = ',' . $cleanup . ',';
}
$this->setAttribute('user_groups', $cleanup);
......@@ -76,7 +75,7 @@ public function __construct($id, Handler $Factory)
$cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) {
$cleanup = ','.$cleanup.',';
$cleanup = ',' . $cleanup . ',';
}
$this->setAttribute('articles', $cleanup);
......@@ -87,7 +86,7 @@ public function __construct($id, Handler $Factory)
$cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) {
$cleanup = ','.$cleanup.',';
$cleanup = ',' . $cleanup . ',';
}
$this->setAttribute('user_groups', $cleanup);
......@@ -98,7 +97,7 @@ public function __construct($id, Handler $Factory)
$cleanup = \implode(',', $cleanup);
if (!empty($cleanup)) {
$cleanup = ','.$cleanup.',';
$cleanup = ',' . $cleanup . ',';
}
$this->setAttribute('articles', $cleanup);
......@@ -112,14 +111,15 @@ public function __construct($id, Handler $Factory)
$this->Events->addEvent('onDeleteEnd', function () {
QUI\Translator::delete(
'quiqqer/discount',
'discount.'.$this->getId().'.title'
'discount.' . $this->getId() . '.title'
);
});
$this->Events->addEvent('onSaveBegin', function () {
Permission::checkPermission('quiqqer.areas.area.edit');
if ($this->getAttribute('date_from')
if (
$this->getAttribute('date_from')
&& !Orthos::checkMySqlDatetimeSyntax($this->getAttribute('date_from'))
) {
throw new QUI\ERP\Discount\Exception([
......@@ -128,7 +128,8 @@ public function __construct($id, Handler $Factory)
]);
}
if ($this->getAttribute('date_until')
if (
$this->getAttribute('date_until')
&& !Orthos::checkMySqlDatetimeSyntax($this->getAttribute('date_until'))
) {
throw new QUI\ERP\Discount\Exception([
......@@ -137,10 +138,10 @@ public function __construct($id, Handler $Factory)
]);
}
$purchaseQuantityFrom = $this->getAttribute('purchase_quantity_from');
$purchaseQuantityFrom = $this->getAttribute('purchase_quantity_from');
$purchaseQuantityUntil = $this->getAttribute('purchase_quantity_until');
$purchaseValueFrom = $this->getAttribute('purchase_value_from');
$purchaseValueUntil = $this->getAttribute('purchase_value_until');
$purchaseValueFrom = $this->getAttribute('purchase_value_from');
$purchaseValueUntil = $this->getAttribute('purchase_value_until');
if ($purchaseQuantityFrom !== '' && ($purchaseQuantityFrom === false || $purchaseQuantityFrom < 0)) {
throw new QUI\ERP\Discount\Exception([
......@@ -216,7 +217,8 @@ public function setAttribute($key, $value)
$value = null;
}
if ($key === 'scope' ||
if (
$key === 'scope' ||
$key === 'discount_type' ||
$key === 'usage_type'
) {
......@@ -240,7 +242,7 @@ public function getTitle($Locale = null)
return $Locale->get(
'quiqqer/discount',
'discount.'.$this->getId().'.title'
'discount.' . $this->getId() . '.title'
);
}
......@@ -296,9 +298,9 @@ public function canUsedBy(QUI\Interfaces\Users\User $User)
}
// usage definitions / limits
$dateFrom = $this->getAttribute('date_from');
$dateFrom = $this->getAttribute('date_from');
$dateUntil = $this->getAttribute('date_until');
$now = \time();
$now = \time();
if ($dateFrom && \strtotime($dateFrom) > $now) {
return false;
......@@ -310,7 +312,7 @@ public function canUsedBy(QUI\Interfaces\Users\User $User)
// assignment
$userGroupValue = $this->getAttribute('user_groups');
$areasValue = $this->getAttribute('areas');
$areasValue = $this->getAttribute('areas');
// if groups and areas are empty, everbody is allowed
if (empty($userGroupValue) && empty($areasValue)) {
......@@ -326,7 +328,7 @@ public function canUsedBy(QUI\Interfaces\Users\User $User)
$this->getAttribute('user_groups')
);
$discountUsers = $userGroups['users'];
$discountUsers = $userGroups['users'];
$discountGroups = $userGroups['groups'];
// user checking
......@@ -368,7 +370,7 @@ public function canUsedWith(QUI\ERP\Products\Interfaces\ProductInterface $Produc
return false;
}
$articles = $this->getAttribute('articles');
$articles = $this->getAttribute('articles');
$categories = $this->getAttribute('categories');
if (\is_string($articles)) {
......@@ -465,7 +467,7 @@ public function verifyCombinationWith(Discount $Discount)
'quiqqer/discount',
'exception.discount.not.combinable',
[
'id' => $this->getId(),
'id' => $this->getId(),
'discountId' => $Discount->getId()
]
]);
......@@ -485,7 +487,7 @@ public function verifyUser(User $User)
'quiqqer/discount',
'exception.discount.user.cant.use.discount',
[
'id' => $this->getId(),
'id' => $this->getId(),
'userId' => $User->getId()
]
]);
......@@ -524,8 +526,8 @@ public function toPriceFactor($Locale = null, $Customer = null)
// check calculation basis VAT
$useAuto = $this->getAttribute('consider_vat') === 'auto'
&& $Customer
&& QUI\ERP\Utils\User::isNettoUser($Customer) === false;
&& $Customer
&& QUI\ERP\Utils\User::isNettoUser($Customer) === false;
if ($useAuto || $this->getAttribute('consider_vat') === 'brutto') {
$basis = QUI\ERP\Accounting\Calc::CALCULATION_BASIS_VAT_BRUTTO;
......@@ -552,30 +554,30 @@ public function toPriceFactor($Locale = null, $Customer = null)
}
return new PriceFactor([
'identifier' => 'discount-'.$this->getId(),
'title' => $this->getTitle($Locale),
'valueText' => $valueText,
'identifier' => 'discount-' . $this->getId(),
'title' => $this->getTitle($Locale),
'valueText' => $valueText,
'description' => '',
'priority' => (int)$this->getAttribute('priority'),
'priority' => (int)$this->getAttribute('priority'),
'calculation' => $calculation,
'basis' => $basis,
'value' => $this->getAttribute('discount') * -1,
'visible' => $hideDiscounts ? false : true,
'vat' => $this->getAttribute('vat')
'basis' => $basis,
'value' => $this->getAttribute('discount') * -1,
'visible' => $hideDiscounts ? false : true,
'vat' => $this->getAttribute('vat')
]);
}
// to product
return new QUI\ERP\Products\Utils\PriceFactor([
'identifier' => 'discount-'.$this->getId(),
'title' => $this->getTitle($Locale),
'identifier' => 'discount-' . $this->getId(),
'title' => $this->getTitle($Locale),
// 'valueText' => $this->getTitle($Locale),
'description' => '',
'priority' => (int)$this->getAttribute('priority'),
'priority' => (int)$this->getAttribute('priority'),
'calculation' => $calculation,
'basis' => $basis,
'value' => $this->getAttribute('discount') * -1,
'visible' => $hideDiscounts ? false : true
'basis' => $basis,
'value' => $this->getAttribute('discount') * -1,
'visible' => $hideDiscounts ? false : true
]);
}
......@@ -589,7 +591,7 @@ public function update()
$this->Events->fireEvent('saveBegin');
$this->Events->fireEvent('updateBegin');
$needles = $this->Factory->getChildAttributes();
$needles = $this->Factory->getChildAttributes();
$savedData = [];
foreach ($needles as $needle) {
......@@ -602,7 +604,7 @@ public function update()
switch ($needle) {
case 'user_groups':
if (!empty($value)) {
$value = ','.$value.',';
$value = ',' . $value . ',';
}
break;
}
......
......@@ -70,7 +70,7 @@ protected static function getUserDiscounts(QUI\Interfaces\Users\User $User): arr
*/
public static function isDiscountUsableWithQuantity(Discount $Discount, $quantity): bool
{
$purchaseQuantityFrom = $Discount->getAttribute('purchase_quantity_from');
$purchaseQuantityFrom = $Discount->getAttribute('purchase_quantity_from');
$purchaseQuantityUntil = $Discount->getAttribute('purchase_quantity_until');
if ($quantity === 0) {
......@@ -102,13 +102,15 @@ public static function isDiscountUsableWithQuantity(Discount $Discount, $quantit
*/
public static function isDiscountUsableWithPurchaseValue(Discount $Discount, $value): bool
{
$purchaseValueFrom = $Discount->getAttribute('purchase_value_from');
$purchaseValueFrom = $Discount->getAttribute('purchase_value_from');
$purchaseValueUntil = $Discount->getAttribute('purchase_value_until');
// 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') === ErpCalc::CALCULATION_COMPLEMENT
&& $Discount->getAttribute('discount') > $value) {
if (
(int)$Discount->getAttribute('discount_type') === ErpCalc::CALCULATION_COMPLEMENT
&& $Discount->getAttribute('discount') > $value
) {
return false;
}
......@@ -168,7 +170,7 @@ public static function onQuiqqerProductsCalcListProduct(
return;
}
$PriceFactors = $Product->getPriceFactors();
$PriceFactors = $Product->getPriceFactors();
$productQuantity = $Product->getQuantity();
$productNettoSum = $attributes['calculated_nettoSum'];
......@@ -184,7 +186,7 @@ public static function onQuiqqerProductsCalcListProduct(
// check if Pricefactor is already in
$factors = $PriceFactors->toArray();
$Factor = $Discount->toPriceFactor(
$Factor = $Discount->toPriceFactor(
$Calc->getUser()->getLocale(),
$Calc->getUser()
);
......@@ -237,7 +239,7 @@ public static function onQuiqqerProductsCalcList(
}
$listQuantity = $List->getQuantity();
$products = $List->getProducts();
$products = $List->getProducts();
$PriceFactors = $List->getPriceFactors();
/* @var $Discount Discount */
......@@ -307,7 +309,7 @@ public static function onQuiqqerProductsCalcList(
// check if Pricefactor is already in
$factors = $PriceFactors->toArray();
$Factor = $Discount->toPriceFactor(
$Factor = $Discount->toPriceFactor(
$Calc->getUser()->getLocale(),
$Calc->getUser()
);
......
......@@ -22,7 +22,7 @@ class Handler extends QUI\CRUD\Factory
const DISCOUNT_TYPE_PERCENT = 1;
/**
* discount type -> crrency
* discount type -> currency
*/
const DISCOUNT_TYPE_CURRENCY = 2;
......@@ -130,7 +130,7 @@ public function __construct()
// create new translation var for the discount
$this->Events->addEvent('onCreateEnd', function ($New, $data) {
/* @var $New QUI\ERP\Discount\Discount */
$newVar = 'discount.'.$New->getId().'.title';
$newVar = 'discount.' . $New->getId() . '.title';
$current = QUI::getLocale()->getCurrent();
$title = $New->getAttribute('title');
......@@ -146,9 +146,9 @@ public function __construct()
try {
QUI\Translator::addUserVar('quiqqer/discount', $newVar, [
$current => $title,
$current => $title,
'datatype' => 'php,js',
'package' => 'quiqqer/discount'
'package' => 'quiqqer/discount'
]);
} catch (QUI\Exception $Exception) {
QUI::getMessagesHandler()->addAttention(
......
......@@ -28,15 +28,15 @@ class Utils
public static function getUserDiscounts(UserInterface $User): array
{
$guString = UserGroups::getUserGroupStringFromUser($User);
$guString = ','.\str_replace(',', ',|,', $guString).',';
$guString = ',' . \str_replace(',', ',|,', $guString) . ',';
$result = [];
$result = [];
$Discounts = new Handler();
$personalDiscounts = $Discounts->getChildren([
'where' => [
'user_groups' => [
'type' => 'REGEXP',
'type' => 'REGEXP',
'value' => $guString
]
]
......@@ -70,14 +70,14 @@ public static function getUserDiscounts(UserInterface $User): array
*/
public static function getProductDiscounts(Product $Product): array
{
$result = [];
$result = [];
$Discounts = new Handler();
$productDiscounts = $Discounts->getChildren([
'where' => [
'user_groups' => [
'type' => 'REGEXP',
'value' => ','.$Product->getId().','
'type' => 'REGEXP',
'value' => ',' . $Product->getId() . ','
]
]
]);
......@@ -111,16 +111,16 @@ public static function getProductDiscounts(Product $Product): array
public static function getActiveUserDiscounts(UserInterface $User): array
{
$guString = UserGroups::getUserGroupStringFromUser($User);
$guString = ','.\str_replace(',', ',|,', $guString).',';
$guString = ',' . \str_replace(',', ',|,', $guString) . ',';
$result = [];
$result = [];
$Discounts = new Handler();
$personalDiscounts = $Discounts->getChildren([
'where' => [
'active' => 1,
'active' => 1,
'user_groups' => [
'type' => 'REGEXP',
'type' => 'REGEXP',
'value' => $guString
]
]
......@@ -128,14 +128,14 @@ public static function getActiveUserDiscounts(UserInterface $User): array
$discounts = $Discounts->getChildren([
'where' => [
'active' => 1,
'active' => 1,
'user_groups' => ''
]
]);
$discountsNULL = $Discounts->getChildren([
'where' => [
'active' => 1,
'active' => 1,
'user_groups' => null
]
]);
......@@ -180,7 +180,7 @@ public static function getActiveUserDiscounts(UserInterface $User): array
public static function getUsableUserDiscounts(UserInterface $User): array
{
$discounts = self::getActiveUserDiscounts($User);
$result = [];
$result = [];
/* @var $Discount Discount */
foreach ($discounts as $Discount) {
......
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