Revize 1241
Přidáno uživatelem Jiří Sviták před asi 13 roky(ů)
freenetis/branches/testing/application/libraries/importers/Raiffeisenbank/RB_Importer.php | ||
---|---|---|
|
||
}
|
||
|
||
class RB_Exception extends Exception {}
|
freenetis/branches/testing/application/libraries/importers/Fio/FioSaver.php | ||
---|---|---|
->where('account_attribute_id', Account_attribute_Model::$cash)
|
||
->find();
|
||
|
||
|
||
|
||
$ba = new Bank_account_Model($bank_account_id);
|
||
$account = $ba->get_related_account_by_attribute_id(Account_attribute_Model::$bank);
|
||
$bank_interests = $ba->get_related_account_by_attribute_id(Account_attribute_Model::$bank_interests);
|
||
|
||
// model preparation
|
||
$transfer = new Transfer_Model();
|
||
... | ... | |
$stats["invoices_nr"] = 0;
|
||
$stats["member_fees"] = 0;
|
||
$stats["member_fees_nr"] = 0;
|
||
$stats["interests"] = 0;
|
||
$stats["interests_nr"] = 0;
|
||
$stats["deposits"] = 0;
|
||
$stats["deposits_nr"] = 0;
|
||
|
||
// miscellaneous preparation
|
||
$now = date("Y-m-d H:i:s");
|
||
... | ... | |
$counter_ba->member_id, $user_id, null,
|
||
$datetime, $now, $item["zprava"], abs($item["castka"])
|
||
);
|
||
|
||
// bank transfer
|
||
$bt->clear();
|
||
$bt->set_logger(false);
|
||
... | ... | |
$bt->destination_id = $counter_ba->id;
|
||
$bt->transfer_id = $transfer_id;
|
||
$bt->bank_statement_id = $bank_statement_id;
|
||
$bt->transaction_code = $item["id_pohybu"];
|
||
$bt->number = $number;
|
||
$bt->constant_symbol = $item["ks"];
|
||
$bt->variable_symbol = $item["vs"];
|
||
$bt->specific_symbol = $item["ss"];
|
||
$bt->save();
|
||
|
||
// stats
|
||
$stats["invoices"] += abs($item["castka"]);
|
||
$stats["invoices_nr"]++;
|
||
... | ... | |
{
|
||
// inbound transfer
|
||
// ----------------
|
||
// by default we assume that it is member fee
|
||
// let's identify member
|
||
$member = $member_model->where('variable_symbol', $item["vs"])->find();
|
||
|
||
if (!$member->id)
|
||
|
||
// interest transfer
|
||
if ($item["typ"] == "Připsaný úrok")
|
||
{
|
||
$member_id = null;
|
||
$stats["unidentified_nr"]++;
|
||
// let's create interest transfer
|
||
$transfer_id = Transfer_Model::insert_transfer(
|
||
$bank_interests->id, $account->id, null, null,
|
||
$user_id, null, $datetime, $now, $item["typ"],
|
||
abs($item["castka"])
|
||
);
|
||
$bt->clear();
|
||
$bt->set_logger(false);
|
||
$bt->origin_id = null;
|
||
$bt->destination_id = $ba->id;
|
||
$bt->transfer_id = $transfer_id;
|
||
$bt->bank_statement_id = $bank_statement_id;
|
||
$bt->transaction_code = $item["id_pohybu"];
|
||
$bt->number = $number;
|
||
$bt->save();
|
||
$stats["interests"] += abs($item["castka"]);
|
||
$stats["interests_nr"]++;
|
||
}
|
||
else
|
||
elseif ($item["typ"] == "Vklad pokladnou")
|
||
{
|
||
$member_id = $member->id;
|
||
// let's create interest transfer
|
||
$transfer_id = Transfer_Model::insert_transfer(
|
||
$cash->id, $account->id, null, null,
|
||
$user_id, null, $datetime, $now, $item["typ"],
|
||
abs($item["castka"])
|
||
);
|
||
$bt->clear();
|
||
$bt->set_logger(false);
|
||
$bt->origin_id = null;
|
||
$bt->destination_id = $ba->id;
|
||
$bt->transfer_id = $transfer_id;
|
||
$bt->bank_statement_id = $bank_statement_id;
|
||
$bt->transaction_code = $item["id_pohybu"];
|
||
$bt->number = $number;
|
||
$bt->constant_symbol = $item["ks"];
|
||
$bt->variable_symbol = $item["vs"];
|
||
$bt->specific_symbol = $item["ss"];
|
||
$bt->save();
|
||
$stats["deposits"] += abs($item["castka"]);
|
||
$stats["deposits_nr"]++;
|
||
}
|
||
|
||
|
||
// double-entry incoming transfer
|
||
$transfer_id = Transfer_Model::insert_transfer(
|
||
$member_fees->id, $account->id, null, $member_id,
|
||
$user_id, null, $datetime, $now, $item["zprava"],
|
||
abs($item["castka"])
|
||
);
|
||
|
||
// incoming bank transfer
|
||
$bt->clear();
|
||
$bt->set_logger(false);
|
||
$bt->origin_id = $counter_ba->id;
|
||
$bt->destination_id = $ba->id;
|
||
$bt->transfer_id = $transfer_id;
|
||
$bt->bank_statement_id = $bank_statement_id;
|
||
$bt->number = $number;
|
||
$bt->constant_symbol = $item["ks"];
|
||
$bt->variable_symbol = $item["vs"];
|
||
$bt->specific_symbol = $item["ss"];
|
||
$bt->save();
|
||
|
||
// assign transfer? (0 - invalid id, 1 - assoc id, other are ordinary members)
|
||
if ($member_id > 1)
|
||
// otherwise we assume that it is member fee
|
||
else
|
||
{
|
||
$ca = ORM::factory("account")
|
||
->where('member_id', $member_id)
|
||
->find();
|
||
// let's identify member
|
||
$member = $member_model->where('variable_symbol', $item["vs"])->find();
|
||
if (!$member->id)
|
||
{
|
||
$member_id = null;
|
||
$stats["unidentified_nr"]++;
|
||
}
|
||
else
|
||
{
|
||
$member_id = $member->id;
|
||
}
|
||
|
||
// assigning transfer
|
||
$a_transfer_id = Transfer_Model::insert_transfer(
|
||
$account->id, $ca->id, $transfer_id, $member_id,
|
||
$user_id, null, $datetime, $now,
|
||
__("Assigning of transfer"), abs($item["castka"])
|
||
// double-entry incoming transfer
|
||
$transfer_id = Transfer_Model::insert_transfer(
|
||
$member_fees->id, $account->id, null, $member_id,
|
||
$user_id, null, $datetime, $now, $item["zprava"],
|
||
abs($item["castka"])
|
||
);
|
||
// incoming bank transfer
|
||
$bt->clear();
|
||
$bt->set_logger(false);
|
||
$bt->origin_id = $counter_ba->id;
|
||
$bt->destination_id = $ba->id;
|
||
$bt->transfer_id = $transfer_id;
|
||
$bt->bank_statement_id = $bank_statement_id;
|
||
$bt->transaction_code = $item["id_pohybu"];
|
||
$bt->number = $number;
|
||
$bt->constant_symbol = $item["ks"];
|
||
$bt->variable_symbol = $item["vs"];
|
||
$bt->specific_symbol = $item["ss"];
|
||
$bt->save();
|
||
|
||
// transaction fee
|
||
$fee = $fee_model->get_by_date_type(
|
||
$datetime, 'transfer fee'
|
||
);
|
||
if ($fee->fee > 0)
|
||
// assign transfer? (0 - invalid id, 1 - assoc id, other are ordinary members)
|
||
if ($member_id > 1)
|
||
{
|
||
$tf_transfer_id = Transfer_Model::insert_transfer(
|
||
$ca->id, $operating->id, $transfer_id,
|
||
$member_id, $user_id, null, $datetime,
|
||
$now, __("Transfer fee"), abs($item["castka"])
|
||
$ca = ORM::factory("account")
|
||
->where('member_id', $member_id)
|
||
->find();
|
||
|
||
// assigning transfer
|
||
$a_transfer_id = Transfer_Model::insert_transfer(
|
||
$account->id, $ca->id, $transfer_id, $member_id,
|
||
$user_id, null, $datetime, $now,
|
||
__("Assigning of transfer"), abs($item["castka"])
|
||
);
|
||
|
||
// transaction fee
|
||
$fee = $fee_model->get_by_date_type(
|
||
$datetime, 'transfer fee'
|
||
);
|
||
if ($fee->fee > 0)
|
||
{
|
||
$tf_transfer_id = Transfer_Model::insert_transfer(
|
||
$ca->id, $operating->id, $transfer_id,
|
||
$member_id, $user_id, null, $datetime,
|
||
$now, __("Transfer fee"), abs($item["castka"])
|
||
);
|
||
}
|
||
}
|
||
// member fee stats
|
||
$stats["member_fees"] += abs($item["castka"]);
|
||
$stats["member_fees_nr"]++;
|
||
}
|
||
|
||
// member fee stats
|
||
$stats["member_fees"] += abs($item["castka"]);
|
||
$stats["member_fees_nr"]++;
|
||
}
|
||
|
||
// line number increase
|
Také k dispozici: Unified diff
FioSaver - pridano rozliseni na cl. prispevky, uroky, vklady, ale zatim neotestovano. Pridana nova vyjimka pro hlaseni chyby pri importu Raiffeisenbank.