Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion admin/company_preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
'no_supplier_list' =>0, 'base_sales', 'ref_no_auto_increase' => 0,
'time_zone' => 0, 'company_logo_report' => 0, 'barcodes_on_stock' => 0, 'print_dialog_direct' => 0,
'add_pct', 'round_to', 'login_tout', 'auto_curr_reval', 'bcc_email', 'alternative_tax_include_on_docs',
'suppress_tax_rates', 'use_manufacturing', 'use_fixed_assets'))
'suppress_tax_rates', 'tax_bank_payments', 'use_manufacturing', 'use_fixed_assets'))
);

$_SESSION['wa_current_user']->timeout = $_POST['login_tout'];
Expand Down Expand Up @@ -214,6 +214,7 @@
$_POST['bcc_email'] = $myrow["bcc_email"];
$_POST['alternative_tax_include_on_docs'] = $myrow["alternative_tax_include_on_docs"];
$_POST['suppress_tax_rates'] = $myrow["suppress_tax_rates"];
$_POST['tax_bank_payments'] = $myrow["tax_bank_payments"];
$_POST['use_manufacturing'] = $myrow["use_manufacturing"];
$_POST['use_fixed_assets'] = $myrow["use_fixed_assets"];

Expand Down Expand Up @@ -255,6 +256,7 @@
text_row_ex(_("Tax Last Period:"), 'tax_last', 10, 10, '', null, null, _('Months back.'));
check_row(_("Put alternative Tax Include on Docs"), 'alternative_tax_include_on_docs', null);
check_row(_("Suppress Tax Rates on Docs"), 'suppress_tax_rates', null);
check_row(_("Tax Bank Payments and Deposits"), 'tax_bank_payments', null);

table_section_title(_("Sales Pricing"));
sales_types_list_row(_("Base for auto price calculations:"), 'base_sales', $_POST['base_sales'], false,
Expand Down
19 changes: 11 additions & 8 deletions gl/includes/db/gl_db_trans.inc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ function get_gl_transactions($from_date, $to_date, $trans_no=0,
$sql .= " AND person_id=".db_escape($person_id);

$sql .= " ORDER BY tran_date, counter";
//display_notification($sql);

return db_query($sql, "The transactions for could not be retrieved");
}
Expand Down Expand Up @@ -523,30 +524,32 @@ function get_tax_summary($from, $to, $also_zero_purchases=false)
$sql = "SELECT
SUM(IF(trans_type=".ST_CUSTCREDIT.",-1,1)*
IF((reg_type=".TR_OUTPUT.")"
." || ((trans_type IN(".ST_SALESINVOICE.",".ST_CUSTCREDIT.") OR (trans_type=".ST_JOURNAL." AND reg_type=".TR_INPUT."))
." || ((trans_type IN(".ST_SALESINVOICE.",".ST_CUSTCREDIT.",".ST_BANKDEPOSIT."))
), net_amount*ex_rate,0)
) net_output,

SUM(IF(trans_type=".ST_CUSTCREDIT.",-1,1)*
IF((reg_type=".TR_OUTPUT.")"
." || ((trans_type IN(".ST_SALESINVOICE.",".ST_CUSTCREDIT.") OR (trans_type=".ST_JOURNAL." AND reg_type=".TR_INPUT."))
." || ((trans_type IN(".ST_SALESINVOICE.",".ST_CUSTCREDIT.",".ST_BANKDEPOSIT."))
), amount*ex_rate,0)) payable,

