* matching fix

* status added
This commit is contained in:
Danyi Dávid 2017-09-05 23:13:23 +02:00
parent 8184c1e07d
commit 12b7acaeda
3 changed files with 9 additions and 5 deletions

View File

@ -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', []);

View File

@ -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");
}
}

View File

@ -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;
}
/**