Skip to content

Commit

Permalink
Update for current ease framework and debian buster + ENV based confi…
Browse files Browse the repository at this point in the history
…guration support
  • Loading branch information
Vitexus committed Apr 28, 2020
1 parent 9d289c8 commit be325cb
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 75 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
/debian/php-flexibee-matcher.debhelper.log
/debian/php-flexibee-matcher.postrm.debhelper
/debian/php-flexibee-matcher.substvars
/.vagrant/
/.vagrant/
/nbproject/private/
27 changes: 25 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM php:7.2.7-cli-stretch
MAINTAINER Vítězslav Dvořák <[email protected]>
FROM php:7.2.7-cli-buster
LABEL maintainer="Vítězslav Dvořák <[email protected]>"

RUN apt update && apt-get install -my wget gnupg

Expand All @@ -13,3 +13,26 @@ RUN echo "deb [trusted=yes] file:///repo/ ./" > /etc/apt/sources.list.d/local.li

RUN apt update ; RUN DEBIAN_FRONTEND=noninteractive apt-get -y install flexibee-matcher



FROM debian:latest
LABEL maintainer="[email protected]"
ENV TERM xterm
ENV DEBIAN_FRONTEND noninteractive

RUN apt update ; apt -y install lsb-release wget dialog apt-utils cron msmtp
RUN echo "deb http://repo.vitexsoftware.cz $(lsb_release -sc) main paid" | tee /etc/apt/sources.list.d/vitexsoftware.list
RUN wget -O /etc/apt/trusted.gpg.d/vitexsoftware.gpg http://repo.vitexsoftware.cz/keyring.gpg

COPY flexibee-dev.spoje.conf /etc/flexibee/client.conf

RUN apt update ; apt -y install flexibee-reminder-sms

COPY msmtprc /etc/msmtprc
COPY mail.ini /etc/php/7.3/mods-available
RUN phpenmod mail

#EXPOSE 80

CMD ["cron", "-f"]

4 changes: 2 additions & 2 deletions bin/flexibee-matcher
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
php -f /usr/lib/php-flexibee-matcher/ParujPrijateFaktury.php
php -f /usr/lib/php-flexibee-matcher/ParujVydaneFaktury.php
php -f /usr/lib/flexibee-matcher/ParujPrijateFaktury.php
php -f /usr/lib/flexibee-matcher/ParujVydaneFaktury.php
2 changes: 1 addition & 1 deletion bin/flexibee-matcher-in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
php -f /usr/lib/php-flexibee-matcher/ParujPrijateFaktury.php
php -f /usr/lib/flexibee-matcher/ParujPrijateFaktury.php
2 changes: 1 addition & 1 deletion bin/flexibee-matcher-new2old
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
php -f /usr/lib/php-flexibee-matcher/ParujFakturyNew2Old.php
php -f /usr/lib/flexibee-matcher/ParujFakturyNew2Old.php

2 changes: 1 addition & 1 deletion bin/flexibee-matcher-out
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
php -f /usr/lib/php-flexibee-matcher/ParujVydaneFaktury.php
php -f /usr/lib/flexibee-matcher/ParujVydaneFaktury.php

2 changes: 1 addition & 1 deletion bin/flexibee-pull-bank
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
php -f /usr/lib/php-flexibee-matcher/StahniBanku.php
php -f /usr/lib/flexibee-matcher/StahniBanku.php
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"FlexiPeeHP\\Matcher\\": "src/FlexiPeeHP/Matcher/"
"FlexiPeeHP\\Matcher\\": "src/FlexiPeeHP/Matcher/",
"FlexiPeeHP\\Matcher\\Ui\\": "src/FlexiPeeHP/Matcher/Ui/"
}
}
}
8 changes: 3 additions & 5 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
flexibee-matcher (0.7.10) UNRELEASED; urgency=medium
flexibee-matcher (0.8) UNRELEASED; urgency=medium

[ vitex ]
* Rename Composer Package in Debian to be Composer 2.0 valid
* Configuration is get from Enviroment if /etc/flexibee/cliet.json does not exist.

