mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
64 lines
2.8 KiB
PHP
Executable File
64 lines
2.8 KiB
PHP
Executable File
<?php
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class PatientCategoryInvoiceAccountSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeders.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
$invoices = \Streamline\Models\PatientCategoryInvoice::all();
|
|
$drugs_cost_of_good_account_id = \Streamline\Models\ChartOfAccount::where('id', 17)->pluck('id')->first();
|
|
$sundries_cost_of_good_account_id = \Streamline\Models\ChartOfAccount::where('id', 5)->pluck('id')->first();
|
|
|
|
foreach ($invoices as $invoice){
|
|
//Consultations / Services
|
|
if($invoice->tag_id == 6 || $invoice->tag_id == 8 || $invoice->tag_id == 7 || $invoice->tag_id == 10){
|
|
\Streamline\Models\PatientCategoryInvoice::where('id', $invoice->id)->update(['income_account'=> 7]);
|
|
}
|
|
//Drugs / Treatments
|
|
elseif ($invoice->tag_id == 3 || $invoice->tag_id == 1){
|
|
$cost_price_array = [];
|
|
$items_array = explode(',',$invoice->items_ids);
|
|
for ($x = 0; $x < count($items_array); $x++){
|
|
$current_cost_price = get_name($items_array[$x], 'id', 'cost_price', 'drugs');
|
|
array_push($cost_price_array, $current_cost_price);
|
|
}
|
|
$cost_price_string = implode(',', $cost_price_array);
|
|
\Streamline\Models\PatientCategoryInvoice::where('id', $invoice->id)->update([
|
|
'income_account'=> 4,
|
|
'cost_price'=> $cost_price_string,
|
|
'cost_of_goods_account'=> $drugs_cost_of_good_account_id
|
|
]);
|
|
|
|
}
|
|
//Sundries
|
|
elseif ($invoice->tag_id == 5 ){
|
|
$items_array = explode(',',$invoice->items_ids);
|
|
for ($x = 0; $x < count($items_array); $x++){
|
|
$current_cost_price = get_name($items_array[$x], 'id', 'cost_price', 'drugs');
|
|
array_push($cost_price_array, $current_cost_price);
|
|
}
|
|
$cost_price_string = implode(',', $cost_price_array);
|
|
\Streamline\Models\PatientCategoryInvoice::where('id', $invoice->id)->update([
|
|
'income_account'=> 4,
|
|
'cost_price'=> $cost_price_string,
|
|
'cost_of_goods_account'=> $sundries_cost_of_good_account_id
|
|
]);
|
|
}
|
|
//Investigations
|
|
elseif ($invoice->tag_id == 2 ){
|
|
\Streamline\Models\PatientCategoryInvoice::where('id', $invoice->id)->update(['income_account'=> 11]);
|
|
}
|
|
//Procedures
|
|
elseif ($invoice->tag_id == 4 ){
|
|
\Streamline\Models\PatientCategoryInvoice::where('id', $invoice->id)->update(['income_account'=> 8]);
|
|
}
|
|
}
|
|
}
|
|
}
|