projects
/
fa-stable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merging latest changes from stable branch up to 2.3.24
[fa-stable.git]
/
gl
/
includes
/
db
/
gl_db_banking.inc
diff --git
a/gl/includes/db/gl_db_banking.inc
b/gl/includes/db/gl_db_banking.inc
index cd197af797bc576c3c5003e4b46e646485be1dd2..9d5b9693879dd70ecaf61f00b735f7a0a37a6b9b 100644
(file)
--- a/
gl/includes/db/gl_db_banking.inc
+++ b/
gl/includes/db/gl_db_banking.inc
@@
-92,7
+92,7
@@
function get_cust_account_curr_balances($date)
{
$to = date2sql($date);
{
$to = date2sql($date);
- $sql = "SELECT SUM(IF(t.type =".ST_CUSTCREDIT." OR t.type = ".ST_CUSTPAYMENT." OR t.type = ".ST_BANKDEPOSIT.",
+ $sql = "SELECT SUM(IF(t.type =".ST_CUSTCREDIT." OR t.type = ".ST_CUSTPAYMENT." OR t.type = ".ST_BANKDEPOSIT."
OR t.type = ".ST_JOURNAL."
,
-(t.ov_amount + t.ov_gst + t.ov_freight + t.ov_freight_tax + t.ov_discount),
(t.ov_amount + t.ov_gst + t.ov_freight + t.ov_freight_tax + t.ov_discount))) AS amount,
dt.debtor_no, dt.name, dt.curr_code, b.receivables_account
-(t.ov_amount + t.ov_gst + t.ov_freight + t.ov_freight_tax + t.ov_discount),
(t.ov_amount + t.ov_gst + t.ov_freight + t.ov_freight_tax + t.ov_discount))) AS amount,
dt.debtor_no, dt.name, dt.curr_code, b.receivables_account
@@
-416,7
+416,8
@@
function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $
$old_trans = $trans_no;
$Refs->restore_last($trans_type, $trans_no);
$aid = has_attachment($trans_type, $trans_no);
$old_trans = $trans_no;
$Refs->restore_last($trans_type, $trans_no);
$aid = has_attachment($trans_type, $trans_no);
- }
+ } else
+ $old_trans = false;
$currency = get_bank_account_currency($from_account);
$bank_gl_account = get_bank_gl_account($from_account);
$currency = get_bank_account_currency($from_account);
$bank_gl_account = get_bank_gl_account($from_account);
@@
-438,7
+439,8
@@
function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $
$trans_no = write_customer_trans($trans_type, 0, $person_id, $person_detail_id, $date_,
$ref, $cust_amount);
$trans_no = write_customer_trans($trans_type, 0, $person_id, $person_detail_id, $date_,
$ref, $cust_amount);
- move_trans_attachments($trans_type, $old_trans, $trans_no);
+ if ($old_trans)
+ move_trans_attachments($trans_type, $old_trans, $trans_no);
}
elseif ($person_type_id == PT_SUPPLIER)
{
}
elseif ($person_type_id == PT_SUPPLIER)
{
@@
-454,7
+456,8
@@
function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $
$trans_no = write_supp_trans($trans_type, 0, $person_id, $date_, '',
$ref, "", $supp_amount, 0, 0);
$trans_no = write_supp_trans($trans_type, 0, $person_id, $date_, '',
$ref, "", $supp_amount, 0, 0);
- move_trans_attachments($trans_type, $old_trans, $trans_no);
+ if ($old_trans)
+ move_trans_attachments($trans_type, $old_trans, $trans_no);
}
else
{
}
else
{
@@
-535,8
+538,16
@@
function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $
// old transaction can be voided only after new transaction is entered,
// otherwise the operation could fail for cash accounts due to temporary negative balance
// old transaction can be voided only after new transaction is entered,
// otherwise the operation could fail for cash accounts due to temporary negative balance
- if (@$old_trans)
- void_transaction($trans_type, $old_trans, Today(), _("Document reentered."));
+ if ($old_trans)
+ {
+ $msg = void_transaction($trans_type, $old_trans, Today(), _("Document reentered."));
+ if ($msg)
+ {
+ display_error($msg);
+ return false;
+ }
+ }
+
$args->trans_no = $trans_no;
hook_db_postwrite($args, $trans_type);
$args->trans_no = $trans_no;
hook_db_postwrite($args, $trans_type);