[ Vítězslav Dvořák ]
*

-- vitex <[email protected]> Wed, 13 Mar 2019 11:25:46 +0100
-- CyberVitexus <[email protected]> Wed, 29 Apr 2020 00:10:31 +0200

flexibee-matcher (0.7.6) experimental; urgency=medium

Expand Down
31 changes: 18 additions & 13 deletions debian/conf/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,32 @@
"require": {
"deb/flexibee-bricks": "*"
},
"autoload": {
"psr-4": {
"FlexiPeeHP\\Matcher\\": "FlexiPeeHP/Matcher/",
"FlexiPeeHP\\Matcher\\Ui\\": "FlexiPeeHP/Matcher/Ui/"
}
},
"repositories": [
{
"type": "path",
"url": "/usr/share/php/Ease",
"options": {
"symlink": true
}
"url": "/usr/share/php/Ease"
},
{
"type": "path",
"url": "/usr/share/php/EaseHtml"
},
{
"type": "path",
"url": "/usr/share/php/FlexiPeeHP"
},
{
"type": "path",
"url": "/usr/share/php/FlexiPeeHP",
"options": {
"symlink": true
}
"url": "/usr/share/php/EaseBricks"
},
{
"type": "path",
"url": "/usr/share/php/FlexiPeeHPBricks",
"options": {
"symlink": true
}
"url": "/usr/share/php/FlexiPeeHPBricks"
}
]
}
}
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Priority: optional
Homepage: https://github.com/VitexSoftware/php-flexibee-matcher

Package: flexibee-matcher
Depends: ${misc:Depends}, php-flexibee-config, php-flexibee-bricks, php-cli
Suggests: flexibee-server
Depends: ${misc:Depends}, php-flexibee-bricks, php-cli
Suggests: flexibee-server, php-flexibee-config
Architecture: all
Section: web
Priority: optional
Expand Down
4 changes: 3 additions & 1 deletion debian/postinst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
# postinst script for flexibee-matcher
WEBUSER="root"

set -e

if [ "$1" = "configure" ]; then
Expand All @@ -9,6 +9,8 @@ set -e

fi

db_get composer/WEB_USER
WEBUSER=$RET

mkdir -p /var/lib/composer
chown $WEBUSER:$WEBUSER /var/lib/composer
Expand Down
2 changes: 0 additions & 2 deletions debian/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ set -e

. /usr/share/debconf/confmodule

php-flexibee-checker

fi


Expand Down
4 changes: 2 additions & 2 deletions debian/prerm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# rm script for php-flexibee-reminder
# rm script for flexibee-reminder

rm -f /usr/share/php-flexibee-reminder/composer.lock
rm -f /usr/share/flexibee-reminder/composer.lock

#DEBHELPER#

Expand Down
2 changes: 1 addition & 1 deletion nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>php-flexibee-matcher</name>
<name>flexibee-matcher</name>
</data>
</configuration>
</project>
36 changes: 19 additions & 17 deletions src/Init.php
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
<?php

/**
* php-flexibee-matecher
*
* @copyright (c) 2018, Vítězslav Dvořák
* @copyright (c) 2018-2020, Vítězslav Dvořák
*/
$autoloader = require_once '../vendor/autoload.php';
$shared = new Ease\Shared();
$shared->loadConfig('../client.json',true);
$shared->loadConfig('../matcher.json',true);
$shared = new Ease\Shared();
if (file_exists('../client.json')) {
$shared->loadConfig('../client.json', true);
}
$shared->loadConfig('../matcher.json', true);

$labeler = new FlexiPeeHP\Stitek();
$labeler->logBanner('EasePHP Bricks v? '.constant('EASE_APPNAME'));
$labeler->logBanner('EasePHP Bricks v? ' . constant('EASE_APPNAME'));
$labeler->addStatusMessage(_('checking labels'), 'debug');

