mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
121 lines
4.8 KiB
PHP
Executable File
121 lines
4.8 KiB
PHP
Executable File
<?php
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Streamline\Models\Debtor;
|
|
use Streamline\Models\DebtPlan;
|
|
use Streamline\Models\InsuranceExpenditure;
|
|
|
|
class DebtTablesAccountSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeders.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
$debtors = \Streamline\Models\Debtor::all();
|
|
$debt_plans = \Streamline\Models\DebtPlan::all();
|
|
$insurance_expenditures = \Streamline\Models\InsuranceExpenditure::all();
|
|
$inventory_account_id = \Streamline\Models\ChartOfAccount::where('type', 10)->pluck('id')->first();
|
|
$cost_of_good_account_id = \Streamline\Models\ChartOfAccount::where('type', 7)->pluck('id')->first();
|
|
|
|
foreach ($debtors as $invoice){
|
|
//Consultations / Services
|
|
if($invoice->tag_id == 6 || $invoice->tag_id == 8 || $invoice->tag_id == 7 || $invoice->tag_id == 10){
|
|
Debtor::where('id', $invoice->id)->update(['income_account'=> 7]);
|
|
}
|
|
//Drugs / Treatments
|
|
elseif ($invoice->tag_id == 3 || $invoice->tag_id == 1){
|
|
|
|
Debtor::where('id', $invoice->id)->update([
|
|
'income_account'=> 4,
|
|
'inventory_account'=> $inventory_account_id,
|
|
'cost_of_goods_account'=> $cost_of_good_account_id
|
|
]);
|
|
|
|
}
|
|
//Sundries
|
|
elseif ($invoice->tag_id == 5 ){
|
|
|
|
Debtor::where('id', $invoice->id)->update([
|
|
'income_account'=> 4,
|
|
'inventory_account'=> $inventory_account_id,
|
|
'cost_of_goods_account'=> $cost_of_good_account_id
|
|
]);
|
|
}
|
|
//Investigations
|
|
elseif ($invoice->tag_id == 2 ){
|
|
Debtor::where('id', $invoice->id)->update(['income_account'=> 11]);
|
|
}
|
|
//Procedures
|
|
elseif ($invoice->tag_id == 4 ){
|
|
Debtor::where('id', $invoice->id)->update(['income_account'=> 8]);
|
|
}
|
|
}
|
|
|
|
foreach ($debt_plans as $invoice){
|
|
//Consultations / Services
|
|
if($invoice->tag_id == 6 || $invoice->tag_id == 8 || $invoice->tag_id == 7 || $invoice->tag_id == 10){
|
|
DebtPlan::where('id', $invoice->id)->update(['income_account'=> 7]);
|
|
}
|
|
//Drugs / Treatments
|
|
elseif ($invoice->tag_id == 3 || $invoice->tag_id == 1){
|
|
DebtPlan::where('id', $invoice->id)->update([
|
|
'income_account'=> 4,
|
|
'inventory_account'=> $inventory_account_id,
|
|
'cost_of_goods_account'=> $cost_of_good_account_id
|
|
]);
|
|
|
|
}
|
|
//Sundries
|
|
elseif ($invoice->tag_id == 5 ){
|
|
DebtPlan::where('id', $invoice->id)->update([
|
|
'income_account'=> 4,
|
|
'inventory_account'=> $inventory_account_id,
|
|
'cost_of_goods_account'=> $cost_of_good_account_id
|
|
]);
|
|
}
|
|
//Investigations
|
|
elseif ($invoice->tag_id == 2 ){
|
|
DebtPlan::where('id', $invoice->id)->update(['income_account'=> 11]);
|
|
}
|
|
//Procedures
|
|
elseif ($invoice->tag_id == 4 ){
|
|
DebtPlan::where('id', $invoice->id)->update(['income_account'=> 8]);
|
|
}
|
|
}
|
|
foreach ($insurance_expenditures as $invoice){
|
|
//Consultations / Services
|
|
if($invoice->tag_id == 6 || $invoice->tag_id == 8 || $invoice->tag_id == 7 || $invoice->tag_id == 10){
|
|
InsuranceExpenditure::where('id', $invoice->id)->update(['income_account'=> 7]);
|
|
}
|
|
//Drugs / Treatments
|
|
elseif ($invoice->tag_id == 3 || $invoice->tag_id == 1){
|
|
InsuranceExpenditure::where('id', $invoice->id)->update([
|
|
'income_account'=> 4,
|
|
'inventory_account'=> $inventory_account_id,
|
|
'cost_of_goods_account'=> $cost_of_good_account_id
|
|
]);
|
|
|
|
}
|
|
//Sundries
|
|
elseif ($invoice->tag_id == 5 ){
|
|
InsuranceExpenditure::where('id', $invoice->id)->update([
|
|
'income_account'=> 12,
|
|
'inventory_account'=> $inventory_account_id,
|
|
'cost_of_goods_account'=> $cost_of_good_account_id
|
|
]);
|
|
}
|
|
//Investigations
|
|
elseif ($invoice->tag_id == 2 ){
|
|
InsuranceExpenditure::where('id', $invoice->id)->update(['income_account'=> 11]);
|
|
}
|
|
//Procedures
|
|
elseif ($invoice->tag_id == 4 ){
|
|
InsuranceExpenditure::where('id', $invoice->id)->update(['income_account'=> 8]);
|
|
}
|
|
}
|
|
}
|
|
}
|