Better test for correct balance accounts when closing fiscal year.
[fa-stable.git] / admin / db / fiscalyears_db.inc
index 669e8c3c91f7fbb00572b45b8d7f72a124a9f4bb..ff4e4bcd3b7664ed72206df3585c4096ee5c5db6 100644 (file)
@@ -124,6 +124,12 @@ function close_year($year)
                display_error(_("The Retained Earnings Account or the Profit and Loss Year Account has not been set in System and General GL Setup"));
                return false;
        }
+       if (!is_account_balancesheet($co['retained_earnings_act']) || is_account_balancesheet($co['profit_loss_year_act']))
+       {
+               display_error(_("The Retained Earnings Account should be a Balance Account or the Profit and Loss Year Account should be an Expense Account (preferred the last one in the Expense Class)"));
+               return false;
+       }
+
        begin_transaction();
 
        $myrow = get_fiscalyear($year);