SUM(IF(trans_type IN(".ST_SUPPCREDIT."),-1,1)*
IF(reg_type=".TR_INPUT
SUM(IF(trans_type IN(".ST_SUPPCREDIT.",".ST_BANKPAYMENT."),-1,1)*
IF((reg_type=".TR_INPUT." OR trans_type IN (".ST_SUPPINVOICE.",".ST_BANKPAYMENT."))"
. ($also_zero_purchases ? '': " AND tax_type_id AND taxrec.rate")
.", net_amount*ex_rate, 0)) net_input,

SUM(IF(trans_type IN(".ST_SUPPCREDIT."),-1,1)*
IF(reg_type=".TR_INPUT
SUM(IF(trans_type IN(".ST_SUPPCREDIT.",".ST_BANKPAYMENT."),-1,1)*
IF((reg_type=".TR_INPUT." OR trans_type IN (".ST_SUPPINVOICE.",".ST_BANKPAYMENT."))"
. ($also_zero_purchases ? '': " AND tax_type_id AND taxrec.rate ")
.", amount*ex_rate, 0)) collectible,
taxrec.rate,
ttype.id,
ttype.name
FROM ".TB_PREF."trans_tax_details taxrec LEFT JOIN ".TB_PREF."tax_types ttype ON taxrec.tax_type_id=ttype.id
WHERE taxrec.trans_type IN (".implode(',',
array(ST_SALESINVOICE, ST_CUSTCREDIT, ST_SUPPINVOICE, ST_SUPPCREDIT, ST_JOURNAL)).")
WHERE taxrec.trans_type IN (". implode(',',
get_company_pref("tax_bank_payments") ?
array(ST_SALESINVOICE, ST_CUSTCREDIT, ST_SUPPINVOICE, ST_SUPPCREDIT, ST_JOURNAL, ST_BANKDEPOSIT, ST_BANKPAYMENT) :
array(ST_SALESINVOICE, ST_CUSTCREDIT, ST_SUPPINVOICE, ST_SUPPCREDIT, ST_JOURNAL)).")
AND taxrec.tran_date >= '$fromdate'
AND taxrec.tran_date <= '$todate'
GROUP BY ttype.id";
Expand Down
5 changes: 5 additions & 0 deletions includes/prefs/sysprefs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ class sys_prefs
return $this->prefs['suppress_tax_rates'];
}

function tax_bank_payments()
{
return $this->prefs['tax_bank_payments'];
}

function backup_dir($comp=null)
{
if (!isset($comp))
Expand Down
35 changes: 25 additions & 10 deletions reporting/rep709.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ function getTaxTransactions($from, $to)

$sql = "SELECT tt.name as taxname, taxrec.*, taxrec.amount*ex_rate AS amount,
taxrec.net_amount*ex_rate AS net_amount,
IF(taxrec.trans_type=".ST_BANKPAYMENT." OR taxrec.trans_type=".ST_BANKDEPOSIT.",
IF(gl.person_type_id<>".PT_MISC.", gl.memo_, gl.person_id),
IF(ISNULL(supp.supp_name), debt.name, supp.supp_name)) as name,
branch.br_name
IF(ISNULL(supp.supp_name),
IF(ISNULL(debt.name),
IF(gl.person_type_id<>".PT_MISC.", gl.memo_, bt.person_id), debt.name),
supp.supp_name) as name,
branch.br_name,
bt.bank_act,
gl.memo_ as gl_memo
FROM ".TB_PREF."trans_tax_details taxrec
LEFT JOIN ".TB_PREF."tax_types tt
ON taxrec.tax_type_id=tt.id
Expand All @@ -52,10 +55,18 @@ function getTaxTransactions($from, $to)
ON taxrec.trans_no=dtrans.trans_no AND taxrec.trans_type=dtrans.type
LEFT JOIN ".TB_PREF."debtors_master as debt ON dtrans.debtor_no=debt.debtor_no
LEFT JOIN ".TB_PREF."cust_branch as branch ON dtrans.branch_code=branch.branch_code
LEFT JOIN ".TB_PREF."bank_trans as bt ON taxrec.trans_type=bt.type AND taxrec.trans_no=bt.trans_no
WHERE (taxrec.amount <> 0 OR taxrec.net_amount <> 0)
AND !ISNULL(taxrec.reg_type)
AND taxrec.tran_date >= '$fromdate'
AND taxrec.trans_type <> ".ST_CUSTDELIVERY;

// display of bank payments/deposits in tax history is optional in FA
if (!get_company_pref("tax_bank_payments"))
$sql .= " AND taxrec.trans_type <> ".ST_BANKPAYMENT."
AND taxrec.trans_type <> ".ST_BANKDEPOSIT;

$sql .= " AND taxrec.tran_date >= '$fromdate'
AND taxrec.tran_date <= '$todate'
GROUP BY taxrec.id
ORDER BY taxrec.trans_type, taxrec.tran_date, taxrec.trans_no, taxrec.ex_rate";

return db_query($sql,"No transactions were returned");
Expand Down Expand Up @@ -140,9 +151,7 @@ function print_tax_report()
if (!$summaryOnly)
{
$rep->TextCol(0, 1, $systypes_array[$trans['trans_type']]);
if ($trans['memo'] == '')
$trans['memo'] = get_reference($trans['trans_type'], $trans['trans_no']);
$rep->TextCol(1, 2, $trans['memo']);
$rep->TextCol(1, 2, get_reference($trans['trans_type'], $trans['trans_no']));
$rep->DateCol(2, 3, $trans['tran_date'], true);
$rep->TextCol(3, 4, $trans['name']);
$rep->TextCol(4, 5, $trans['br_name']);
Expand All @@ -154,6 +163,12 @@ function print_tax_report()
$rep->TextCol(9, 10, $trans['taxname']);

$rep->NewLine();
if (in_array($trans['trans_type'], array(ST_BANKPAYMENT, ST_BANKDEPOSIT))) {
$rep->TextCol(1, 3, get_bank_account($trans['bank_act'])['bank_account_name']);
$rep->TextCol(3, 4, $trans['memo']);
$rep->TextCol(4, 8, $trans['gl_memo']);
$rep->NewLine();
}

if ($rep->row < $rep->bottomMargin + $rep->lineHeight)
{
Expand All @@ -173,7 +188,7 @@ function print_tax_report()
elseif (in_array($trans['trans_type'], array(ST_BANKDEPOSIT,ST_SALESINVOICE,ST_CUSTCREDIT))) {
$taxes[$tax_type]['taxout'] += $trans['amount'];
$taxes[$tax_type]['out'] += $trans['net_amount'];
} elseif ($trans['reg_type'] !== NULL) {
} elseif ($trans['reg_type'] !== NULL || in_array($trans['trans_type'], array(ST_SUPPINVOICE, ST_SUPPCREDIT, ST_BANKPAYMENT))) {
$taxes[$tax_type]['taxin'] += $trans['amount'];
$taxes[$tax_type]['in'] += $trans['net_amount'];
}
Expand Down
3 changes: 3 additions & 0 deletions sql/alter2.4.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ function install($company, $force=false)
if (get_company_pref('shortname_name_in_list') === null) { // available from 2.4.2, during updates
set_company_pref('shortname_name_in_list', 'setup.company', 'tinyint', 1, '0');
}
if (get_company_pref('tax_bank_payments') === null) { // available from 2.4.7, during updates
set_company_pref('tax_bank_payments', 'setup.company', 'tinyint', 1, '0');
}

$result = $this->update_workorders() && $this->update_grn_rates() && $this->switch_database_to_utf($pref);

Expand Down
3 changes: 2 additions & 1 deletion sql/alter2.4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ INSERT IGNORE INTO `0_sys_prefs` VALUES
('accounts_alpha', 'glsetup.general', 'tinyint', 1, '0'),
('bcc_email', 'setup.company', 'varchar', 100, ''),
('alternative_tax_include_on_docs', 'setup.company', 'tinyint', 1, '0'),
('suppress_tax_rates', 'setup.company', 'tinyint', 1, '0');
('suppress_tax_rates', 'setup.company', 'tinyint', 1, '0'),
('tax_bank_payments', 'setup.company', 'tinyint', 1, '0');

# stock_moves.visible field is obsolete
# removing obsolete moves for writeoffs
Expand Down
3 changes: 2 additions & 1 deletion sql/en_US-demo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,7 @@ INSERT INTO `0_sys_prefs` VALUES
('print_invoice_no','glsetup.sales', 'tinyint', 1, '0'),
('allow_negative_prices','glsetup.inventory', 'tinyint', 1, '1'),
('print_item_images_on_quote','glsetup.inventory', 'tinyint', 1, '0'),
('tax_bank_payments','setup.company', 'tinyint', 1, '0'),
('suppress_tax_rates','setup.company', 'tinyint', 1, '0'),
('company_logo_report','setup.company', 'tinyint', 1, '0'),
('barcodes_on_stock','setup.company', 'tinyint', 1, '0'),
Expand Down Expand Up @@ -2279,4 +2280,4 @@ CREATE TABLE `0_workorders` (
INSERT INTO `0_workorders` VALUES
('1', '001/2018', 'DEF', '2', '201', '2018-05-05', '0', '2018-05-05', '2018-05-05', '2', '1', '1', '0'),
('2', '002/2018', 'DEF', '5', '201', '2018-05-07', '2', '2018-05-27', '2018-05-07', '0', '0', '1', '0'),
('3', '003/2018', 'DEF', '5', '201', '2018-05-07', '2', '2018-05-27', '0000-00-00', '0', '0', '0', '0');
('3', '003/2018', 'DEF', '5', '201', '2018-05-07', '2', '2018-05-27', '0000-00-00', '0', '0', '0', '0');
1 change: 1 addition & 0 deletions sql/en_US-new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,7 @@ INSERT INTO `0_sys_prefs` VALUES
('print_invoice_no','glsetup.sales', 'tinyint', 1, '0'),
('allow_negative_prices','glsetup.inventory', 'tinyint', 1, '1'),
('print_item_images_on_quote','glsetup.inventory', 'tinyint', 1, '0'),
('tax_bank_payments','setup.company', 'tinyint', 1, '0'),
('suppress_tax_rates','setup.company', 'tinyint', 1, '0'),
('company_logo_report','setup.company', 'tinyint', 1, '0'),
('barcodes_on_stock','setup.company', 'tinyint', 1, '0'),
Expand Down