* matching fix
* status added
This commit is contained in:
parent
8184c1e07d
commit
12b7acaeda
@ -11,6 +11,7 @@ set('shared_dirs', [
|
||||
// 'data/tmp',
|
||||
]);
|
||||
set('shared_files', [
|
||||
'config/autoload/local.php',
|
||||
'config/autoload/doctrine.local.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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user