categories for invoices/bills
This commit is contained in:
@@ -5,6 +5,11 @@ namespace App\Listeners\Updates;
|
||||
use App\Events\UpdateFinished;
|
||||
use App\Models\Auth\Role;
|
||||
use App\Models\Auth\Permission;
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Expense\Bill;
|
||||
use App\Models\Income\Invoice;
|
||||
use App\Models\Setting\Category;
|
||||
use Artisan;
|
||||
|
||||
class Version120 extends Listener
|
||||
{
|
||||
@@ -25,6 +30,16 @@ class Version120 extends Listener
|
||||
return;
|
||||
}
|
||||
|
||||
$this->updatePermissions();
|
||||
|
||||
// Update database
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
|
||||
$this->updateInvoicesAndBills();
|
||||
}
|
||||
|
||||
protected function updatePermissions()
|
||||
{
|
||||
$permissions = [];
|
||||
|
||||
// Create tax summary permission
|
||||
@@ -56,4 +71,39 @@ class Version120 extends Listener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function updateInvoicesAndBills()
|
||||
{
|
||||
$companies = Company::all();
|
||||
|
||||
foreach ($companies as $company) {
|
||||
// Invoices
|
||||
$invoice_category = Category::create([
|
||||
'company_id' => $company->id,
|
||||
'name' => trans_choice('general.invoices', 2),
|
||||
'type' => 'income',
|
||||
'color' => '#00c0ef',
|
||||
'enabled' => '1'
|
||||
]);
|
||||
|
||||
foreach ($company->invoices as $invoice) {
|
||||
$invoice->category_id = $invoice_category->id;
|
||||
$invoice->save();
|
||||
}
|
||||
|
||||
// Bills
|
||||
$bill_category = Category::create([
|
||||
'company_id' => $company->id,
|
||||
'name' => trans_choice('general.bills', 2),
|
||||
'type' => 'expense',
|
||||
'color' => '#dd4b39',
|
||||
'enabled' => '1'
|
||||
]);
|
||||
|
||||
foreach ($company->bills as $bill) {
|
||||
$bill->category_id = $bill_category->id;
|
||||
$bill->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user