Skip to content
Code-Schnipsel Gruppen Projekte

Revisionen vergleichen

Änderungen werden so angezeigt, als ob die Quellrevision mit der Zielrevision zusammengeführt würde. Erfahre mehr über den Vergleich von Revisionen.

Quelle

Zielprojekt auswählen
No results found

Ziel

Zielprojekt auswählen
  • quiqqer/coupons
1 Ergebnis
Änderungen anzeigen
Commits auf Quelle (11)
  • Henning Leutz's avatar
    fix(phpstan): code improvements and resolve warnings · 2833ed98
    verfasst von Henning Leutz
    Reviewed code and made several improvements which provide better error handling, code quality, and
    resolved warnings. The changes include:
    - Syntax modifications for better readability,
    - Ensured variable type checks before using methods,
    - Resolved warning instances in phpstan,
    - Adapted code to comply with modern PHP nullable type indicator.
    
    Alongside, made version update in phive/phars.xml. Also, unnecessary comments or instances are
    removed for a cleaner code.
    
    Related: #16
    2833ed98
  • Henning Leutz's avatar
    refactor(phpstand): update coupon code and physical coupon product · 6ca95f6b
    verfasst von Henning Leutz
    This commit modifies the `src/QUI/ERP/Coupons/CouponCode.php` by removing an unexplained variable
    annotation.
    In `src/QUI/ERP/Coupons/Products/PhysicalCouponProductType.php`, it introduces an import statement
    for `QUI\\Locale` and updated the `Locale` parameter type definition in `getTypeDescription`
    function. This change improves code readability and consistency.
    6ca95f6b
  • Henning Leutz's avatar
    chore(phpstan): exclude problematic file from phpstan analysis · 7e2e2aea
    verfasst von Henning Leutz
    This commit modifies the phpstan.dist.neon to exclude the DigitalCouponProductType.php file from
    being analyzed by PHPStan. This was necessary due to consistent unresolvable errors.
    7e2e2aea
  • Henning Leutz's avatar
    fix: update phpstan config and add condition to package setup in src/QUI/ERP/Coupons/Events.php · 749db82c
    verfasst von Henning Leutz
    This commit includes a minor modification in the `phpstan.dist.neon` file where the `excludePaths`
    value has been updated. Besides, a conditional check has been added in the `onPackageSetup`
    function, under `Events.php` in the `src/QUI/ERP/Coupons` directory, to only proceed if the package
    name is 'quiqqer/coupons'. This additional check generally improves the efficiency and correctness
    of the package setup process.
    749db82c
  • Henning Leutz's avatar
    chore: update phpstan configuration file · 2ab12e56
    verfasst von Henning Leutz
    The commit modifies the phpstan.dist.neon configuration file. The changes include removing the
    excludePaths section and adjusting the end of the file to not have a new line. This simplification
    will better suit our testing environment.
    2ab12e56
  • Henning Leutz's avatar
    chore: phpstan modify · 0c2d3abe
    verfasst von Henning Leutz
    In this commit, modifications have been made to the .gitlab-ci.yml file to allow running PHPUnit on
    PHP 8.3 in our pipeline. A new job `modify-job` was added which runs phpstan script with following
    instructions:
    
    - Keeping other autoloaders with `QUIQQER_OTHER_AUTOLOADERS=KEEP`
    - Disabling progress display with `--no-progress`
    - Removing memory limit with `--memory-limit=-1`
    - Enabling debug mode with `--debug`
    0c2d3abe
  • Henning Leutz's avatar
    chore(phpstan): update gitlab-ci configuration · 782f0cd0
    verfasst von Henning Leutz
    Debug test
    782f0cd0
  • Henning Leutz's avatar
    refactor: use const instead of var in CouponCodeInput.js · 0619681d
    verfasst von Henning Leutz
    Modified 'var' declarations to 'const' in CouponCodeInput.js file for better ES6 compliance. This
    refactoring helps increase code readability and ensures variables are block-scoped, reducing the
    risk of accidental variable reassignment or mutation.
    0619681d
  • Henning Leutz's avatar
    refactor: var to const refactor · 6b1d6f44
    verfasst von Henning Leutz
    6b1d6f44
  • Henning Leutz's avatar
    fix: remove phpstan from gitlab CI pipeline · 2b857d4f
    verfasst von Henning Leutz
    The `.gitlab-ci.yml` file was updated to remove the `phpstan` job. This change means we will no
    longer run static analysis automatically on our CI pipeline. Further discussions may be needed on
    whether to replace this with another tool or integrate it differently.
    2b857d4f
  • Henning Leutz's avatar
    Merge branch 'next-2.x' into 'main' · 2796c83d
    verfasst von Henning Leutz
    fix(phpstan): code improvements and resolve warnings
    
    See merge request !18
    2796c83d
