$hitField=null;// the field on which we found a match.
foreach($this->allAccountsas$account){
// we have a match!
if((string)$account->$name===(string)$value){
if((string)$account->$field===(string)$value){
// never found a match before!
if(0===$count){
app('log')->debug(sprintf('Recognized "%s" as a "%s"-account by its "%s".',$value,$account->type,$name));
app('log')->debug(sprintf('Recognized "%s" as a "%s"-account by its "%s".',$value,$account->type,$field));
$result=$account->type;
$hitField=$name;
$hitField=$field;
$count++;
}
// we found a match before, and it's different too.
if(0!==$count&&$account->type!==$result){
app('log')->warning(sprintf('Recognized "%s" as a "%s"-account (on the "%s"-field) but ALSO as a "%s"-account (previous match was on the "%s"-field)!',$value,$result,$name,$account->type,$hitField));
app('log')->warning(sprintf('Recognized "%s" as a "%s"-account (on the "%s"-field) but ALSO as a "%s"-account (previous match was on the "%s"-field)!',$value,$result,$field,$account->type,$hitField));
// the previous result always trumps the current result because the order of accountIdentificationSuffixes
app('log')->debug(sprintf('System will keep the previous match and assume account with %s "%s" is a "%s" account',$name,$value,$result));
app('log')->debug(sprintf('System will keep the previous match and assume account with %s "%s" is a "%s" account',$field,$value,$result));
$count++;
}
// we found a match before and it's different. But the data importer has found both "revenue" AND "expense" accounts. What to do?
app('log')->warning(sprintf('Recognized "%s" as a "%s"-account (on the "%s"-field) but ALSO as a "%s"-account (previous match was on the "%s"-field)!',$value,$result,$name,$account->type,$hitField));
app('log')->warning(sprintf('Recognized "%s" as a "%s"-account (on the "%s"-field) but ALSO as a "%s"-account (previous match was on the "%s"-field)!',$value,$result,$field,$account->type,$hitField));
app('log')->debug('Because amount is less than zero, we assume "expense" is the correct type.');
$result='expense';
@ -211,7 +225,7 @@ class TransactionMapper
}
// we found a match before and it's different. But: previous result was "expense", current result is "revenue"
app('log')->warning(sprintf('Recognized "%s" as a "%s"-account (on the "%s"-field) but ALSO as a "%s"-account (previous match was on the "%s"-field)!',$value,$result,$name,$account->type,$hitField));
app('log')->warning(sprintf('Recognized "%s" as a "%s"-account (on the "%s"-field) but ALSO as a "%s"-account (previous match was on the "%s"-field)!',$value,$result,$field,$account->type,$hitField));
app('log')->debug('Because amount is more than zero, we assume "revenue" is the correct type.');
$result='revenue';
@ -220,7 +234,7 @@ class TransactionMapper
}
}
if(null===$result){
app('log')->debug(sprintf('Unable to recognize the account type of "%s" "%s", or skipped because unsure.',$name,$value));
app('log')->debug(sprintf('Unable to recognize the account type of "%s" "%s", or skipped because unsure.',$field,$value));