From 12b7acaedac7d5b75b1dbd179fffa238aa6e6038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danyi=20D=C3=A1vid?= Date: Tue, 5 Sep 2017 23:13:23 +0200 Subject: [PATCH] * matching fix * status added --- deploy.php | 3 ++- src/App/Command/KoinImportCommand.php | 5 +++-- src/App/Service/KoinService.php | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/deploy.php b/deploy.php index 4973549..e76d3fb 100644 --- a/deploy.php +++ b/deploy.php @@ -11,7 +11,8 @@ set('shared_dirs', [ // 'data/tmp', ]); set('shared_files', [ - 'config/autoload/doctrine.local.php', + 'config/autoload/local.php', + 'config/autoload/doctrine.local.php', ]); set('writable_dirs', []); diff --git a/src/App/Command/KoinImportCommand.php b/src/App/Command/KoinImportCommand.php index a6c41ff..e12c42a 100644 --- a/src/App/Command/KoinImportCommand.php +++ b/src/App/Command/KoinImportCommand.php @@ -47,8 +47,9 @@ class KoinImportCommand extends Command $smsId = $input->getArgument('id'); /** @var Sms $sms */ $sms = $this->em->getRepository(Sms::class)->find($smsId); - $this->koinService->onReceiveSms($sms); - $output->writeln("OK"); + $result = $this->koinService->onReceiveSms($sms); + + $output->writeln($result ? "OK" : "NOP"); } } diff --git a/src/App/Service/KoinService.php b/src/App/Service/KoinService.php index b064809..7b5243a 100644 --- a/src/App/Service/KoinService.php +++ b/src/App/Service/KoinService.php @@ -21,7 +21,7 @@ class KoinService * 4 - currency * 5 - pos info */ - const OTP_SMS_PATTERN = '/([0-9]{6}) ([0-9]{1,2}:[0-9]{1,2}) K[áà]rty[áà]s v[áà]s[áà]rl[áà]s/z[áà]rol[áà]s: -([0-9.]+) ([A-Z]{2,3}); (.*?); K[áà]rtyasz[áà]m: ...[0-9]{4}; Egyenleg: \+[0-9.]+ HUF - OTPdirekt/msi'; + const OTP_SMS_PATTERN = '#([0-9]{6}) ([0-9]{1,2}:[0-9]{1,2}) K[áà]rty[áà]s v[áà]s[áà]rl[áà]s/z[áà]rol[áà]s: -([0-9.]+) ([A-Z]{2,3}); (.*?); K[áà]rtyasz[áà]m: ...[0-9]{4}; Egyenleg: \+[0-9.]+ HUF - OTPdirekt#msi'; /** * @var array @@ -62,10 +62,11 @@ class KoinService /** * @param Sms $sms + * @return int */ public function onReceiveSms(Sms $sms) { - if (false !== preg_match(self::OTP_SMS_PATTERN, $sms->getText(), $otpMatches)) { + if (1 === ($matchStatus = preg_match(self::OTP_SMS_PATTERN, $sms->getText(), $otpMatches))) { $datePart = implode("-", sscanf($otpMatches[1], '%2c%2c%2c')); $this->saveTransaction( @@ -76,6 +77,7 @@ class KoinService $this->getExpenseTags($otpMatches[5]) ); } + return $matchStatus; } /**