From 99b2a5de9ef5ac1cbf73a597b5870da20d7c6b79 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Wed, 13 Feb 2019 16:05:42 +0100 Subject: [PATCH] Process Depreciation: hardcoded fiscal years constraint removed. --- includes/data_checks.inc | 7 ++++--- includes/ui/ui_lists.inc | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/data_checks.inc b/includes/data_checks.inc index 54f9dbb5..4b968904 100644 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@ -348,15 +348,16 @@ function db_has_fixed_asset_classes() function db_has_depreciable_fixed_assets() { $year = get_current_fiscalyear(); - $y = date('Y', strtotime($year['end'])); + $begin = date2sql(add_months(sql2date($year['begin']), -1)); + $end = date2sql(add_months(sql2date($year['end']), -1)); return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag='F' AND material_cost > 0 AND stock_id IN ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE type=".ST_SUPPRECEIVE." AND qty!=0 ) AND stock_id NOT IN ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE (type=".ST_CUSTDELIVERY." OR type=".ST_INVADJUST.") AND qty!=0 ) - AND depreciation_date < '".$y."-12-01' - AND depreciation_date >= '".($y-1)."-12-01'"); + AND depreciation_date <= '".$end."' + AND depreciation_date >='".$begin."'"); } function check_db_has_depreciable_fixed_assets($msg) diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index c7c5a406..c70343af 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -1152,11 +1152,12 @@ function stock_depreciable_fa_list_cells($label, $name, $selected_id=null, ( SELECT stock_id FROM ".TB_PREF."stock_moves WHERE (type=".ST_CUSTDELIVERY." OR type=".ST_INVADJUST.") AND qty!=0 )"; $year = get_current_fiscalyear(); - $y = date('Y', strtotime($year['end'])); + $begin = date2sql(add_months(sql2date($year['begin']), -1)); + $end = date2sql(add_months(sql2date($year['end']), -1)); // check if current fiscal year - $where_opts[] = "depreciation_date < '".$y."-12-01'"; - $where_opts[] = "depreciation_date >= '".($y-1)."-12-01'"; + $where_opts[] = "depreciation_date <= '".$end."'"; + $where_opts[] = "depreciation_date >= '".$begin."'"; $where_opts[] = "material_cost > 0"; $where_opts[] = "mb_flag='F'"; -- 2.30.2