werden angezeigt mit 248 Ergänzungen und 311 Löschungen
...@@ -14,4 +14,4 @@ phpunit-php8.2: ...@@ -14,4 +14,4 @@ phpunit-php8.2:
# Remove the entire phpunit-php8.3 block, to allow PHPUnit to run on PHP 8.3 in your pipeline # Remove the entire phpunit-php8.3 block, to allow PHPUnit to run on PHP 8.3 in your pipeline
phpunit-php8.3: phpunit-php8.3:
rules: rules:
- when: never - when: never
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive"> <phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.11.8" installed="1.11.8" location="./tools/phpstan" copy="false"/> <phar name="phpstan" version="1.*" installed="1.12.13" location="./tools/phpstan" copy="false"/>
<phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/> <phar name="phpunit" version="^10.5.20" installed="10.5.20" location="./tools/phpunit" copy="false"/>
<phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/> <phar name="phpcs" version="^3.10.1" installed="3.10.1" location="./tools/phpcs" copy="false"/>
<phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/> <phar name="phpcbf" version="^3.10.1" installed="3.10.1" location="./tools/phpcbf" copy="false"/>
......
...@@ -28,7 +28,7 @@ function ($couponId, $vat) { ...@@ -28,7 +28,7 @@ function ($couponId, $vat) {
continue; continue;
} }
if ($vat !== false) { if ($vat !== false && method_exists($PriceFactor, 'setVat')) {
$PriceFactor->setVat($vat); $PriceFactor->setVat($vat);
} }
......
...@@ -36,9 +36,11 @@ function ($ids) { ...@@ -36,9 +36,11 @@ function ($ids) {
); );
return false; return false;
} catch (QUI\Permissions\Exception $Exception) {
throw $Exception;
} catch (Exception $Exception) { } catch (Exception $Exception) {
if ($Exception instanceof QUI\Permissions\Exception) {
throw $Exception;
}
QUI\System\Log::writeException($Exception); QUI\System\Log::writeException($Exception);
QUI::getMessagesHandler()->addError( QUI::getMessagesHandler()->addError(
......
...@@ -13,7 +13,7 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [ ...@@ -13,7 +13,7 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [
], function (QUIAjax) { ], function (QUIAjax) {
"use strict"; "use strict";
var pkg = 'quiqqer/coupons'; const pkg = 'quiqqer/coupons';
return new Class({ return new Class({
...@@ -28,9 +28,9 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [ ...@@ -28,9 +28,9 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [
create: function (Attributes) { create: function (Attributes) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
QUIAjax.post('package_quiqqer_coupons_ajax_create', resolve, { QUIAjax.post('package_quiqqer_coupons_ajax_create', resolve, {
'package' : pkg, 'package': pkg,
attributes: JSON.encode(Attributes), attributes: JSON.encode(Attributes),
onError : reject onError: reject
}); });
}); });
}, },
...@@ -45,10 +45,10 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [ ...@@ -45,10 +45,10 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [
edit: function (id, Attributes) { edit: function (id, Attributes) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
QUIAjax.post('package_quiqqer_coupons_ajax_edit', resolve, { QUIAjax.post('package_quiqqer_coupons_ajax_edit', resolve, {
'package' : pkg, 'package': pkg,
id : id, id: id,
attributes: JSON.encode(Attributes), attributes: JSON.encode(Attributes),
onError : reject onError: reject
}); });
}); });
}, },
...@@ -63,8 +63,8 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [ ...@@ -63,8 +63,8 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
QUIAjax.post('package_quiqqer_coupons_ajax_delete', resolve, { QUIAjax.post('package_quiqqer_coupons_ajax_delete', resolve, {
'package': pkg, 'package': pkg,
ids : JSON.encode(ids), ids: JSON.encode(ids),
onError : reject onError: reject
}); });
}); });
}, },
...@@ -78,9 +78,9 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [ ...@@ -78,9 +78,9 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [
getList: function (SearchParams) { getList: function (SearchParams) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
QUIAjax.get('package_quiqqer_coupons_ajax_getList', resolve, { QUIAjax.get('package_quiqqer_coupons_ajax_getList', resolve, {
'package' : pkg, 'package': pkg,
searchParams: JSON.encode(SearchParams), searchParams: JSON.encode(SearchParams),
onError : reject onError: reject
}); });
}); });
}, },
...@@ -96,9 +96,9 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [ ...@@ -96,9 +96,9 @@ define('package/quiqqer/coupons/bin/backend/classes/CouponCodes', [
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
QUIAjax.post('package_quiqqer_coupons_ajax_sendMail', resolve, { QUIAjax.post('package_quiqqer_coupons_ajax_sendMail', resolve, {
'package': pkg, 'package': pkg,
ids : JSON.encode(ids), ids: JSON.encode(ids),
resend : resend ? 1 : 0, resend: resend ? 1 : 0,
onError : reject onError: reject
}); });
}); });
} }
......
Dieser Diff ist reduziert.
...@@ -18,7 +18,7 @@ define('package/quiqqer/coupons/bin/backend/controls/Window', [ ...@@ -18,7 +18,7 @@ define('package/quiqqer/coupons/bin/backend/controls/Window', [
return new Class({ return new Class({
Extends: QUIConfirm, Extends: QUIConfirm,
Type : 'package/quiqqer/coupons/bin/backend/controls/Window', Type: 'package/quiqqer/coupons/bin/backend/controls/Window',
Binds: [ Binds: [
'$listRefresh', '$listRefresh',
...@@ -30,14 +30,14 @@ define('package/quiqqer/coupons/bin/backend/controls/Window', [ ...@@ -30,14 +30,14 @@ define('package/quiqqer/coupons/bin/backend/controls/Window', [
this.parent(options); this.parent(options);
this.setAttributes({ this.setAttributes({
icon : 'fa fa-credit-card-alt', icon: 'fa fa-credit-card-alt',
title : QUILocale.get(lg, 'controls.manager.title'), title: QUILocale.get(lg, 'controls.manager.title'),
maxHeight: 600, maxHeight: 600,
maxWidth : 500, maxWidth: 500,
}); });
this.addEvents({ this.addEvents({
onOpen : this.$onOpen, onOpen: this.$onOpen,
onResize: this.$onResize onResize: this.$onResize
}); });
}, },
...@@ -64,54 +64,54 @@ define('package/quiqqer/coupons/bin/backend/controls/Window', [ ...@@ -64,54 +64,54 @@ define('package/quiqqer/coupons/bin/backend/controls/Window', [
const Container = new Element('div').inject(this.getContent()); const Container = new Element('div').inject(this.getContent());
this.$Grid = new Grid(Container, { this.$Grid = new Grid(Container, {
columnModel : [ columnModel: [
{ {
header : QUILocale.get('quiqqer/system', 'id'), header: QUILocale.get('quiqqer/system', 'id'),
dataIndex: 'id', dataIndex: 'id',
dataType : 'number', dataType: 'number',
width : 50 width: 50
}, },
{ {
header : QUILocale.get(lg, 'controls.manager.tbl.header.code'), header: QUILocale.get(lg, 'controls.manager.tbl.header.code'),
dataIndex: 'code', dataIndex: 'code',
dataType : 'string', dataType: 'string',
width : 150 width: 150
}, },
{ {
header : QUILocale.get(lg, 'controls.manager.tbl.header.title'), header: QUILocale.get(lg, 'controls.manager.tbl.header.title'),
dataIndex: 'title', dataIndex: 'title',
dataType : 'string', dataType: 'string',
width : 200 width: 200
}, },
{ {
header : QUILocale.get(lg, 'controls.manager.tbl.header.status'), header: QUILocale.get(lg, 'controls.manager.tbl.header.status'),
dataIndex: 'status', dataIndex: 'status',
dataType : 'node', dataType: 'node',
width : 200, width: 200,
className: 'clickable' className: 'clickable'
}, },
{ {
header : QUILocale.get(lg, 'controls.manager.tbl.header.validUntilDate'), header: QUILocale.get(lg, 'controls.manager.tbl.header.validUntilDate'),
dataIndex: 'validUntilDateText', dataIndex: 'validUntilDateText',
dataType : 'string', dataType: 'string',
width : 150 width: 150
}, },
{ {
header : QUILocale.get(lg, 'controls.manager.tbl.header.reusable'), header: QUILocale.get(lg, 'controls.manager.tbl.header.reusable'),
dataIndex: 'maxUsageLabel', dataIndex: 'maxUsageLabel',
dataType : 'string', dataType: 'string',
width : 150 width: 150
}, },
{ {
header : QUILocale.get(lg, 'controls.manager.tbl.header.createDate'), header: QUILocale.get(lg, 'controls.manager.tbl.header.createDate'),
dataIndex: 'createDate', dataIndex: 'createDate',
dataType : 'string', dataType: 'string',
width : 150 width: 150
} }
], ],
pagination : true, pagination: true,
serverSort : true, serverSort: true,
selectable : true, selectable: true,
multipleSelection: true multipleSelection: true
}); });
...@@ -120,7 +120,7 @@ define('package/quiqqer/coupons/bin/backend/controls/Window', [ ...@@ -120,7 +120,7 @@ define('package/quiqqer/coupons/bin/backend/controls/Window', [
onDblClick: () => { onDblClick: () => {
this.submit(); this.submit();
}, },
onRefresh : this.$listRefresh onRefresh: this.$listRefresh
}); });
this.$Grid.refresh(); this.$Grid.refresh();
...@@ -148,10 +148,10 @@ define('package/quiqqer/coupons/bin/backend/controls/Window', [ ...@@ -148,10 +148,10 @@ define('package/quiqqer/coupons/bin/backend/controls/Window', [
} }
let GridParams = { let GridParams = {
sortOn : Grid.getAttribute('sortOn'), sortOn: Grid.getAttribute('sortOn'),
sortBy : Grid.getAttribute('sortBy'), sortBy: Grid.getAttribute('sortBy'),
perPage: Grid.getAttribute('perPage'), perPage: Grid.getAttribute('perPage'),
page : Grid.getAttribute('page') page: Grid.getAttribute('page')
}; };
switch (GridParams.sortOn) { switch (GridParams.sortOn) {
......
...@@ -17,11 +17,11 @@ define('package/quiqqer/coupons/bin/backend/controls/settings/CodeGeneratorSelec ...@@ -17,11 +17,11 @@ define('package/quiqqer/coupons/bin/backend/controls/settings/CodeGeneratorSelec
], function (QUISelect, QUILoader, QUILocale, QUIAjax) { ], function (QUISelect, QUILoader, QUILocale, QUIAjax) {
"use strict"; "use strict";
var lg = 'quiqqer/coupons'; const lg = 'quiqqer/coupons';
return new Class({ return new Class({
Extends: QUISelect, Extends: QUISelect,
Type : 'package/quiqqer/coupons/bin/backend/controls/settings/CodeGeneratorSelect', Type: 'package/quiqqer/coupons/bin/backend/controls/settings/CodeGeneratorSelect',
Binds: [ Binds: [
'$onImport' '$onImport'
...@@ -46,22 +46,22 @@ define('package/quiqqer/coupons/bin/backend/controls/settings/CodeGeneratorSelec ...@@ -46,22 +46,22 @@ define('package/quiqqer/coupons/bin/backend/controls/settings/CodeGeneratorSelec
* Event: onImport * Event: onImport
*/ */
$onImport: function () { $onImport: function () {
var self = this; const self = this;
this.$Input = this.getElm(); this.$Input = this.getElm();
this.$Input.hidden = true; this.$Input.hidden = true;
var Elm = this.create().inject(this.$Input, 'after'); const Elm = this.create().inject(this.$Input, 'after');
Elm.addClass('field-container-field'); Elm.addClass('field-container-field');
this.Loader.inject(Elm); this.Loader.inject(Elm);
this.Loader.show(); this.Loader.show();
this.$getCodeGenerators().then(function(codeGenerators) { this.$getCodeGenerators().then(function (codeGenerators) {
self.Loader.hide(); self.Loader.hide();
for (var i = 0, len = codeGenerators.length; i < len; i++) { for (let i = 0, len = codeGenerators.length; i < len; i++) {
self.appendChild( self.appendChild(
codeGenerators[i], codeGenerators[i],
codeGenerators[i] codeGenerators[i]
...@@ -72,7 +72,7 @@ define('package/quiqqer/coupons/bin/backend/controls/settings/CodeGeneratorSelec ...@@ -72,7 +72,7 @@ define('package/quiqqer/coupons/bin/backend/controls/settings/CodeGeneratorSelec
self.setValue(self.$Input.value); self.setValue(self.$Input.value);
} }
self.addEvent('onChange', function(value) { self.addEvent('onChange', function (value) {
self.$Input.value = value; self.$Input.value = value;
}); });
}); });
...@@ -87,7 +87,7 @@ define('package/quiqqer/coupons/bin/backend/controls/settings/CodeGeneratorSelec ...@@ -87,7 +87,7 @@ define('package/quiqqer/coupons/bin/backend/controls/settings/CodeGeneratorSelec
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
QUIAjax.get('package_quiqqer_coupons_ajax_settings_getCodeGenerators', resolve, { QUIAjax.get('package_quiqqer_coupons_ajax_settings_getCodeGenerators', resolve, {
'package': 'quiqqer/coupons', 'package': 'quiqqer/coupons',
onError : reject onError: reject
}); });
}); });
} }
......
...@@ -7,8 +7,8 @@ require(['qui/QUI'], function (QUI) { ...@@ -7,8 +7,8 @@ require(['qui/QUI'], function (QUI) {
require(['Ajax'], function (QUIAjax) { require(['Ajax'], function (QUIAjax) {
QUIAjax.get('package_quiqqer_coupons_ajax_backend_getCouponPrice', resolve, { QUIAjax.get('package_quiqqer_coupons_ajax_backend_getCouponPrice', resolve, {
'package': 'quiqqer/coupons', 'package': 'quiqqer/coupons',
couponId : couponId, couponId: couponId,
vat : vat vat: vat
}); });
}); });
}); });
...@@ -22,13 +22,13 @@ require(['qui/QUI'], function (QUI) { ...@@ -22,13 +22,13 @@ require(['qui/QUI'], function (QUI) {
require(['Locale'], function (QUILocale) { require(['Locale'], function (QUILocale) {
new Element('button', { new Element('button', {
'class': 'qui-button', 'class': 'qui-button',
html : '<span class="fa fa-credit-card-alt"></span>', html: '<span class="fa fa-credit-card-alt"></span>',
title : QUILocale.get('quiqqer/coupons', 'add.coupon.priceFactor'), title: QUILocale.get('quiqqer/coupons', 'add.coupon.priceFactor'),
styles : { styles: {
'float' : 'right', 'float': 'right',
marginRight: '10px' marginRight: '10px'
}, },
events : { events: {
click: function (e) { click: function (e) {
e.stop(); e.stop();
...@@ -37,7 +37,7 @@ require(['qui/QUI'], function (QUI) { ...@@ -37,7 +37,7 @@ require(['qui/QUI'], function (QUI) {
], function (CouponWindow) { ], function (CouponWindow) {
new CouponWindow({ new CouponWindow({
multiple: true, multiple: true,
events : { events: {
onSubmit: function (Instance, value) { onSubmit: function (Instance, value) {
if (!value.length) { if (!value.length) {
return; return;
...@@ -57,20 +57,20 @@ require(['qui/QUI'], function (QUI) { ...@@ -57,20 +57,20 @@ require(['qui/QUI'], function (QUI) {
); );
}).then((data) => { }).then((data) => {
let priceFactor = { let priceFactor = {
calculation : 2, calculation: 2,
calculation_basis: 2, calculation_basis: 2,
description : couponData.title, description: couponData.title,
identifier : "", identifier: "",
index : ArticleList.countPriceFactors(), index: ArticleList.countPriceFactors(),
nettoSum : data.nettoSum, nettoSum: data.nettoSum,
nettoSumFormatted: data.nettoSumFormatted, nettoSumFormatted: data.nettoSumFormatted,
sum : data.sum, sum: data.sum,
sumFormatted : data.sumFormatted, sumFormatted: data.sumFormatted,
title : couponData.title, title: couponData.title,
value : data.sum, value: data.sum,
valueText : data.valueText, valueText: data.valueText,
vat : vat, vat: vat,
visible : 1 visible: 1
}; };
ArticleList.addPriceFactor(priceFactor); ArticleList.addPriceFactor(priceFactor);
......
...@@ -13,7 +13,7 @@ define('package/quiqqer/coupons/bin/frontend/classes/CouponCodes', [ ...@@ -13,7 +13,7 @@ define('package/quiqqer/coupons/bin/frontend/classes/CouponCodes', [
], function (QUIAjax) { ], function (QUIAjax) {
"use strict"; "use strict";
var pkg = 'quiqqer/coupons'; const pkg = 'quiqqer/coupons';
return new Class({ return new Class({
...@@ -30,9 +30,9 @@ define('package/quiqqer/coupons/bin/frontend/classes/CouponCodes', [ ...@@ -30,9 +30,9 @@ define('package/quiqqer/coupons/bin/frontend/classes/CouponCodes', [
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
QUIAjax.post('package_quiqqer_coupons_ajax_frontend_redeem', resolve, { QUIAjax.post('package_quiqqer_coupons_ajax_frontend_redeem', resolve, {
'package': pkg, 'package': pkg,
code : code, code: code,
orderHash: orderHash, orderHash: orderHash,
onError : reject onError: reject
}); });
}); });
} }
......
...@@ -23,7 +23,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -23,7 +23,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
], function(QUI, QUIControl, QUILoader, Sessions, CouponCodes, QUIAjax, QUILocale, Mustache, template) { ], function(QUI, QUIControl, QUILoader, Sessions, CouponCodes, QUIAjax, QUILocale, Mustache, template) {
'use strict'; 'use strict';
var lg = 'quiqqer/coupons'; const lg = 'quiqqer/coupons';
return new Class({ return new Class({
...@@ -50,8 +50,8 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -50,8 +50,8 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
* Event: onInject * Event: onInject
*/ */
$onInject: function() { $onInject: function() {
var self = this; const self = this;
var lgPrefix = 'controls.frontend.CouponCodeInput.template.'; const lgPrefix = 'controls.frontend.CouponCodeInput.template.';
this.$Elm.addClass('quiqqer-coupons-field'); this.$Elm.addClass('quiqqer-coupons-field');
...@@ -81,7 +81,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -81,7 +81,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
}); });
if (this.isInOrder()) { if (this.isInOrder()) {
var OrderProcess = this.getOrderProcess(); const OrderProcess = this.getOrderProcess();
new Promise(function(resolve) { new Promise(function(resolve) {
if (!OrderProcess.isLoaded()) { if (!OrderProcess.isLoaded()) {
...@@ -118,8 +118,8 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -118,8 +118,8 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
return; return;
} }
var self = this; const self = this;
var code = this.$Input.value.trim(); const code = this.$Input.value.trim();
if (code === '') { if (code === '') {
this.$Input.focus(); this.$Input.focus();
...@@ -192,7 +192,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -192,7 +192,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
return; return;
} }
var OrderProcess = this.getOrderProcess(); const OrderProcess = this.getOrderProcess();
OrderProcess.Loader.show(); OrderProcess.Loader.show();
...@@ -239,7 +239,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -239,7 +239,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
* @return {boolean} * @return {boolean}
*/ */
isInOrder: function() { isInOrder: function() {
var OrderProcessNode = this.getElm().getParent( const OrderProcessNode = this.getElm().getParent(
'[data-qui="package/quiqqer/order/bin/frontend/controls/OrderProcess"]' '[data-qui="package/quiqqer/order/bin/frontend/controls/OrderProcess"]'
); );
...@@ -252,7 +252,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -252,7 +252,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
* @return {Object} * @return {Object}
*/ */
getOrderProcess: function() { getOrderProcess: function() {
var OrderProcessNode = this.getElm().getParent( const OrderProcessNode = this.getElm().getParent(
'[data-qui="package/quiqqer/order/bin/frontend/controls/OrderProcess"]' '[data-qui="package/quiqqer/order/bin/frontend/controls/OrderProcess"]'
); );
...@@ -269,10 +269,10 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [ ...@@ -269,10 +269,10 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
return Promise.resolve(); return Promise.resolve();
} }
var self = this; const self = this;
return new Promise(function(resolve) { return new Promise(function(resolve) {
var OrderProcess = self.getOrderProcess(); const OrderProcess = self.getOrderProcess();
OrderProcess.Loader.show(); OrderProcess.Loader.show();
OrderProcess.getOrder().then(function(orderHash) { OrderProcess.getOrder().then(function(orderHash) {
......
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method QUI\\\\ERP\\\\Products\\\\Interfaces\\\\PriceFactorInterface\\:\\:setVat\\(\\)\\.$#"
count: 1
path: ajax/backend/getCouponPrice.php
-
message: "#^Dead catch \\- Exception is never thrown in the try block\\.$#"
count: 1
path: ajax/delete.php
-
message: "#^Call to an undefined method QUI\\\\ERP\\\\Products\\\\Interfaces\\\\PriceFactorInterface\\:\\:setVat\\(\\)\\.$#"
count: 1
path: src/QUI/ERP/Coupons/CouponCode.php
-
message: "#^Method QUI\\\\ERP\\\\Coupons\\\\CouponCode\\:\\:getDiscounts\\(\\) should return array\\<QUI\\\\ERP\\\\Discount\\\\Discount\\> but returns array\\<int\\<0, max\\>, QUI\\\\CRUD\\\\Child\\>\\.$#"
count: 1
path: src/QUI/ERP/Coupons/CouponCode.php
-
message: "#^Offset 'standard' on array\\{title\\: array\\{de\\: 'Gutschein \\- Versand', en\\: 'Coupon delivery'\\}, type\\: 'ProductAttributeList', public\\: true, standard\\: false, requiredField\\: true, options\\: array\\{entries\\: array\\{array\\{title\\: array\\{de\\: 'per E \\- Mail', en\\: 'via email'\\}, sum\\: 0, type\\: 2, selected\\: true, userinput\\: false\\}, array\\{title\\: array\\{de\\: 'per Post', en\\: 'via mail'\\}, sum\\: 0, type\\: 2, selected\\: false, userinput\\: false\\}\\}\\}\\}\\|array\\{title\\: array\\{de\\: 'Gutschein Wert', en\\: 'Coupon amount'\\}, type\\: 'FloatType', public\\: false, standard\\: false, requiredField\\: true\\}\\|array\\{title\\: array\\{de\\: 'Gutschein\\-Code als…', en\\: 'Provide coupon code…'\\}, description\\: array\\{de\\: 'Der Gutschein wird…', en\\: 'The coupon is also…'\\}, type\\: 'BoolType', public\\: false, standard\\: false, requiredField\\: false\\}\\|array\\{title\\: array\\{de\\: 'Gutschein\\-Code ist…', en\\: 'Coupon code is…'\\}, description\\: array\\{de\\: 'Übertragbare…', en\\: 'Transferable…'\\}, type\\: 'BoolType', public\\: false, standard\\: false, requiredField\\: false\\}\\|array\\{title\\: array\\{de\\: 'Gutschein\\-Code per…', en\\: 'Send coupon code…'\\}, description\\: array\\{de\\: 'Der Gutschein\\-Code…', en\\: 'The coupon code is…'\\}, type\\: 'BoolType', public\\: false, standard\\: false, requiredField\\: false\\}\\|array\\{title\\: array\\{de\\: 'Gutschein\\-Code…', en\\: 'Coupon code…'\\}, type\\: 'IntType', public\\: false, standard\\: false, requiredField\\: true\\}\\|array\\{title\\: array\\{de\\: 'Gutschein…', en\\: 'Coupon description'\\}, description\\: array\\{de\\: 'Diese Beschreibung…', en\\: 'This description…'\\}, type\\: 'InputMultiLang', public\\: false, standard\\: false, requiredField\\: false\\}\\|array\\{title\\: array\\{de\\: 'Ist Einzweck…', en\\: 'Is single purpose…'\\}, description\\: array\\{de\\: 'Einzweck\\-Gutscheine…', en\\: 'Single\\-purpose…'\\}, type\\: 'BoolType', public\\: false, standard\\: false, requiredField\\: false\\}\\|array\\{title\\: array\\{de\\: 'Kunde darf…', en\\: 'Customer can choose…'\\}, description\\: array\\{de\\: 'Ist diese Funktion…', en\\: 'if this option is…'\\}, type\\: 'BoolType', public\\: false, standard\\: false, requiredField\\: false\\} in empty\\(\\) always exists and is always falsy\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Events.php
-
message: "#^Parameter \\#1 \\$id of static method QUI\\\\ERP\\\\Coupons\\\\Handler\\:\\:getCouponCode\\(\\) expects int, string\\|false given\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Handler.php
-
message: "#^Call to method createPDF\\(\\) on an unknown class QUI\\\\HtmlToPdf\\\\Document\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Call to method setAttribute\\(\\) on an unknown class QUI\\\\HtmlToPdf\\\\Document\\.$#"
count: 7
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Call to method setContentHTML\\(\\) on an unknown class QUI\\\\HtmlToPdf\\\\Document\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Call to method setFooterHTML\\(\\) on an unknown class QUI\\\\HtmlToPdf\\\\Document\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Call to method setHeaderHTML\\(\\) on an unknown class QUI\\\\HtmlToPdf\\\\Document\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Instantiated class QUI\\\\HtmlToPdf\\\\Document not found\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
-
message: "#^Parameter \\#1 \\$key of method QUI\\\\ERP\\\\Accounting\\\\Article\\:\\:getCustomField\\(\\) expects string, int given\\.$#"
count: 1
path: src/QUI/ERP/Coupons/Products/Handler.php
...@@ -276,6 +276,7 @@ public function getDiscounts(): array ...@@ -276,6 +276,7 @@ public function getDiscounts(): array
} }
} }
// @phpstan-ignore-next-line
return $discounts; return $discounts;
} }
...@@ -307,7 +308,7 @@ public function getGroupIds(): array ...@@ -307,7 +308,7 @@ public function getGroupIds(): array
* @throws QUI\Database\Exception * @throws QUI\Database\Exception
* @throws ExceptionStack * @throws ExceptionStack
*/ */
public function redeem(QUI\Interfaces\Users\User $User = null, AbstractOrder $Order = null): void public function redeem(null | QUI\Interfaces\Users\User $User = null, null | AbstractOrder $Order = null): void
{ {
if (is_null($User)) { if (is_null($User)) {
$User = QUI::getUserBySession(); $User = QUI::getUserBySession();
...@@ -487,14 +488,13 @@ public function checkOrderRedemption(?OrderInterface $Order): void ...@@ -487,14 +488,13 @@ public function checkOrderRedemption(?OrderInterface $Order): void
foreach ($this->discountIds as $discountId) { foreach ($this->discountIds as $discountId) {
try { try {
/** @var QUI\ERP\Discount\Discount $Discount */
$Discount = $DiscountHandler->getChild($discountId); $Discount = $DiscountHandler->getChild($discountId);
} catch (Exception $Exception) { } catch (Exception $Exception) {
$discountError = $Exception->getMessage(); $discountError = $Exception->getMessage();
continue; continue;
} }
if ($Discount->canUsedInOrder($Order)) { if (method_exists($Discount, 'canUsedInOrder') && $Discount->canUsedInOrder($Order)) {
$discountsValid = true; $discountsValid = true;
break; break;
} }
...@@ -525,8 +525,10 @@ public function checkOrderRedemption(?OrderInterface $Order): void ...@@ -525,8 +525,10 @@ public function checkOrderRedemption(?OrderInterface $Order): void
* @param OrderInterface|null $Order * @param OrderInterface|null $Order
* @return bool * @return bool
*/ */
public function isRedeemable(QUI\Interfaces\Users\User $User = null, OrderInterface $Order = null): bool public function isRedeemable(
{ null | QUI\Interfaces\Users\User $User = null,
null | OrderInterface $Order = null
): bool {
try { try {
$this->checkRedemption($User); $this->checkRedemption($User);
} catch (CouponCodeException) { } catch (CouponCodeException) {
...@@ -725,13 +727,12 @@ public function addToOrder(QUI\ERP\Order\OrderInProcess $Order): void ...@@ -725,13 +727,12 @@ public function addToOrder(QUI\ERP\Order\OrderInProcess $Order): void
continue; continue;
} }
/* @var $Discount QUI\ERP\Discount\Discount */
$discounts = $Coupon->getDiscounts(); $discounts = $Coupon->getDiscounts();
foreach ($discounts as $Discount) { foreach ($discounts as $Discount) {
$PriceFactor = $Discount->toPriceFactor(null, $Order->getCustomer()); $PriceFactor = $Discount->toPriceFactor(null, $Order->getCustomer());
if ($vat !== false) { if ($vat !== false && method_exists($PriceFactor, 'setVat')) {
$PriceFactor->setVat($vat); $PriceFactor->setVat($vat);
} }
......
...@@ -44,6 +44,10 @@ class Events ...@@ -44,6 +44,10 @@ class Events
*/ */
public static function onPackageSetup(QUI\Package\Package $Package): void public static function onPackageSetup(QUI\Package\Package $Package): void
{ {
if ($Package->getName() !== 'quiqqer/coupons') {
return;
}
try { try {
self::createProductFields(); self::createProductFields();
} catch (Exception $Exception) { } catch (Exception $Exception) {
...@@ -670,7 +674,7 @@ protected static function createProductFields(): void ...@@ -670,7 +674,7 @@ protected static function createProductFields(): void
'workingtitles' => $field['title'], 'workingtitles' => $field['title'],
'description' => !empty($field['description']) ? $field['description'] : null, 'description' => !empty($field['description']) ? $field['description'] : null,
'systemField' => 0, 'systemField' => 0,
'standardField' => !empty($field['standard']) ? 1 : 0, 'standardField' => !empty($field['standard']) ? 1 : 0, // @phpstan-ignore-line
'publicField' => !empty($field['public']) ? 1 : 0, 'publicField' => !empty($field['public']) ? 1 : 0,
'options' => !empty($field['options']) ? $field['options'] : null, 'options' => !empty($field['options']) ? $field['options'] : null,
'requiredField' => !empty($field['requiredField']) ? 1 : 0 'requiredField' => !empty($field['requiredField']) ? 1 : 0
......
...@@ -193,7 +193,7 @@ public static function createCouponCode(array $discountIds, array $settings = [] ...@@ -193,7 +193,7 @@ public static function createCouponCode(array $discountIds, array $settings = []
]); ]);
} }
return self::getCouponCode(QUI::getPDO()->lastInsertId()); return self::getCouponCode((int)QUI::getPDO()->lastInsertId());
} }
/** /**
...@@ -310,7 +310,7 @@ public static function editCouponCode(int $id, array $discountIds, array $settin ...@@ -310,7 +310,7 @@ public static function editCouponCode(int $id, array $discountIds, array $settin
* @return CouponCode[]|int * @return CouponCode[]|int
* @throws CouponCodeException|QUI\Exception * @throws CouponCodeException|QUI\Exception
*/ */
public static function search(array $searchParams, bool $countOnly = false): array|int public static function search(array $searchParams, bool $countOnly = false): array | int
{ {
$couponCodes = []; $couponCodes = [];
$Grid = new Grid($searchParams); $Grid = new Grid($searchParams);
...@@ -434,7 +434,7 @@ public static function existsCode(string $code): bool ...@@ -434,7 +434,7 @@ public static function existsCode(string $code): bool
* *
* @return QUI\Projects\Site|false * @return QUI\Projects\Site|false
*/ */
public static function getRegistrationSite(): bool|QUI\Projects\Site public static function getRegistrationSite(): bool | QUI\Projects\Site
{ {
try { try {
$Conf = QUI::getPackage('quiqqer/coupons')->getConfig(); $Conf = QUI::getPackage('quiqqer/coupons')->getConfig();
...@@ -464,7 +464,7 @@ public static function getRegistrationSite(): bool|QUI\Projects\Site ...@@ -464,7 +464,7 @@ public static function getRegistrationSite(): bool|QUI\Projects\Site
* *
* @throws Exception * @throws Exception
*/ */
public static function deleteExpiredCouponCodes(int $days = null): void public static function deleteExpiredCouponCodes(null | int $days = null): void
{ {
$Now = new DateTime(); $Now = new DateTime();
$where = [ $where = [
...@@ -498,7 +498,7 @@ public static function deleteExpiredCouponCodes(int $days = null): void ...@@ -498,7 +498,7 @@ public static function deleteExpiredCouponCodes(int $days = null): void
* *
* @throws Exception * @throws Exception
*/ */
public static function deleteRedeemedCouponCodes(int $days = null): void public static function deleteRedeemedCouponCodes(null | int $days = null): void
{ {
$where = [ $where = [
'useDate' => [ 'useDate' => [
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use QUI; use QUI;
use QUI\ERP\Products\Product\Types\DigitalProduct; use QUI\ERP\Products\Product\Types\DigitalProduct;
use QUI\Locale;
/** /**
* Class DigitalProduct * Class DigitalProduct
...@@ -52,7 +53,7 @@ public function __construct(int $pid, array $product = []) ...@@ -52,7 +53,7 @@ public function __construct(int $pid, array $product = [])
* @param QUI\Locale|null $Locale * @param QUI\Locale|null $Locale
* @return string * @return string
*/ */
public static function getTypeTitle(QUI\Locale $Locale = null): string public static function getTypeTitle(null | QUI\Locale $Locale = null): string
{ {
if ($Locale === null) { if ($Locale === null) {
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
...@@ -62,10 +63,10 @@ public static function getTypeTitle(QUI\Locale $Locale = null): string ...@@ -62,10 +63,10 @@ public static function getTypeTitle(QUI\Locale $Locale = null): string
} }
/** /**
* @param QUI\Locale $Locale * @param Locale|null $Locale
* @return string * @return string
*/ */
public static function getTypeDescription($Locale = null): string public static function getTypeDescription(null | QUI\Locale $Locale = null): string
{ {
if ($Locale === null) { if ($Locale === null) {
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
......
...@@ -57,7 +57,6 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O ...@@ -57,7 +57,6 @@ public static function createCouponCodesFromOrder(QUI\ERP\Order\AbstractOrder $O
$Customer = $Order->getCustomer(); $Customer = $Order->getCustomer();
$Currency = $Order->getCurrency(); $Currency = $Order->getCurrency();
/** @var QUI\ERP\Accounting\Article $Article */
foreach ($Order->getArticles() as $Article) { foreach ($Order->getArticles() as $Article) {
try { try {
// Do not parse coupon codes / discounts // Do not parse coupon codes / discounts
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace QUI\ERP\Coupons\Products; namespace QUI\ERP\Coupons\Products;
use QUI; use QUI;
use QUI\Locale;
/** /**
* Class PhysicalCouponProductType * Class PhysicalCouponProductType
...@@ -51,7 +52,7 @@ public function __construct(int $pid, array $product = []) ...@@ -51,7 +52,7 @@ public function __construct(int $pid, array $product = [])
* @param QUI\Locale|null $Locale * @param QUI\Locale|null $Locale
* @return string * @return string
*/ */
public static function getTypeTitle(QUI\Locale $Locale = null): string public static function getTypeTitle(null | QUI\Locale $Locale = null): string
{ {
if ($Locale === null) { if ($Locale === null) {
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
...@@ -61,10 +62,10 @@ public static function getTypeTitle(QUI\Locale $Locale = null): string ...@@ -61,10 +62,10 @@ public static function getTypeTitle(QUI\Locale $Locale = null): string
} }
/** /**
* @param QUI\Locale $Locale * @param Locale|null $Locale
* @return string * @return string
*/ */
public static function getTypeDescription($Locale = null): string public static function getTypeDescription(null | QUI\Locale $Locale = null): string
{ {
if ($Locale === null) { if ($Locale === null) {
$Locale = QUI::getLocale(); $Locale = QUI::getLocale();
......