Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 849

Přidáno uživatelem Jiří Sviták před více než 13 roky(ů)

Pridany kontrolni cisla vysledku financnich operaci, optimalizace strahavaci funkce. Jina mensi vylepseni.

Zobrazit rozdíly:

freenetis/branches/account_transactions/application/i18n/cs_CZ/texts.php
'back to all subnets' => 'Zpět na seznam podsítí',
'back to bank account' => 'Zpět na bankovní účet',
'back to bank accounts' => 'Zpět na bankovní účty',
'back to bank statement' => 'Zpět na bankovní výpis',
'back to bank statements' => 'Zpět na bankovní výpisy',
'back to bank templates' => 'Zpět na bankovní šablony',
'back to day book' => 'Zpět na účetní deník',
......
'entrance date' => 'Datum vstupu',
'entrance_date' => 'Datum vstupu',
'entrance fee' => 'Vstupní příspěvek',
'entrance fee has been successfully deducted' => 'Vstupní příspěvek byl úspěšně stržen.',
'entrance fee have to be a number' => 'Vstupní příspěvk musí být číslo',
'entrance fees have been successfully deducted, %d new transfers created' => 'Vstupní příspěvky byly úspěšně strženy, vytvořeno %d nových převodů.',
'entrance fees have been successfully recalculated, %d transfers deleted, %d new transfers created' => 'Vstupní příspěvek byl úspěšně stržen, smazáno %d převodů, vytvořeno %d nových převodů.',
'enum type has been successfully added' => 'Výčet byl úspěšně přidán',
'enum type has been successfully deleted' => 'Výčet byl úspěšně smazán',
'enum type has been successfully updated' => 'Výčet byl úspěšně aktualizován',
......
'fee type' => 'Typ poplatku',
'fees' => 'Poplatky',
'fees have been successfully deducted, %d new transfers created' => 'Členské příspěvky byly úspěšně strženy, vytvořeno %d nových převodů.',
'fees have been successfully recounted' => 'Členské příspěvky byly úspěšně přepočítány.',
'fees have been successfully recalculated, %d deleted transfers, %d created new transfers' => 'Členské příspěvky byly úspěšně přepočítány, smazáno %d převodů, vytvořeno %d nových převodů.',
'fees have not been set!' => 'Členské příspěvky nebyly nastaveny!',
'fifth-degree certified engineers' => 'Certifikování technici pátého stupně',
'file' => 'Soubor',
freenetis/branches/account_transactions/application/models/bank_transfer.php
CONCAT(dba.account_nr, '/', dba.bank_nr) AS dba_number,
m2.id AS dba_member_id, m2.name AS dba_member_name,
t.id, t.origin_id, t.destination_id, t.datetime, t.creation_datetime, t.text, t.amount,
bt.id AS bt_id, bt.variable_symbol, bt.constant_symbol, bt.specific_symbol
bt.id AS bt_id, bt.variable_symbol, bt.constant_symbol, bt.specific_symbol, bt.bank_statement_id
FROM transfers t
JOIN bank_transfers bt ON t.id = bt.transfer_id
LEFT JOIN bank_accounts oba ON oba.id = bt.origin_id
freenetis/branches/account_transactions/application/models/account.php
public function get_accounts_to_deduct($date)
{
return $this->db->query("
SELECT a.id, m.entrance_date, m.leaving_date,
SELECT a.id, a.balance, m.entrance_date, m.leaving_date,
IF(mf.fee IS NOT NULL, 1, 0) fee_is_set,
mf.fee,
mf.readonly AS fee_readonly,
......
{
$transfers = ORM::factory('transfer')->where(array('type' => Transfer_Model::$deduct_member_fee,
'origin_id' => $account_id))->find_all();
$transfers_count = 0;
foreach ($transfers as $transfer)
{
$transfers_count++;
if (!$transfer->delete())
throw new ErrorException();
}
......
$operating = ORM::factory('account')->where(array('account_attribute_id' => Account_attribute_Model::$operating))->find();
if (!$this->recalculate_account_balance_of_account($operating->id))
throw new ErrorException();
return $transfers_count;
}
/**
......
{
$transfers = ORM::factory('transfer')->where(array('type' => Transfer_Model::$deduct_entrance_fee,
'origin_id' => $account_id))->find_all();
$transfers_count = 0;
foreach ($transfers as $transfer)
{
$transfers_count++;
if (!$transfer->delete())
throw new ErrorException();
}
......
$operating = ORM::factory('account')->where(array('account_attribute_id' => Account_attribute_Model::$infrastructure))->find();
if (!$this->recalculate_account_balance_of_account($operating->id))
throw new ErrorException();
return $transfers_count;
}
freenetis/branches/account_transactions/application/controllers/transfers.php
$form_data[$key] = htmlspecialchars($value);
// preparation
$created_transfers_count = 0;
$total_amount = 0;
$date = date('Y-m-d', mktime(0, 0, 0, $form_data['month'], 15, $arr_years[$form_data['year']]));
$creation_datetime = date('Y-m-d H:i:s');
$user_id = $this->session->get('user_id');
// finds default fee
$fee_model = new Fee_Model();
$fee = $fee_model->get_default_fee_by_date_type($date, 'regular member fee');
......
}
$operating = ORM::factory('account')->
where('account_attribute_id', Account_attribute_Model::$operating)->find();
$database = new Database();
$account_model = new Account_Model();
$accounts = $account_model->get_accounts_to_deduct($date);
try
{
$db = new Transfer_Model();
$db->transaction_start();
// first sql for inserting transfers
$sql_insert = "INSERT INTO transfers (origin_id, destination_id, previous_transfer_id, member_id, user_id, type, datetime, creation_datetime, text, amount) VALUES ";
$values = array();
// second sql for updating accounts
$sql_update = "UPDATE accounts SET balance = CASE id ";
$ids = array();
// main cycle
foreach ($accounts as $account)
{
// no deduct transfer for this date and account generated? then create one
......
{
$amount = $default_fee;
}
Transfer_Model::insert_transfer($account->id, $operating->id, null, null,
$this->session->get('user_id'), Transfer_Model::$deduct_member_fee, $date, $creation_datetime, $text, $amount);
$created_transfers_count++;
// is amount bigger than zero?
if ($amount > 0)
{
// insert
$values[] = "($account->id, $operating->id, NULL, NULL, $user_id, ".Transfer_Model::$deduct_member_fee.", '$date', '$creation_datetime', '$text', $amount)";
// update
$sql_update .= "WHEN $account->id THEN ".($account->balance - $amount)." ";
$ids[] = $account->id;
$total_amount += $amount;
$created_transfers_count++;
}
}
}
if ($created_transfers_count > 0)
{
// single query for inserting transfers
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new ErrorException();
// single query for updating credit account balances
$ids_with_commas = implode(",", $ids);
$sql_update .= "END WHERE id IN ($ids_with_commas)";
if (!$database->query($sql_update))
throw new ErrorException();
// update also balance of operating account
if (!$account_model->recalculate_account_balance_of_account($operating->id))
throw new ErrorException();
}
$db->transaction_commit();
$this->session->set_flash('message', url_lang::lang('texts.Fees have been successfully deducted, %d new transfers created.', $created_transfers_count));
}
......
$db = new Transfer_Model();
$db->transaction_start();
// deleting old deduct transfer of member
$account->delete_deduct_transfers_of_account($account_id);
$deleted_transfers_count = $account->delete_deduct_transfers_of_account($account_id);
$created_transfers_count = 0;
$max_date = date('Y-m-d', mktime(0, 0, 0, $max_month, 15, $max_year));
while (($date = date('Y-m-d', mktime(0, 0, 0, $month, 15, $year))) <= $max_date)
{
......
{
$amount = $default_fee;
}
Transfer_Model::insert_transfer($account->id, $operating->id, null, null,
$this->session->get('user_id'), Transfer_Model::$deduct_member_fee,
$date, $creation_datetime, $text, $amount);
if ($amount > 0)
{
$created_transfers_count++;
Transfer_Model::insert_transfer($account->id, $operating->id, null, null,
$this->session->get('user_id'), Transfer_Model::$deduct_member_fee,
$date, $creation_datetime, $text, $amount);
}
// iterate to next month
$month++;
if ($month == 13)
......
}
}
$db->transaction_commit();
$this->session->set_flash('message', url_lang::lang('texts.Fees have been successfully recounted.'));
$this->session->set_flash('message', url_lang::lang('texts.Fees have been successfully recalculated, %d deleted transfers, %d created new transfers.', array(0 => $deleted_transfers_count, 1=> $created_transfers_count)));
}
catch (ErrorException $e)
{
......
Controller::error(RECORD);
// first of all is necessary to delete previous entrance fee transfers
// user can change debt payment rate, this means that existing transfers are useless
$account_model->delete_entrance_deduct_transfers_of_account($account_id);
$deleted_transfers_count = $account_model->delete_entrance_deduct_transfers_of_account($account_id);
// preparation
$created_transfers_count = 0;
$creation_datetime = date('Y-m-d H:i:s');
$infrastructure = ORM::factory('account')->where('account_attribute_id', Account_attribute_Model::$infrastructure)->find();
$account_model = new Account_Model();
......
// decrease amount of debt due to size of one instalment
$debt -= $amount;
// create new transfer
Transfer_Model::insert_transfer($ca->id, $infrastructure->id, null, null,
$this->session->get('user_id'), Transfer_Model::$deduct_entrance_fee,
$date, $creation_datetime, url_lang::lang('texts.Entrance fee'), $amount);
if ($amount > 0)
{
$created_transfers_count++;
Transfer_Model::insert_transfer($ca->id, $infrastructure->id, null, null,
$this->session->get('user_id'), Transfer_Model::$deduct_entrance_fee,
$date, $creation_datetime, url_lang::lang('texts.Entrance fee'), $amount);
}
// iterate to next month
$emonth++;
if ($emonth == 13)
......
$date = date('Y-m-d', mktime(0, 0, 0, $emonth, 15, $eyear));
}
$db->transaction_commit();
$this->session->set_flash('message', url_lang::lang('texts.Entrance fees have been successfully deducted.'));
$this->session->set_flash('message', url_lang::lang('texts.Entrance fees have been successfully recalculated, %d transfers deleted, %d new transfers created.', array(1=>$deleted_transfers_count, 2=>$created_transfers_count)));
}
catch(ErrorException $e)
{
freenetis/branches/account_transactions/application/views/transfers_show.php
<?php
echo $message ? '<div class="message">'.$message.'</div>' : '';
if ($this->acl_check_view('Accounts_Controller', 'transfers')) {
echo html::anchor(url_lang::base().'transfers/show_all', url_lang::lang('texts.Back to day book')); ?>
$links = array();
$links[] = html::anchor(url_lang::base().'transfers/show_all', url_lang::lang('texts.Back to day book'));
if (isset($bt)) $links[] = html::anchor(url_lang::base().'bank_transfers/show_by_bank_statement/'.$bt->bank_statement_id, url_lang::lang('texts.Back to bank statement'));
echo implode(" | ", $links);
?>
<br />
<?php } ?>
<br />

Také k dispozici: Unified diff