$updateCfg = false;
foreach (['PREPLATEK', 'CHYBIFAKTURA', 'NEIDENTIFIKOVANO'] as $label) {
if (is_null($shared->getConfigValue('LABEL_'.$label))) {
$shared->setConfigValue('LABEL_'.$label, $label);
if (is_null($shared->getConfigValue('LABEL_' . $label))) {
$shared->setConfigValue('LABEL_' . $label, $label);
$labeler->addStatusMessage(sprintf(_('Cannot find LABEL_%s in config file matcher.json. Using default value: %s'),
$label, $label), 'warning');
$label, $label), 'warning');
$updateCfg = true;
}
if ($labeler->recordExists(['kod' => $shared->getConfigValue('LABEL_'.$label)])
=== false) {
$labeler->createNew($shared->getConfigValue('LABEL_'.$label), ['banka']);
if ($labeler->recordExists(['kod' => $shared->getConfigValue('LABEL_' . $label)]) === false) {
$labeler->createNew($shared->getConfigValue('LABEL_' . $label), ['banka']);
$labeler->addStatusMessage(sprintf(_('LABEL_%s: %s was created in FlexiBee'),
$label, $shared->getConfigValue('LABEL_'.$label)), 'success');
$label, $shared->getConfigValue('LABEL_' . $label)), 'success');
} else {
$labeler->addStatusMessage(sprintf(_('LABEL_%s: %s exists in FlexiBee'),
$label, $shared->getConfigValue('LABEL_'.$label)));
$label, $shared->getConfigValue('LABEL_' . $label)));
}
}

if ($updateCfg === true) {
foreach ([
"EASE_APPNAME", "EASE_MAILTO", "EASE_LOGGER", "LOCALIZE", "PULL_BANK",
"DAYS_BACK", "LABEL_PREPLATEK", "LABEL_CHYBIFAKTURA", "LABEL_NEIDENTIFIKOVANO"] as $cfg) {
"EASE_APPNAME", "EASE_MAILTO", "EASE_LOGGER", "LOCALIZE", "PULL_BANK",
"DAYS_BACK", "LABEL_PREPLATEK", "LABEL_CHYBIFAKTURA", "LABEL_NEIDENTIFIKOVANO"] as $cfg) {
$cfg2save[$cfg] = $shared->getConfigValue($cfg);
}
if (file_put_contents('../matcher.json',
json_encode($cfg2save, JSON_PRETTY_PRINT))) {
json_encode($cfg2save, JSON_PRETTY_PRINT))) {
$labeler->addStatusMessage(_('../matcher.json was updated'), 'success');
} else {
$labeler->addStatusMessage(_('../matcher.json was not updated', 'error'),
'success');
'success');
}
}
$labeler->addStatusMessage(_('labels check done'), 'debug');
15 changes: 9 additions & 6 deletions src/ParujFakturyNew2Old.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
<?php

/**
* Párování fakrur
* Invoice Matching
*
* @author Vítězslav Dvořák <[email protected]>
* @copyright (c) 2018, Vítězslav Dvořák
* @copyright (c) 2018-2020, Vítězslav Dvořák
*/
define('EASE_APPNAME', 'ParujFakturyNewToOld');

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

$shared = new Ease\Shared();
$shared->loadConfig('../client.json', true);
if (file_exists('../client.json')) {
$shared->loadConfig('../client.json', true);
}
$shared->loadConfig('../matcher.json', true);
//new \Ease\Locale($shared->getConfigValue('LOCALIZE'), '../i18n',
// 'flexibee-matcher');

$odden = 0;
$date1 = new \DateTime();
$date2 = new \DateTime();
$date2->modify('-'.$shared->getConfigValue('DAYS_BACK').' days');
$date2->modify('-' . $shared->getConfigValue('DAYS_BACK') . ' days');

$doden = $date2->diff($date1)->format("%a");

$invoiceSteamer = new FlexiPeeHP\Matcher\OutcomingInvoice($shared->configuration);
$invoiceSteamer->banker->logBanner(constant('EASE_APPNAME') );
$invoiceSteamer->banker->logBanner(constant('EASE_APPNAME'));

if ($shared->getConfigValue('PULL_BANK') === true) {
$invoiceSteamer->addStatusMessage(_('pull account statements'));
Expand All @@ -32,7 +35,7 @@
}
}

