From: Janusz Dobrowolski Date: Thu, 16 Apr 2015 08:27:04 +0000 (+0200) Subject: Salesman Report: fixed bug in provision calculation, Sales Persons: changed break... X-Git-Tag: v2.4.2~19^2~204 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=e289445ecdb1980ab73063dc3f6d131145ce76da;p=fa-stable.git Salesman Report: fixed bug in provision calculation, Sales Persons: changed break point definition to turnover level. --- diff --git a/reporting/rep106.php b/reporting/rep106.php index 409465e4..f9ea4499 100644 --- a/reporting/rep106.php +++ b/reporting/rep106.php @@ -40,7 +40,6 @@ function GetSalesmanTrans($from, $to) cust.name AS DebtorName, cust.curr_code, branch.br_name, - branch.contact_name, sorder.customer_ref, salesman.* FROM ".TB_PREF."debtor_trans trans, @@ -144,10 +143,14 @@ function print_salesman_list() } $rate = $myrow['rate']; $amt = $myrow['InvoiceTotal'] * $rate; - if ($subprov > $myrow['break_pt'] && $myrow['provision2'] != 0) - $prov = $myrow['provision2'] * $amt / 100; - else + if ($myrow['provision2'] == 0) $prov = $myrow['provision'] * $amt / 100; + else { + $amt1 = min($amt, max(0, $myrow['break_pt']-$subtotal)); + $amt2 = $amt - $amt1; + + $prov = $amt1*$myrow['provision']/100 + $amt2*$myrow['provision2']/100; + } if (!$summary) { $rep->TextCol(0, 1, $myrow['trans_no']); diff --git a/sales/manage/sales_people.php b/sales/manage/sales_people.php index 121eea6b..2f44ad06 100644 --- a/sales/manage/sales_people.php +++ b/sales/manage/sales_people.php @@ -157,7 +157,7 @@ text_row_ex(_("Telephone number:"), 'salesman_phone', 20); text_row_ex(_("Fax number:"), 'salesman_fax', 20); email_row_ex(_("E-mail:"), 'salesman_email', 40); percent_row(_("Provision").':', 'provision'); -amount_row(_("Break Pt.:"), 'break_pt'); +amount_row(_("Turnover Break Pt Level:"), 'break_pt'); percent_row(_("Provision")." 2:", 'provision2'); end_table(1); diff --git a/sql/alter2.4.sql b/sql/alter2.4.sql index 727e91c3..66910137 100644 --- a/sql/alter2.4.sql +++ b/sql/alter2.4.sql @@ -239,3 +239,9 @@ ALTER TABLE `0_stock_moves` DROP COLUMN `discount_percent`; ALTER TABLE `0_stock_moves` DROP COLUMN `person_id`; DROP TABLE IF EXISTS `0_movement_types`; + +# change salesman breakpoint meaning to turnover level +UPDATE `0_salesman` + SET `break_pt` = `break_pt`*100.0/`provision` +WHERE `provision` != 0; +