return null;
return max(0, get_balance_before_for_bank_account($account, add_days($date,1))); // in case of manco made before the check was implemented
}
+
+function identify_bank_account($account_number)
+{
+ $number = db_escape($account_number);
+ $sql = "(SELECT id AS id, ".BO_COMPANY." AS type FROM ".TB_PREF."bank_accounts WHERE REPLACE(bank_account_number,' ', '')=$number)";
+ $sql .= " UNION (SELECT supplier_id AS id, ".BO_SUPPLIER." AS type FROM ".TB_PREF."suppliers WHERE REPLACE(bank_account,' ', '')=$number)";
+ $sql .= " UNION (SELECT branch_code AS id, ".BO_CUSTBRANCH." AS type FROM ".TB_PREF."cust_branch WHERE REPLACE(bank_account,' ', '')=$number)";
+
+ $result = db_query($sql, 'bank account identification failed');
+
+ if (db_num_rows($result))
+ return db_fetch($result);
+ else
+ return null;
+}
?>
\ No newline at end of file
//
global $systypes_array, $bank_account_types, $bank_transfer_types,
$payment_person_types, $wo_types_array, $wo_cost_types, $class_types,
- $quick_actions, $quick_entry_types, $stock_types, $tag_types;
+ $quick_actions, $quick_entry_types, $stock_types, $tag_types, $bank_owner;
$systypes_array = array (
ST_JOURNAL => _("Journal Entry"),
TCA_LINES => _("Sum per line taxes"),
TCA_TOTALS => _("Taxes from totals")
);
+//----------------------------------------------------------------------------------
+
+$bank_owner_types = array(
+ BO_UNKNOWN => _("Unknown"),
+ BO_COMPANY => _("Company"),
+ BO_CUSTBRANCH => _("Customer"),
+ BO_SUPPLIER => _("Supplier")
+);
?>
\ No newline at end of file
define('TCA_TOTALS', 1); // taxes are calculated from respective net totals for all lines
define('TCA_LINES', 2); // taxes calculated for every line, then summed
+//
+// Bank account owner types
+//
+define('BO_UNKNOWN', 0);
+define('BO_COMPANY', 1);
+define('BO_CUSTBRANCH', 2);
+define('BO_SUPPLIER', 3);
include_once($path_to_root . '/includes/sysnames.inc');
function add_branch($customer_id, $br_name, $br_ref, $br_address, $salesman, $area,
$tax_group_id, $sales_account, $sales_discount_account, $receivables_account,
$payment_discount_account, $default_location, $br_post_address, $disable_trans, $group_no,
- $default_ship_via, $notes)
+ $default_ship_via, $notes, $bank_account)
{
$sql = "INSERT INTO ".TB_PREF."cust_branch (debtor_no, br_name, branch_ref, br_address,
salesman, area, tax_group_id, sales_account, receivables_account, payment_discount_account,
sales_discount_account, default_location,
- br_post_address, disable_trans, group_no, default_ship_via, notes)
+ br_post_address, disable_trans, group_no, default_ship_via, notes, bank_account)
VALUES (".db_escape($customer_id). ",".db_escape($br_name) . ", "
.db_escape($br_ref) . ", "
.db_escape($br_address) . ", ".db_escape($salesman) . ", "
.db_escape($disable_trans) . ", "
.db_escape($group_no) . ", "
.db_escape($default_ship_via). ", "
- .db_escape($notes).")";
+ .db_escape($notes). ", "
+ .db_escape($bank_account, true).")";
db_query($sql,"The branch record could not be added");
}
function update_branch($customer_id, $branch_code, $br_name, $br_ref, $br_address,
$salesman, $area, $tax_group_id, $sales_account, $sales_discount_account, $receivables_account,
$payment_discount_account, $default_location, $br_post_address, $disable_trans, $group_no,
- $default_ship_via, $notes)
+ $default_ship_via, $notes, $bank_account)
{
$sql = "UPDATE ".TB_PREF."cust_branch SET br_name = " . db_escape($br_name) . ",
branch_ref = " . db_escape($br_ref) . ",
disable_trans=".db_escape($disable_trans) . ",
group_no=".db_escape($group_no) . ",
default_ship_via=".db_escape($default_ship_via) . ",
- notes=".db_escape($notes) . "
+ notes=".db_escape($notes) . ",
+ bank_account=".db_escape($bank_account, true)."
WHERE branch_code =".db_escape($branch_code) . "
AND debtor_no=".db_escape($customer_id);
db_query($sql,"The branch record could not be updated");
$_POST['br_address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], $_POST['sales_account'],
$_POST['sales_discount_account'], $_POST['receivables_account'], $_POST['payment_discount_account'],
$_POST['default_location'], $_POST['br_post_address'], $_POST['disable_trans'], $_POST['group_no'],
- $_POST['default_ship_via'], $_POST['notes']);
+ $_POST['default_ship_via'], $_POST['notes'], $_POST['bank_account']);
// update_record_status($_POST['supplier_id'], $_POST['inactive'],
// 'cust_branch', 'branch_code');
$_POST['br_address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], $_POST['sales_account'],
$_POST['sales_discount_account'], $_POST['receivables_account'], $_POST['payment_discount_account'],
$_POST['default_location'], $_POST['br_post_address'], 0, $_POST['group_no'],
- $_POST['default_ship_via'], $_POST['notes']);
+ $_POST['default_ship_via'], $_POST['notes'], $_POST['bank_account']);
$selected_id = db_insert_id();
add_crm_person($_POST['contact_name'], $_POST['contact_name'], '', $_POST['br_post_address'],
$_POST['payment_discount_account'] = $myrow['payment_discount_account'];
$_POST['group_no'] = $myrow["group_no"];
$_POST['notes'] = $myrow["notes"];
+ $_POST['bank_account'] = $myrow["bank_account"];
}
}
// We use the Item Sales Account as default!
// $_POST['sales_account'] = $company_record["default_sales_act"];
- $_POST['sales_account'] = $_POST['notes'] = '';
+ $_POST['sales_account'] = $_POST['notes'] = $_POST['bank_account'] = '';
$_POST['sales_discount_account'] = $company_record['default_sales_discount_act'];
$_POST['receivables_account'] = $company_record['debtors_act'];
$_POST['payment_discount_account'] = $company_record['default_prompt_payment_act'];
gl_all_accounts_list_row(_("Sales Discount Account:"), 'sales_discount_account');
gl_all_accounts_list_row(_("Accounts Receivable Account:"), 'receivables_account', null, true);
gl_all_accounts_list_row(_("Prompt Payment Discount Account:"), 'payment_discount_account');
+ text_row(_("Bank Account Number:"), 'bank_account', null, 30, 60);
table_section(2);
WHERE tgi.rate=(SELECT 0_tax_types.rate FROM 0_tax_types, 0_tax_groups
WHERE tax_shipping=1 AND tgi.tax_group_id=0_tax_groups.id AND tgi.tax_type_id=0_tax_types.id);
ALTER TABLE `0_tax_groups` DROP COLUMN `tax_shipping`;
+
+ALTER TABLE `0_cust_branch` ADD COLUMN `bank_account` varchar(60) DEFAULT NULL AFTER `notes`;
`br_post_address` tinytext NOT NULL,
`group_no` int(11) NOT NULL default '0',
`notes` tinytext NOT NULL,
+ `bank_account` varchar(60) DEFAULT NULL,
`inactive` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`branch_code`,`debtor_no`),
KEY `branch_code` (`branch_code`),
-- Dumping data for table `0_cust_branch`
--
-INSERT INTO `0_cust_branch` VALUES(1, 1, 'Beefeater Ltd.', 'Beefeater', '', 1, 1, 'Main Branch', 'DEF', 2, '', '4510', '1200', '4500', 1, 0, 'Address 1\nAddress 2\nAddress 3', 0, '', 0);
-INSERT INTO `0_cust_branch` VALUES(2, 2, 'Ghostbusters Corp.', 'Ghostbusters', 'Address 1\nAddress 2\nAddress 3', 1, 1, 'Main Branch', 'DEF', 1, '', '4510', '1200', '4500', 1, 0, 'Address 1\nAddress 2\nAddress 3', 0, '', 0);
-INSERT INTO `0_cust_branch` VALUES(3, 3, 'Brezan', 'Brezan', 'Address 1\nAddress 2\nAddress 3', 1, 1, 'Main Branch', 'DEF', 1, '', '4510', '1200', '4500', 1, 0, 'Address 1\nAddress 2\nAddress 3', 0, '', 0);
+INSERT INTO `0_cust_branch` VALUES(1, 1, 'Beefeater Ltd.', 'Beefeater', '', 1, 1, 'Main Branch', 'DEF', 2, '', '4510', '1200', '4500', 1, 0, 'Address 1\nAddress 2\nAddress 3', 0, '', '', 0);
+INSERT INTO `0_cust_branch` VALUES(2, 2, 'Ghostbusters Corp.', 'Ghostbusters', 'Address 1\nAddress 2\nAddress 3', 1, 1, 'Main Branch', 'DEF', 1, '', '4510', '1200', '4500', 1, 0, 'Address 1\nAddress 2\nAddress 3', 0, '','', 0);
+INSERT INTO `0_cust_branch` VALUES(3, 3, 'Brezan', 'Brezan', 'Address 1\nAddress 2\nAddress 3', 1, 1, 'Main Branch', 'DEF', 1, '', '4510', '1200', '4500', 1, 0, 'Address 1\nAddress 2\nAddress 3', 0, '', '', 0);
-- --------------------------------------------------------
`br_post_address` tinytext NOT NULL,
`group_no` int(11) NOT NULL default '0',
`notes` tinytext NOT NULL,
+ `bank_account` varchar(60) DEFAULT NULL,
`inactive` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`branch_code`,`debtor_no`),
KEY `branch_code` (`branch_code`),