$invoiceSteamer->addStatusMessage(_('Matching program started'),'debug');
$invoiceSteamer->addStatusMessage(_('Matching program started'), 'debug');
while ($odden < $doden) {
$invoiceSteamer->setStartDay($odden++);
$invoiceSteamer->outInvoicesMatchingByBank();
Expand Down
21 changes: 12 additions & 9 deletions src/ParujPrijateFaktury.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?php

/**
* php-flexibee-matcher
*
* @copyright (c) 2018, Vítězslav Dvořák
* @copyright (c) 2018-2020, Vítězslav Dvořák
*/
define('EASE_APPNAME', 'ParujPrijateFaktury');
require_once '../vendor/autoload.php';
$shared = new Ease\Shared();
$shared->loadConfig('../client.json', true);
if (file_exists('../client.json')) {
$shared->loadConfig('../client.json', true);
}
$shared->loadConfig('../matcher.json', true);

//new \Ease\Locale($shared->getConfigValue('LOCALIZE'), '../i18n','flexibee-matcher');
Expand All @@ -16,19 +19,19 @@
$invoiceSteamer->banker->logBanner(constant('EASE_APPNAME'));

if ($shared->getConfigValue('PULL_BANK') === true) {
$invoiceSteamer->addStatusMessage(_('pull account statements'),'debug');
$invoiceSteamer->addStatusMessage(_('pull account statements'), 'debug');
if (!$invoiceSteamer->banker->stahnoutVypisyOnline()) {
$invoiceSteamer->addStatusMessage('Banka Offline!', 'error');
}
}

$begin = new \DateTime();
$daterange = new \DatePeriod($begin->modify('-'.$shared->getConfigValue('DAYS_BACK').' days'),
new DateInterval('P1D'), new \DateTime());
$begin = new \DateTime();
$daterange = new \DatePeriod($begin->modify('-' . $shared->getConfigValue('DAYS_BACK') . ' days'),
new DateInterval('P1D'), new \DateTime());

$invoiceSteamer->addStatusMessage(_('Incoming Invoice matching begin'),'debug');
if(!empty($shared->getConfigValue('DAYS_BACK'))){
$invoiceSteamer->addStatusMessage(_('Incoming Invoice matching begin'), 'debug');
if (!empty($shared->getConfigValue('DAYS_BACK'))) {
$invoiceSteamer->setStartDay($shared->getConfigValue('DAYS_BACK'));
}
$invoiceSteamer->inInvoicesMatchingByBank($daterange);
$invoiceSteamer->addStatusMessage(_('Incoming Invoice matching done'),'debug');
$invoiceSteamer->addStatusMessage(_('Incoming Invoice matching done'), 'debug');
9 changes: 5 additions & 4 deletions src/ParujVydaneFaktury.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

/**
* php-flexibee-matcher
*
* @copyright (c) 2018, Vítězslav Dvořák
* @copyright (c) 2018-2020, Vítězslav Dvořák
*/
define('EASE_APPNAME', 'ParujVydaneFaktury');
require_once '../vendor/autoload.php';
Expand All @@ -16,12 +17,12 @@
$invoiceSteamer->banker->logBanner(constant('EASE_APPNAME'));

if ($shared->getConfigValue('PULL_BANK') === true) {
$invoiceSteamer->addStatusMessage(_('pull account statements'),'debug');
$invoiceSteamer->addStatusMessage(_('pull account statements'), 'debug');
if (!$invoiceSteamer->banker->stahnoutVypisyOnline()) {
$invoiceSteamer->addStatusMessage('Banka Offline!', 'error');
}
}

$invoiceSteamer->addStatusMessage(_('Outgoing Invoice matching begin'),'debug');
$invoiceSteamer->addStatusMessage(_('Outgoing Invoice matching begin'), 'debug');
$invoiceSteamer->outInvoicesMatchingByBank();
$invoiceSteamer->addStatusMessage(_('Outgoing Invoice matching done'),'debug');
$invoiceSteamer->addStatusMessage(_('Outgoing Invoice matching done'), 'debug');
Loading

0 comments on commit be325cb

Please sign in to comment.