Skip to content

Commit

Permalink
Source price Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Apr 25, 2024
1 parent 67b7468 commit 6463b6e
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 131 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ buildx:

drun:
docker run -f Containerfile --env-file .env vitexsoftware/abraflexi-pricefixer:latest

phar:
phar-composer build .
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"phpunit/phpunit": "11.1.x-dev"
},
"license": "MIT",
"bin": ["src/fixall.php", "src/pricefix.php", "src/init.php"],
"autoload": {
"psr-4": {
"AbraFlexi\\PriceFix\\": "src/PriceFix/"
Expand Down
211 changes: 105 additions & 106 deletions composer.lock

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
abraflexi-pricefixer (2.8) UNRELEASED; urgency=low
abraflexi-pricefixer (2.9.0) UNRELEASED; urgency=medium

* Source price fix

-- Vítězslav Dvořák <[email protected]> Thu, 25 Apr 2024 10:37:03 +0200

abraflexi-pricefixer (2.8) jammy; urgency=low

* Initial release. Closes: #nnnn
<nnnn is the bug number of your ITP>

-- Vítězslav Dvořák <[email protected]> Thu, 21 Mar 2024 11:50:44 +0100
-- Vítězslav Dvořák <[email protected]> Thu, 25 Apr 2024 10:36:45 +0200
30 changes: 14 additions & 16 deletions src/PriceFix/Bundler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,32 @@

use AbraFlexi\Cenik;

class Bundler extends \AbraFlexi\Cenik
{
class Bundler extends \AbraFlexi\Cenik {

/**
* Load Product
*
* @param string $code
* calculate the selling price from the purchase prices of the price set
* items
*
* @return float
*/
public function overallPrice()
{
public function overallPrice() {
$subproductHelper = new Cenik();

$subitemsPrice = 0;

foreach ($this->getDataValue('sady-a-komplety') as $item) {
$subproductHelper->loadFromAbraFlexi(\AbraFlexi\Functions::code($item['cenik']));
$subitemsPrice += $subproductHelper->getDataValue('cenaZakl');

This comment has been minimized.

Copy link
@Vitexus

Vitexus Apr 25, 2024

Author Contributor

Main Change

$subitemsPrice += $subproductHelper->getDataValue('nakupCena');
}
return $subitemsPrice;
}

/**
* Save Bundle Price
*
* @param float $price to save
*
* @return boolean
* @return array
*/
public function saveBundlePrice($price)
{
public function saveBundlePrice($price) {
return $this->insertToAbraFlexi([
'id' => $this->getRecordIdent(),
'nakupCena' => $price,
Expand All @@ -49,7 +48,7 @@ public function saveBundlePrice($price)
//"cenaZaklBezDph" ?
//"cenaZaklVcDph" ?
//"cenaZakl" ?
]);
]);
}

/**
Expand All @@ -59,8 +58,7 @@ public function saveBundlePrice($price)
*
* @return boolean
*/
public function saveProviderPrice($price)
{
public function saveProviderPrice($price) {
$supplier = new \AbraFlexi\RW([
'cenik' => $this->getRecordCode(),
'firma' => \Ease\Shared::cfg('ABRAFLEXI_PROVIDER', 'code:PRICEFIXER'),
Expand Down
6 changes: 2 additions & 4 deletions src/fixall.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
*
* @copyright (c) 2024, Vítězslav Dvořák
*/

use AbraFlexi\Cenik;
use Ease\Shared;

define('APP_NAME', 'AbraFlexi PriceFix crawler');

require_once '../vendor/autoload.php';

Shared::init(['ABRAFLEXI_URL', 'ABRAFLEXI_LOGIN', 'ABRAFLEXI_PASSWORD', 'ABRAFLEXI_COMPANY'], '../.env');
new \Ease\Locale(Shared::cfg('LOCALIZE', 'cs_CZ'), '../i18n', 'abraflexi-pricefixer');
//new \Ease\Locale(Shared::cfg('LOCALIZE', 'cs_CZ'), '../i18n', 'abraflexi-pricefixer');

$completor = new \AbraFlexi\PriceFix\SadyAKomplety();
$complets = $completor->getColumnsFromAbraFlexi('*', ['limit' => 0]);
Expand All @@ -28,5 +26,5 @@
foreach ($bundles as $bundleCode => $bundle) {
$bundler->loadFromAbraFlexi($bundleCode);
$bundlePrice = $bundler->overallPrice();
$bundler->addStatusMessage('📦 ' . \AbraFlexi\Functions::uncode($bundleCode) . ' = 💰 ' . $bundlePrice, $bundler->saveBundlePrice($bundlePrice) ? 'success' : 'error');
$bundler->addStatusMessage('📦 ' . \AbraFlexi\Functions::uncode($bundleCode) . ' = 💰 ' . strval($bundlePrice).' 💶', $bundler->saveBundlePrice($bundlePrice) ? 'success' : 'error');
}
4 changes: 2 additions & 2 deletions src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
require_once '../vendor/autoload.php';

Shared::init(['ABRAFLEXI_URL', 'ABRAFLEXI_LOGIN', 'ABRAFLEXI_PASSWORD', 'ABRAFLEXI_COMPANY'], '../.env');
new \Ease\Locale(Shared::cfg('LOCALIZE', 'cs_CZ'), '../i18n', 'abraflexi-pricefixer');
//new \Ease\Locale(Shared::cfg('LOCALIZE', 'cs_CZ'), '../i18n', 'abraflexi-pricefixer');

$provider = new \AbraFlexi\Adresar();
if ($provider->recordExists(Shared::cfg('ABRAFLEXI_PROVIDER', 'code:PRICEFIXER'))) {
if ($provider->recordExists(strval(Shared::cfg('ABRAFLEXI_PROVIDER', 'code:PRICEFIXER')))) {
$provider->addStatusMessage('Provider Already Exists');
} else {
$provider->insertToAbraFlexi(['kod' => Shared::cfg('ABRAFLEXI_PROVIDER', 'PRICEFIXER'), 'nazev' => 'PriceFixer']);
Expand Down
2 changes: 1 addition & 1 deletion src/pricefix.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
require_once '../vendor/autoload.php';

Shared::init(['ABRAFLEXI_URL', 'ABRAFLEXI_LOGIN', 'ABRAFLEXI_PASSWORD', 'ABRAFLEXI_COMPANY'], '../.env');
new \Ease\Locale(Shared::cfg('LOCALIZE', 'cs_CZ'), '../i18n', 'abraflexi-pricefixer');
//new \Ease\Locale(Shared::cfg('LOCALIZE', 'cs_CZ'), '../i18n', 'abraflexi-pricefixer');

$completor = new Bundler($argv[1]);
$completor->saveBundlePrice($completor->overallPrice());

0 comments on commit 6463b6e

Please sign in to comment.