From 83086e6733af3dbfd67edcac751dad7daf3a4fae Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sun, 18 Jul 2010 16:39:20 +0000 Subject: [PATCH] New customer/supplier currency can be changed as long as no transaction is entered. --- purchasing/includes/db/suppliers_db.inc | 6 ++++++ purchasing/manage/suppliers.php | 2 +- sales/includes/db/customers_db.inc | 6 ++++++ sales/manage/customers.php | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/purchasing/includes/db/suppliers_db.inc b/purchasing/includes/db/suppliers_db.inc index b0fae283..be6eb5b3 100644 --- a/purchasing/includes/db/suppliers_db.inc +++ b/purchasing/includes/db/suppliers_db.inc @@ -164,4 +164,10 @@ function get_current_supp_credit($supplier_id) } +function is_new_supplier($id) +{ + $tables = array('supp_trans', 'grn_batch', 'purch_orders', 'purch_data'); + + return !key_in_foreign_table($id, $tables, 'supplier_id'); +} ?> \ No newline at end of file diff --git a/purchasing/manage/suppliers.php b/purchasing/manage/suppliers.php index b2ad33c7..a7336240 100644 --- a/purchasing/manage/suppliers.php +++ b/purchasing/manage/suppliers.php @@ -85,7 +85,7 @@ function supplier_settings(&$supplier_id) text_row(_("GSTNo:"), 'gst_no', null, 42, 40); link_row(_("Website:"), 'website', null, 35, 55); - if ($supplier_id) + if ($supplier_id && !is_new_supplier($supplier_id)) { label_row(_("Supplier's Currency:"), $_POST['curr_code']); hidden('curr_code', $_POST['curr_code']); diff --git a/sales/includes/db/customers_db.inc b/sales/includes/db/customers_db.inc index a9a6301b..bd5b8d34 100644 --- a/sales/includes/db/customers_db.inc +++ b/sales/includes/db/customers_db.inc @@ -164,4 +164,10 @@ function get_current_cust_credit($customer_id) } +function is_new_customer($id) +{ + $tables = array('cust_branch', 'debtor_trans', 'recurrent_invoices', 'sales_orders'); + + return !key_in_foreign_table($id, $tables, 'debtor_no'); +} ?> \ No newline at end of file diff --git a/sales/manage/customers.php b/sales/manage/customers.php index ee197565..a20dffb4 100644 --- a/sales/manage/customers.php +++ b/sales/manage/customers.php @@ -205,7 +205,7 @@ function customer_settings($selected_id) text_row(_("GSTNo:"), 'tax_id', null, 40, 40); - if (!$selected_id) + if (!$selected_id || is_new_customer($selected_id)) { currencies_list_row(_("Customer's Currency:"), 'curr_code', $_POST['curr_code']); } -- 2.30.2