Пример #1
0
 public function index()
 {
     $years = FinancialYear::lists('year', 'year');
     $workspace_id = Auth::user()->workspace_id;
     if ($workspace_id == 1) {
         $workspace = Workspace::where('status', '=', 1)->lists('name', 'id');
     } else {
         $workspace = Workspace::where(['id' => $workspace_id])->lists('name', 'id');
     }
     return view('reports.materialUsage.index')->with(compact('workspace', 'years'));
 }
Пример #2
0
 public function store(Request $request)
 {
     $this->validate($request, ['year' => 'required|unique:financial_years', 'start_date' => 'required', 'end_date' => 'required']);
     try {
         DB::transaction(function () use($request) {
             FinancialYear::where('status', '=', 1)->update(['status' => 0]);
             $financial_year = new FinancialYear();
             $financial_year->year = $request->year;
             $financial_year->start_date = strtotime($request->start_date);
             $financial_year->end_date = strtotime($request->end_date);
             $financial_year->created_by = Auth::user()->id;
             $financial_year->created_at = time();
             $financial_year->save();
         });
     } catch (\Exception $e) {
         Session()->flash('error_message', 'Financial Year can not be created. Please Try again.');
         return Redirect::back();
     }
     Session()->flash('flash_message', 'Financial Year created Successfully.');
     return redirect('financial_year');
 }
