{
$net_sum = 0;
foreach($cart->gl_items as $gl)
- if (!is_tax_account($gl->code_id) && !is_subledger_account($gl->code_id, $gl->person_id))
+ if (!is_tax_account($gl->code_id) && !is_subledger_account($gl->code_id))
$net_sum += $gl->amount;
$ex_net = abs($net_sum) - array_sum($tax_info['net_amount']);
$result = db_query($sql,"Couldn't test AR/AP account");
$myrow = db_fetch_row($result);
- return $myrow[0];
+ return $myrow == false ? 0 : $myrow[0];
}
function get_subaccount_data($code_id, $person_id)
return false;
$result = db_fetch_row($result);
- return $result[0];
+ return $result == false ? false : $result[0];
}
function is_new_reference($ref, $type, $trans_no=0)
$this->gl_items[$index]->code_id = $code_id;
$this->gl_items[$index]->person_id = $person_id;
- $gl_type = is_subledger_account($code_id, $person_id);
- if ($gl_type)
+ $gl_type = is_subledger_account($code_id);
+ if ($person_id != null && $gl_type)
{
$this->gl_items[$index]->person_type_id = $gl_type > 0 ? PT_CUSTOMER : PT_SUPPLIER;
$data = get_subaccount_data($code_id, $person_id);
foreach($this->gl_items as $gl)
{
- if ($person_type = is_subledger_account($gl->code_id, $gl->person_id))
+ if ($person_type = is_subledger_account($gl->code_id))
{
$tax_info['person_type'] = $person_type < 0 ? PT_SUPPLIER : PT_CUSTOMER;
$tax_info['person_id'] = $gl->person_id;
$this->code_id = $code_id;
$this->person_id = $person_id;
- $gl_type = is_subledger_account($code_id, $person_id);
- if ($gl_type)
+ $gl_type = is_subledger_account($code_id);
+ if ($person_id != null && $gl_type)
{
$this->person_type_id = $gl_type > 0 ? PT_CUSTOMER : PT_SUPPLIER;
$data = get_subaccount_data($code_id, $person_id);
$last_query=db_query($sql, "Could not retrieve last order detail");
$row = db_fetch_row($last_query);
- return $row[0];
+ return $row == false ? false : $row[0];
}
} else {
// read header data from first document
$myrow = get_customer_trans($trans_no[0],$doc_type);
+ $debtor_no = $myrow['debtor_no'];
if (count_array($trans_no)>1)
$cart->trans_no = get_customer_trans_version($doc_type, $trans_no);
else
$cart->set_sales_type($myrow["tpe"], $myrow["sales_type"], $myrow["tax_included"],0);
- $cart->set_customer($myrow["debtor_no"], $myrow["DebtorName"],
+ $cart->set_customer($debtor_no, $myrow["DebtorName"],
$myrow["curr_code"], $myrow["discount"], $myrow["payment_terms"]);
$cart->set_branch($myrow["branch_code"], $myrow["tax_group_id"],
@$myrow["src_id"]);
}
}
- $cart->prepayments = get_payments_for($trans_no, $doc_type, $myrow["debtor_no"]);
+ $cart->prepayments = get_payments_for($trans_no, $doc_type, $debtor_no);
} // !newdoc
if (($order->pos['cash_sale'] || $order->pos['credit_sale'])
&& !$order->is_started()) {
// editable payment type
- if (get_post('payment') !== $order->payment) {
+ if (isset($_POST['payment']) && $_POST['payment'] !== $order->payment) {
$order->payment = get_post('payment');
$order->payment_terms = get_payment_terms($order->payment);
$order->due_date = get_invoice_duedate($order->payment, $order->document_date);