! -> Note
$ -> Affected files
+20-Sep-2008 Joe Hunt
+# Fix for exchange variation when allocating payments. re-inserted in System and GL Setup.
+$ /admin/gl_setup.php
+ /admin/db/company_db
+ /includes/banking.inc
+ /purchasing/allocations/supplier_allocate.php
+ /purchasing/includes/db/suppalloc_db.inc
+ /sales/allocations/customer_allocate.php
+ /sales/includes/db/custalloc_db.inc
+ /sales/includes/db/payment_db.inc
+ /sales/includes/db/sales_credit_db.inc
+! New tcpdf.php file. Minor bugfixes from tcpdf.org
+ /reporting/includes/tcpdf.php
+
+
18-Sep-2008 Janusz Dobrowolski
+ Support for calling external pages during document entry (e.g. for adding customer/supplier/items).
$ /index.php
<?php
-function update_company_gl_setup($debtors_act, $pyt_discount_act, $creditors_act,
+function update_company_gl_setup($debtors_act, $pyt_discount_act, $creditors_act,
$freight_act,
+ $exchange_diff_act,
$default_sales_act,
$default_sales_discount_act,
$default_prompt_payment_act,
debtors_act=".db_escape($debtors_act).", pyt_discount_act=".db_escape($pyt_discount_act).",
creditors_act=".db_escape($creditors_act).",
freight_act=".db_escape($freight_act).",
+ exchange_diff_act=".db_escape($exchange_diff_act).",
default_sales_act=".db_escape($default_sales_act).",
default_sales_discount_act=".db_escape($default_sales_discount_act).",
default_prompt_payment_act=".db_escape($default_prompt_payment_act).",
function get_base_sales_type()
{
$sql = "SELECT base_sales FROM ".TB_PREF."company WHERE coy_code=1";
-
+
$result = db_query($sql, "could not get base sales type");
$myrow = db_fetch($result);
return $myrow[0];
//-------------------------------------------------------------------------------------------------
-function can_process()
+function can_process()
{
- if (!check_num('po_over_receive', 0, 100))
+ if (!check_num('po_over_receive', 0, 100))
{
display_error(_("The delivery over-receive allowance must be between 0 and 100."));
set_focus('po_over_receive');
return false;
}
- if (!check_num('po_over_charge', 0, 100))
+ if (!check_num('po_over_charge', 0, 100))
{
display_error(_("The invoice over-charge allowance must be between 0 and 100."));
set_focus('po_over_charge');
return false;
}
- if (!check_num('past_due_days', 0, 100))
+ if (!check_num('past_due_days', 0, 100))
{
display_error(_("The past due days interval allowance must be between 0 and 100."));
set_focus('past_due_days');
//-------------------------------------------------------------------------------------------------
-if (isset($_POST['submit']) && can_process())
+if (isset($_POST['submit']) && can_process())
{
update_company_gl_setup($_POST['debtors_act'], $_POST['pyt_discount_act'],
$_POST['creditors_act'], $_POST['freight_act'],
+ $_POST['exchange_diff_act'],
$_POST['default_sales_act'],
$_POST['default_sales_discount_act'],
$_POST['default_prompt_payment_act'],
$_POST['freight_act'] = $myrow["freight_act"];
$_POST['pyt_discount_act'] = $myrow["pyt_discount_act"];
+$_POST['exchange_diff_act'] = $myrow["exchange_diff_act"];
$_POST['default_sales_act'] = $myrow["default_sales_act"];
$_POST['default_sales_discount_act'] = $myrow["default_sales_discount_act"];
$_POST['default_prompt_payment_act'] = $myrow["default_prompt_payment_act"];
//gl_all_accounts_list_row(_("Payroll Account:"), 'payroll_act', $_POST['payroll_act']);
text_row(_("Past Due Days Interval:"), 'past_due_days', $_POST['past_due_days'], 6, 6, '', "", _("days"));
+
+gl_all_accounts_list_row(_("Exchange Variances Account:"), 'exchange_diff_act', $_POST['exchange_diff_act']);
+
//---------------
table_section_title(_("Customers and Sales"));
text_row(_("Default Credit Limit:"), 'default_credit_limit', $_POST['default_credit_limit'], 12, 12);
-// Not used in FA2.0.
-//gl_all_accounts_list_row(_("Sales Exchange Variances Account:"), 'exchange_diff_act', $_POST['exchange_diff_act']);
-
gl_all_accounts_list_row(_("Shipping Charged Account:"), 'freight_act', $_POST['freight_act']);
//---------------
{
$sql= "SELECT account_code FROM ".TB_PREF."bank_accounts WHERE account_code='$account_code'";
$result = db_query($sql, "retreive bank account currency");
-
+
return (db_num_rows($result) > 0);
}
$sql= "SELECT curr_default FROM ".TB_PREF."company";
$result = db_query($sql, "retreive company currency");
- if (db_num_rows($result) == 0)
+ if (db_num_rows($result) == 0)
display_db_error("Could not find the requested currency. Fatal.", $sql);
-
+
$myrow = db_fetch_row($result);
return $myrow[0];
}
{
$sql= "SELECT bank_curr_code FROM ".TB_PREF."bank_accounts WHERE account_code='$bankAccount'";
$result = db_query($sql, "retreive bank account currency");
-
+
$myrow = db_fetch_row($result);
- return $myrow[0];
+ return $myrow[0];
}
//----------------------------------------------------------------------------------
function get_customer_currency($customer_id)
{
$sql = "SELECT curr_code FROM ".TB_PREF."debtors_master WHERE debtor_no = '$customer_id'";
-
+
$result = db_query($sql, "Retreive currency of customer $customer_id");
-
- $myrow=db_fetch_row($result);
- return $myrow[0];
+
+ $myrow=db_fetch_row($result);
+ return $myrow[0];
}
-//----------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------
function get_supplier_currency($supplier_id)
{
$sql = "SELECT curr_code FROM ".TB_PREF."suppliers WHERE supplier_id = '$supplier_id'";
-
+
$result = db_query($sql, "Retreive currency of supplier $supplier_id");
-
- $myrow=db_fetch_row($result);
- return $myrow[0];
+
+ $myrow=db_fetch_row($result);
+ return $myrow[0];
}
//----------------------------------------------------------------------------------
{
if ($currency_code == get_company_currency())
return 1.0000;
-
+
$date = date2sql($date_);
-
- $sql = "SELECT rate_buy, max(date_) as date_ FROM ".TB_PREF."exchange_rates WHERE curr_code = '$currency_code'
+
+ $sql = "SELECT rate_buy, max(date_) as date_ FROM ".TB_PREF."exchange_rates WHERE curr_code = '$currency_code'
AND date_ <= '$date' GROUP BY rate_buy ORDER BY date_ Desc LIMIT 1";
-
+
$result = db_query($sql, "could not query exchange rates");
-
- if (db_num_rows($result) == 0)
+
+ if (db_num_rows($result) == 0)
{
// no stored exchange rate, just return 1
display_error(_("Cannot get exchange rate for this currency. Please add exchange rate manually on Exchange Rates page.") );
return 1.000;
}
-
- $myrow = db_fetch_row($result);
- return $myrow[0];
+
+ $myrow = db_fetch_row($result);
+ return $myrow[0];
}
//----------------------------------------------------------------------------------
function get_exchange_rate_to_home_currency($currency_code, $date_)
{
- return 1 / get_exchange_rate_from_home_currency($currency_code, $date_);
+ return 1 / get_exchange_rate_from_home_currency($currency_code, $date_);
}
//----------------------------------------------------------------------------------
return round($amount / $ex_rate, user_price_dec());
}
-//----------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------
function get_exchange_rate_from_to($from_curr_code, $to_curr_code, $date_)
{
// echo "converting from $from_curr_code to $to_curr_code <BR>";
if ($from_curr_code == $to_curr_code)
return 1.0000;
-
+
$home_currency = get_company_currency();
- if ($to_curr_code == $home_currency)
+ if ($to_curr_code == $home_currency)
{
return get_exchange_rate_to_home_currency($from_curr_code, $date_);
- }
-
- if ($from_curr_code == $home_currency)
+ }
+
+ if ($from_curr_code == $home_currency)
{
- return get_exchange_rate_from_home_currency($to_curr_code, $date_);
- }
-
+ return get_exchange_rate_from_home_currency($to_curr_code, $date_);
+ }
+
// neither from or to are the home currency
return get_exchange_rate_to_home_currency($from_curr_code, $date_) / get_exchange_rate_to_home_currency($to_curr_code, $date_);
}
function exchange_from_to($amount, $from_curr_code, $to_curr_code, $date_)
{
$ex_rate = get_exchange_rate_from_to($from_curr_code, $to_curr_code, $date_);
- return $amount / $ex_rate;
+ return $amount / $ex_rate;
}
//--------------------------------------------------------------------------------
+// Exchange Variations Joe Hunt 2008-09-20 ////////////////////////////////////////
+
+function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $amount, $person_type, $neg=false)
+{
+ if ($person_type == payment_person_types::customer())
+ {
+ $trans = get_customer_trans($trans_no, $type);
+ $ar_ap_act = $trans['receivables_account'];
+ $person_id = $trans['debtor_no'];
+ $curr = $trans['curr_code'];
+ }
+ else
+ {
+ $trans = get_supp_trans($trans_no, $type);
+ $supp_accs = get_supplier_accounts($trans['supplier_id']);
+ $ar_ap_act = $supp_accs['payable_account'];
+ $person_id = $trans['supplier_id'];
+ $curr = $trans['SupplierCurrCode'];
+ }
+ if (is_company_currency($curr))
+ return;
+ $exc_var_act = get_company_pref('exchange_diff_act');
+ $inv_amt = to_home_currency($amount, $curr, sql2date($trans['tran_date']));
+ $pay_amt = to_home_currency($amount, $curr, $pyt_date);
+ if ($inv_amt != $pay_amt)
+ {
+ $diff = $inv_amt - $pay_amt;
+ if ($person_type == payment_person_types::supplier())
+ $diff = -$diff;
+ if ($neg)
+ $diff = -$diff;
+ $memo = systypes::name($type)." ".$trans_no;
+ add_gl_trans($pyt_type, $pyt_no, $pyt_date, $ar_ap_act, 0, 0, $memo, -$diff, null, $person_type, $person_id);
+ add_gl_trans($pyt_type, $pyt_no, $pyt_date, $exc_var_act, 0, 0, $memo, $diff, null, $person_type, $person_id);
+ }
+}
?>
\ No newline at end of file
begin_transaction();
// clear all the allocations for this payment/credit
- clear_supp_alloctions($_SESSION['alloc']->type, $_SESSION['alloc']->trans_no);
+ clear_supp_alloctions($_SESSION['alloc']->type, $_SESSION['alloc']->trans_no, $_SESSION['alloc']->date_);
// now add the new allocations
$total_allocated = 0;
update_supp_trans_allocation($alloc_item->type, $alloc_item->type_no,
$alloc_item->current_allocated);
+
+ // Exchange Variations Joe Hunt 2008-09-20 ////////////////////////////////////////
+
+ exchange_variation($_SESSION['alloc']->type, $_SESSION['alloc']->trans_no,
+ $alloc_item->type, $alloc_item->type_no, $_SESSION['alloc']->date_,
+ $alloc_item->current_allocated, payment_person_types::supplier());
+
+ ///////////////////////////////////////////////////////////////////////////
$total_allocated += $alloc_item->current_allocated;
}
//----------------------------------------------------------------------------------------
-function add_supp_allocation($amount, $trans_type_from, $trans_no_from,
+function add_supp_allocation($amount, $trans_type_from, $trans_no_from,
$trans_type_to, $trans_no_to, $date_)
{
$date = date2sql($date_);
$sql = "INSERT INTO ".TB_PREF."supp_allocations (
- amt, date_alloc,
- trans_type_from, trans_no_from, trans_no_to, trans_type_to)
+ amt, date_alloc,
+ trans_type_from, trans_no_from, trans_no_to, trans_type_to)
VALUES ($amount, '$date', $trans_type_from, $trans_no_from, $trans_no_to, $trans_type_to)";
-
+
db_query($sql, "A supplier allocation could not be added to the database");
}
function get_supp_trans_allocation_balance($trans_type, $trans_no)
{
- $sql = "SELECT (ov_amount+ov_gst-ov_discount-alloc) AS BalToAllocate
+ $sql = "SELECT (ov_amount+ov_gst-ov_discount-alloc) AS BalToAllocate
FROM ".TB_PREF."supp_trans WHERE trans_no=$trans_no AND type=$trans_type";
$result = db_query($sql,"calculate the allocation");
- $myrow = db_fetch_row($result);
-
+ $myrow = db_fetch_row($result);
+
return $myrow[0];
}
//-------------------------------------------------------------------------------------------------------------
-function void_supp_allocations($type, $type_no)
+function void_supp_allocations($type, $type_no, $date="")
{
- return clear_supp_alloctions($type, $type_no);
+ return clear_supp_alloctions($type, $type_no, $date);
}
//-------------------------------------------------------------------------------------------------------------
-function clear_supp_alloctions($type, $type_no)
+function clear_supp_alloctions($type, $type_no, $date="")
{
// clear any allocations for this transaction
- $sql = "SELECT * FROM ".TB_PREF."supp_allocations
- WHERE (trans_type_from=$type AND trans_no_from=$type_no)
+ $sql = "SELECT * FROM ".TB_PREF."supp_allocations
+ WHERE (trans_type_from=$type AND trans_no_from=$type_no)
OR (trans_type_to=$type AND trans_no_to=$type_no)";
$result = db_query($sql, "could not void supp transactions for type=$type and trans_no=$type_no");
-
+
while ($row = db_fetch($result))
{
$sql = "UPDATE ".TB_PREF."supp_trans SET alloc=alloc - " . $row['amt'] . "
- WHERE (type= " . $row['trans_type_from'] . " AND trans_no=" . $row['trans_no_from'] . ")
+ WHERE (type= " . $row['trans_type_from'] . " AND trans_no=" . $row['trans_no_from'] . ")
OR (type=" . $row['trans_type_to'] . " AND trans_no=" . $row['trans_no_to'] . ")";
//$sql = "UPDATE ".TB_PREF."supp_trans SET alloc=alloc - " . $row['amt'] . "
// WHERE type=" . $row['trans_type_to'] . " AND trans_no=" . $row['trans_no_to'];
- db_query($sql, "could not clear allocation");
+ db_query($sql, "could not clear allocation");
+ // 2008-09-20 Joe Hunt
+ if ($date != "")
+ exchange_variation($type, $type_no, $row['trans_type_to'], $row['trans_no_to'], $date,
+ $row['amt'], payment_person_types::supplier(), true);
+ //////////////////////
}
-
+
// remove any allocations for this transaction
- $sql = "DELETE FROM ".TB_PREF."supp_allocations
- WHERE (trans_type_from=$type AND trans_no_from=$type_no)
+ $sql = "DELETE FROM ".TB_PREF."supp_allocations
+ WHERE (trans_type_from=$type AND trans_no_from=$type_no)
OR (trans_type_to=$type AND trans_no_to=$type_no)";
-
- db_query($sql, "could not void supp transactions for type=$type and trans_no=$type_no");
+
+ db_query($sql, "could not void supp transactions for type=$type and trans_no=$type_no");
}
//-------------------------------------------------------------------------------------------------------------
function get_allocatable_from_supp_transactions($supplier_id, $settled)
{
$settled_sql = "";
- if (!$settled)
+ if (!$settled)
{
$settled_sql = "AND round(ABS(ov_amount+ov_gst+ov_discount)-alloc,6) > 0";
}
-
+
$supp_sql = "";
if ($supplier_id != null)
- $supp_sql = " AND ".TB_PREF."supp_trans.supplier_id = $supplier_id";
-
- return get_supplier_transactions("round(ABS(ov_amount+ov_gst+ov_discount)-alloc,6) <= 0 AS settled",
- "(type=22 OR type=21 OR type=1) AND (ov_amount < 0) " . $settled_sql . $supp_sql);
+ $supp_sql = " AND ".TB_PREF."supp_trans.supplier_id = $supplier_id";
+
+ return get_supplier_transactions("round(ABS(ov_amount+ov_gst+ov_discount)-alloc,6) <= 0 AS settled",
+ "(type=22 OR type=21 OR type=1) AND (ov_amount < 0) " . $settled_sql . $supp_sql);
}
//-------------------------------------------------------------------------------------------------------------
function get_allocatable_to_supp_transactions($supplier_id, $trans_no=null, $type=null)
-{
- if ($trans_no != null && $type!= null)
+{
+ if ($trans_no != null && $type!= null)
{
- return get_supplier_transactions("amt", "".TB_PREF."supp_trans.trans_no = ".TB_PREF."supp_allocations.trans_no_to
+ return get_supplier_transactions("amt", "".TB_PREF."supp_trans.trans_no = ".TB_PREF."supp_allocations.trans_no_to
AND ".TB_PREF."supp_trans.type = ".TB_PREF."supp_allocations.trans_type_to
AND ".TB_PREF."supp_allocations.trans_no_from=$trans_no
- AND ".TB_PREF."supp_allocations.trans_type_from=$type
- AND ".TB_PREF."supp_trans.supplier_id=$supplier_id",
- "".TB_PREF."supp_allocations");
- }
- else
+ AND ".TB_PREF."supp_allocations.trans_type_from=$type
+ AND ".TB_PREF."supp_trans.supplier_id=$supplier_id",
+ "".TB_PREF."supp_allocations");
+ }
+ else
{
return get_supplier_transactions(null, "round(ABS(ov_amount+ov_gst+ov_discount)-alloc,6) > 0
AND ".TB_PREF."supp_trans.type != 22
AND ".TB_PREF."supp_trans.supplier_id=$supplier_id");
- }
+ }
}
//============================================================+
// File name : tcpdf.php
// Begin : 2002-08-03
-// Last Update : 2008-09-17
+// Last Update : 2008-09-19
// Author : Nicola Asuni - info@tecnick.com - http://www.tcpdf.org
-// Version : 4.0.026_PHP4
+// Version : 4.0.027_PHP4
// License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
// ----------------------------------------------------------------------------
// Copyright (C) 2002-2008 Nicola Asuni - Tecnick.com S.r.l.
* @copyright 2004-2008 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
- * @version 4.0.026_PHP4
+ * @version 4.0.027_PHP4
*/
/**
/**
* define default PDF document producer
*/
- define('PDF_PRODUCER','TCPDF 4.0.026_PHP4 (http://www.tcpdf.org)');
+ define('PDF_PRODUCER','TCPDF 4.0.027_PHP4 (http://www.tcpdf.org)');
/**
* This is a PHP class for generating PDF documents without requiring external extensions.<br>
* TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
* @name TCPDF
* @package com.tecnick.tcpdf
- * @version 4.0.026_PHP4
+ * @version 4.0.027_PHP4
* @author Nicola Asuni - info@tecnick.com
* @link http://www.tcpdf.org
* @license http://www.gnu.org/copyleft/lesser.html LGPL
if (empty($this->javascript)) {
return;
}
+ // the following two lines are uded to avoid form fields duplication after saving
+ $js1 = sprintf("ftcpdfdocsaved=this.addField('%s','%s',%d,[%.2f,%.2f,%.2f,%.2f]);", 'tcpdfdocsaved', 'text', 0, 0, 1, 0, 1);
+ $js2 = "getField('tcpdfdocsaved').value = 'saved';";
$this->_newobj();
$this->n_js = $this->n;
$this->_out('<<');
$this->_newobj();
$this->_out('<<');
$this->_out('/S /JavaScript');
- $this->_out('/JS '.$this->_textstring($this->javascript));
+ $this->_out('/JS '.$this->_textstring($js1."\n".$this->javascript."\n".$js2));
$this->_out('>>');
$this->_out('endobj');
}
* @since 2.1.002 (2008-02-12)
*/
function _addfield($type, $name, $x, $y, $w, $h, $prop) {
+ // the followind avoid fields duplication after saving the document
+ $this->javascript .= "if(getField('tcpdfdocsaved').value != 'saved') {";
$k = $this->k;
$this->javascript .= sprintf("f".$name."=this.addField('%s','%s',%d,[%.2f,%.2f,%.2f,%.2f]);", $name, $type, $this->PageNo()-1, $x*$k, ($this->h-$y)*$k+1, ($x+$w)*$k, ($this->h-$y-$h)*$k+1)."\n";
$this->javascript .= "f".$name.".textSize=".$this->FontSizePt.";\n";
$this->javascript .= "f".$name.".".$key."=".$val.";\n";
}
$this->x += $w;
+ $this->javascript .= "}";
}
/*
$yshift = 0;
$startlinepage = $this->page;
$newline = true;
- if (isset($this->footerpos[$this->page])) {
+ if (isset($this->footerlen[$this->page])) {
$this->footerpos[$this->page] = strlen($this->pages[$this->page]) - $this->footerlen[$this->page];
- $startlinepos = $this->footerpos[$this->page];
} else {
- $startlinepos = strlen($this->pages[$this->page]);
+ $this->footerpos[$this->page] = strlen($this->pages[$this->page]);
}
+ $startlinepos = $this->footerpos[$this->page];
$lalign = $align;
$plalign = $align;
if ($this->rtl) {
// the last line must be shifted to be aligned as requested
$linew = abs($this->endlinex - $startlinex);
$pstart = substr($this->pages[$startlinepage], 0, $startlinepos);
- if (isset($opentagpos) AND isset($this->footerpos[$startlinepage])) {
+ if (isset($opentagpos) AND isset($this->footerlen[$startlinepage])) {
$this->footerpos[$startlinepage] = strlen($this->pages[$startlinepage]) - $this->footerlen[$startlinepage];
$midpos = min($opentagpos, $this->footerpos[$startlinepage]);
} elseif (isset($opentagpos)) {
$midpos = $opentagpos;
- } elseif (isset($this->footerpos[$startlinepage])) {
+ } elseif (isset($this->footerlen[$startlinepage])) {
$this->footerpos[$startlinepage] = strlen($this->pages[$startlinepage]) - $this->footerlen[$startlinepage];
$midpos = $this->footerpos[$startlinepage];
} else {
$startlinepos = $endlinepos;
unset($endlinepos);
} else {
- if (isset($this->footerpos[$this->page])) {
+ if (isset($this->footerlen[$this->page])) {
$this->footerpos[$this->page] = strlen($this->pages[$this->page]) - $this->footerlen[$this->page];
- $startlinepos = $this->footerpos[$this->page];
} else {
- $startlinepos = strlen($this->pages[$this->page]);
+ $this->footerpos[$this->page] = strlen($this->pages[$this->page]);
}
+ $startlinepos = $this->footerpos[$this->page];
}
$plalign = $lalign;
$this->newline = false;
}
// add rowspan information to table element
if ($rowspan > 1) {
- if (isset($this->footerpos[$this->page])) {
+ if (isset($this->footerlen[$this->page])) {
$this->footerpos[$this->page] = strlen($this->pages[$this->page]) - $this->footerlen[$this->page];
- $trintmrkpos = $this->footerpos[$this->page];
} else {
- $trintmrkpos = strlen($this->pages[$this->page]);
+ $this->footerpos[$this->page] = strlen($this->pages[$this->page]);
}
+ $trintmrkpos = $this->footerpos[$this->page];
$trsid = array_push($dom[$table_el]['rowspans'], array('rowspan' => $rowspan, 'colspan' => $colspan, 'startpage' => $this->page, 'startx' => $this->x, 'starty' => $this->y, 'intmrkpos' => $trintmrkpos));
}
$cellid = array_push($dom[$trid]['cellpos'], array('startx' => $this->x));
} else {
// opening tag (or self-closing tag)
if (!isset($opentagpos)) {
- if (isset($this->footerpos[$this->page])) {
+ if (isset($this->footerlen[$this->page])) {
$this->footerpos[$this->page] = strlen($this->pages[$this->page]) - $this->footerlen[$this->page];
- $opentagpos = $this->footerpos[$this->page];
} else {
- $opentagpos = strlen($this->pages[$this->page]);
+ $this->footerpos[$this->page] = strlen($this->pages[$this->page]);
}
+ $opentagpos = $this->footerpos[$this->page];
}
$this->openHTMLTagHandler($dom, $key, $cell);
}
// the last line must be shifted to be aligned as requested
$linew = abs($this->endlinex - $startlinex);
$pstart = substr($this->pages[$startlinepage], 0, $startlinepos);
- if (isset($opentagpos) AND isset($this->footerpos[$startlinepage])) {
+ if (isset($opentagpos) AND isset($this->footerlen[$startlinepage])) {
$this->footerpos[$startlinepage] = strlen($this->pages[$startlinepage]) - $this->footerlen[$startlinepage];
$midpos = min($opentagpos, $this->footerpos[$startlinepage]);
} elseif (isset($opentagpos)) {
$midpos = $opentagpos;
- } elseif (isset($this->footerpos[$startlinepage])) {
+ } elseif (isset($this->footerlen[$startlinepage])) {
$this->footerpos[$startlinepage] = strlen($this->pages[$startlinepage]) - $this->footerlen[$startlinepage];
$midpos = $this->footerpos[$startlinepage];
} else {
begin_transaction();
// clear all the allocations for this payment/credit
- clear_cust_alloctions($_SESSION['alloc']->type, $_SESSION['alloc']->trans_no);
+ clear_cust_alloctions($_SESSION['alloc']->type, $_SESSION['alloc']->trans_no, $_SESSION['alloc']->date_);
// now add the new allocations
$total_allocated = 0;
update_debtor_trans_allocation($allocn_item->type, $allocn_item->type_no,
$allocn_item->current_allocated);
- $total_allocated += $allocn_item->current_allocated;
+ // Exchange Variations Joe Hunt 2008-09-20 ////////////////////////////////////////
+
+ exchange_variation($_SESSION['alloc']->type, $_SESSION['alloc']->trans_no,
+ $allocn_item->type, $allocn_item->type_no, $_SESSION['alloc']->date_,
+ $allocn_item->current_allocated, payment_person_types::customer());
+
+ ///////////////////////////////////////////////////////////////////////////
+ $total_allocated += $allocn_item->current_allocated;
}
} /*end of the loop through the array of allocations made */
else
{
display_note(_("There are no unsettled transactions to allocate."), 0, 1);
-
+
submit_center('Cancel', _("Back to Allocations"), true,
_('Abandon allocations and return to selection of allocatable amounts'), true);
}
//-------------------------------------------------------------------------------------------------------------
-function void_cust_allocations($type, $type_no)
+function void_cust_allocations($type, $type_no, $date="")
{
- return clear_cust_alloctions($type, $type_no);
+ return clear_cust_alloctions($type, $type_no, $date);
}
//-------------------------------------------------------------------------------------------------------------
-function clear_cust_alloctions($type, $type_no)
+function clear_cust_alloctions($type, $type_no, $date="")
{
// clear any allocations for this transaction
$sql = "SELECT * FROM ".TB_PREF."cust_allocations
WHERE (type= " . $row['trans_type_from'] . " AND trans_no=" . $row['trans_no_from'] . ")
OR (type=" . $row['trans_type_to'] . " AND trans_no=" . $row['trans_no_to'] . ")";
db_query($sql, "could not clear allocation");
+ // 2008-09-20 Joe Hunt
+ if ($date != "")
+ exchange_variation($type, $type_no, $row['trans_type_to'], $row['trans_no_to'], $date,
+ $row['amt'], payment_person_types::customer(), true);
+ //////////////////////
}
$customer_id, $branch_id, $date_, $ref, $amount, $discount);
if ($trans_no != 0) {
- delete_comments(12, $invoice_no);
- void_bank_trans(12, $type_no, true);
+ delete_comments(12, $trans_no);
+ void_bank_trans(12, $trans_no, true);
void_gl_trans(12, $trans_no, true);
- void_cust_allocations(12, $trans_no);
+ void_cust_allocations(12, $trans_no, $date_);
}
/* Bank account entry first */
set_document_parent($credit_note);
} else {
delete_comments(11, $credit_no);
- void_cust_allocations(11, $credit_no);
+ void_cust_allocations(11, $credit_no, $credit_date);
void_gl_trans(11, $credit_no, true);
void_stock_move(11, $credit_no);
void_customer_trans_tax_details(11, $credit_no);