Пример #3
0
 public function store(Request $request)
 {
     try {
         DB::transaction(function () use($request) {
             $workspace_id = $request->workspace_id;
             if ($workspace_id > 0) {
                 $currentYear = CommonHelper::get_current_financial_year();
                 $closingStatus = DB::table('account_closings')->where(['year' => $currentYear, 'workspace_id' => $workspace_id])->value('status');
                 $existingYearDetail = DB::table('financial_years')->where('year', $currentYear)->first();
                 if ($closingStatus == 1) {
                     if ($existingYearDetail->end_date > strtotime(date('Y-m-d'))) {
                         // Delete Workspace Closing Balance Data of Current Year
                         WorkspaceLedger::where(['workspace_id' => $workspace_id, 'balance_type' => Config::get('common.balance_type_closing'), 'year' => CommonHelper::get_current_financial_year()])->delete();
                         // Delete Next Year Opening Balance Data
                         WorkspaceLedger::where(['workspace_id' => $workspace_id, 'balance_type' => Config::get('common.balance_type_opening'), 'year' => CommonHelper::get_next_financial_year()])->delete();
                         // Delete Next Year Intermediate Balance Data
                         WorkspaceLedger::where(['workspace_id' => $workspace_id, 'balance_type' => Config::get('common.balance_type_intermediate'), 'year' => CommonHelper::get_next_financial_year()])->delete();
                         //  Delete Stock Table Current Year Closing Balance Data
                         Stock::where(['workspace_id' => $workspace_id, 'stock_type' => Config::get('common.balance_type_closing'), 'year' => CommonHelper::get_current_financial_year()])->delete();
                         // Delete Next Year Opening Balance Data
                         Stock::where(['workspace_id' => $workspace_id, 'stock_type' => Config::get('common.balance_type_opening'), 'year' => CommonHelper::get_next_financial_year()])->delete();
                         // Delete Stock Table Next Year Intermediate Balance Data
                         Stock::where(['workspace_id' => $workspace_id, 'stock_type' => Config::get('common.balance_type_intermediate'), 'year' => CommonHelper::get_next_financial_year()])->delete();
                         // Delete Account Closing Data
                         AccountClosing::where(['workspace_id' => $workspace_id, 'year' => CommonHelper::get_current_financial_year(), 'type' => 1])->delete();
                     } else {
                         Session()->flash('warning_message', 'Alert: Time Over!');
                         throw new \Exception('error');
                     }
                 } else {
                     Session()->flash('warning_message', 'Alert: Workspace Not Closed Yet!');
                     throw new \Exception('error');
                 }
             } else {
                 // Total System is being rolled back to the previous year
                 // Delete General Ledger Current Year Closing Data
                 GeneralLedger::where(['balance_type' => Config::get('common.balance_type_closing'), 'year' => CommonHelper::get_previous_financial_year()])->delete();
                 // Delete General Ledger Next Year Opening Data
                 GeneralLedger::where(['balance_type' => Config::get('common.balance_type_opening'), 'year' => CommonHelper::get_current_financial_year()])->delete();
                 // Delete General Journal Table Current Year Data
                 GeneralJournal::where(['year' => CommonHelper::get_current_financial_year()])->delete();
                 // Delete Account Closing Data
                 AccountClosing::where(['year' => CommonHelper::get_previous_financial_year(), 'type' => 2])->delete();
                 //  Delete Raw Stock Table Previous Year Closing Balance Data
                 RawStock::where(['stock_type' => Config::get('common.balance_type_closing'), 'year' => CommonHelper::get_previous_financial_year()])->delete();
                 //  Delete Raw Stock Table Current Year Opening Balance Data
                 RawStock::where(['stock_type' => Config::get('common.balance_type_opening'), 'year' => CommonHelper::get_current_financial_year()])->delete();
                 //  Delete Raw Stock Table Current Year Intermediate Balance Data
                 RawStock::where(['stock_type' => Config::get('common.balance_type_intermediate'), 'year' => CommonHelper::get_current_financial_year()])->delete();
                 // Workspaces Rollback
                 $workspaces = Workspace::where('status', '=', 1)->get();
                 foreach ($workspaces as $workspace) {
                     $workspace_id = $workspace->id;
                     // Delete Workspace Closing Balance Data of Current Year
                     WorkspaceLedger::where(['workspace_id' => $workspace_id, 'balance_type' => Config::get('common.balance_type_closing'), 'year' => CommonHelper::get_previous_financial_year()])->delete();
                     // Delete Next Year Opening Balance Data
                     WorkspaceLedger::where(['workspace_id' => $workspace_id, 'balance_type' => Config::get('common.balance_type_opening'), 'year' => CommonHelper::get_current_financial_year()])->delete();
                     // Delete Next Year Intermediate Balance Data
                     WorkspaceLedger::where(['workspace_id' => $workspace_id, 'balance_type' => Config::get('common.balance_type_intermediate'), 'year' => CommonHelper::get_current_financial_year()])->delete();
                     //  Delete Stock Table Current Year Closing Balance Data
                     Stock::where(['workspace_id' => $workspace_id, 'stock_type' => Config::get('common.balance_type_closing'), 'year' => CommonHelper::get_previous_financial_year()])->delete();
                     // Delete Next Year Opening Balance Data
                     Stock::where(['workspace_id' => $workspace_id, 'stock_type' => Config::get('common.balance_type_opening'), 'year' => CommonHelper::get_current_financial_year()])->delete();
                     // Delete Stock Table Next Year Intermediate Balance Data
                     Stock::where(['workspace_id' => $workspace_id, 'stock_type' => Config::get('common.balance_type_intermediate'), 'year' => CommonHelper::get_current_financial_year()])->delete();
                     // Delete Account Closing Data
                     AccountClosing::where(['workspace_id' => $workspace_id, 'year' => CommonHelper::get_previous_financial_year(), 'type' => 1])->delete();
                 }
                 // Fiscal Year Table Operations
                 $previous = CommonHelper::get_previous_financial_year();
                 $current = CommonHelper::get_current_financial_year();
                 // Previous Year Activate
                 DB::table('financial_years')->where('year', $previous)->update(['status' => 1]);
                 // Delete Current Financial Year
                 FinancialYear::where(['year' => $current])->delete();
             }
         });
     } catch (\Exception $e) {
         Session()->flash('error_message', 'Rollback not done!');
         return redirect('rollback');
     }
     Session()->flash('flash_message', 'Rollback Successfully done!');
     return redirect('rollback');
 }
Пример #4
0
 public function index()
 {
     $workspaces = Workspace::lists('name', 'id');
     $years = FinancialYear::lists('year', 'year');
     return view('reports.payrollReport.index')->with(compact('years', 'workspaces'));
 }