Update supplier/cost with components

This commit is contained in:
2024-08-24 17:37:55 +10:00
parent b877a2b673
commit 2627cea3b5
8 changed files with 89 additions and 146 deletions

View File

@@ -8,7 +8,7 @@ use Illuminate\Support\Arr;
use App\Http\Requests\{SupplierAddEdit,SupplierProductAddEdit};
use App\Jobs\ImportCosts;
use App\Models\{Cost,Supplier,SupplierDetail};
use App\Models\{Supplier,SupplierDetail};
class SupplierController extends Controller
{
@@ -24,7 +24,7 @@ class SupplierController extends Controller
foreach (Arr::except($request->validated(),['supplier_details','api_key','api_secret','submit']) as $key => $item)
$o->{$key} = $item;
$o->active = (bool)$request->active;
$o->active = (bool)$request->validated('active');
try {
$o->save();
@@ -50,25 +50,6 @@ class SupplierController extends Controller
->with('success','Supplier Saved');
}
/**
* Show the suppliers invoice
*
* @param Cost $o
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
public function cost(Cost $o)
{
// @todo Need to add the services that are active that are not on the bill for the supplier.
return view('theme.backend.adminlte.supplier.cost.view')
->with('o',$o);
}
public function cost_add(Supplier $o)
{
return view('theme.backend.adminlte.supplier.cost.add')
->with('o',$o);
}
public function cost_submit(Request $request,Supplier $o)
{
$request->validate([

View File

@@ -126,7 +126,7 @@ class ImportCosts implements ShouldQueue
$cost = ($x=$this->getColumnKey('PRICETOTAL')) ? str_replace([',','$'],'',$fields[$x]) : NULL;
$start_at = Carbon::createFromFormat('d M Y',$m[3]);
$stop_at = Carbon::createFromFormat('d M Y',$m[4]);
$so = Service::search($m[1])->active()->with(['type','product.type.supplied'])->single();
$so = Service::search($m[1])->ServiceActive()->with(['type','product.type.supplied'])->single();
if ($so) {
// r[1] = Monthly Charge or Extra Charge,r[2] = "On Plan", r[3] = Plan Info
@@ -197,7 +197,7 @@ class ImportCosts implements ShouldQueue
}
} else {
dump(['line'=>$line,'sql'=>Service::search($m[1])->active()->with(['type','product.type.supplied'])->toSql()]);
dump(['line'=>$line,'sql'=>Service::search($m[1])->ServiceActive()->with(['type','product.type.supplied'])->toSql()]);
$to = Cost\Generic::where('site_id',$this->co->site_id)
->where('cost_id',$this->co->id)

View File

@@ -8,9 +8,9 @@ abstract class Type extends Model
{
public $timestamps = FALSE;
protected $dates = [
'start_at',
'end_at',
protected $casts = [
'start_at' => 'datetime:Y-m-d',
'end_at' => 'datetime:Y-m-d',
];
/* RELATIONS */

View File

@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Intuit\Traits\IntuitSocialite;
use App\Models\{Checkout,Payment,Product,Service,Supplier};
use App\Models\{Checkout,Cost,Payment,Product,Service,Supplier};
class AppServiceProvider extends ServiceProvider
{
@@ -36,6 +36,7 @@ class AppServiceProvider extends ServiceProvider
$this->bootIntuitSocialite();
Route::model('co',Checkout::class);
Route::model('cso',Cost::class);
Route::model('po',Payment::class);
Route::model('pdo',Product::class);
Route::model('so',Service::class);