Process Depreciation: hardcoded fiscal years constraint removed.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 13 Feb 2019 15:05:42 +0000 (16:05 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 13 Feb 2019 15:07:45 +0000 (16:07 +0100)
includes/data_checks.inc
includes/ui/ui_lists.inc

index 54f9dbb5683fb2270079605c6ddb4d73c12626eb..4b9689045e410c42e3140451a32bdc41cee30dd9 100644 (file)
@@ -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)
index c7c5a4061bb80b2449fa96886a35a1c7faf27402..c70343af04c318171ce94c63fa804645781fcc74 100644 (file)
@@ -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'";