Inuit sync of tax, product accounting, accounts and invoices
This commit is contained in:
@@ -24,20 +24,18 @@ class AccountingController extends Controller
|
||||
*/
|
||||
public static function list(string $provider): Collection
|
||||
{
|
||||
$so = ProviderOauth::where('name',$provider)->singleOrFail();
|
||||
// @todo This should be a variable
|
||||
$uo = User::findOrFail(1);
|
||||
|
||||
if (($x=$so->tokens->where('user_id',$uo->id))->count() !== 1)
|
||||
$so = ProviderOauth::where('name',$provider)->singleOrFail();
|
||||
if (! ($to=$so->token($uo)))
|
||||
abort(500,sprintf('Unknown Tokens for [%s]',$uo->email));
|
||||
|
||||
$to = $x->pop();
|
||||
|
||||
$api = $so->API($to,TRUE); // @todo Remove TRUE
|
||||
$api = $to->API();
|
||||
|
||||
return $api->getItems()
|
||||
->pluck('pid','FullyQualifiedName')
|
||||
->transform(function($item,$value) { return ['id'=>$item,'value'=>$value]; })
|
||||
->pluck('pid','Id')
|
||||
->transform(function($item,$value) { return ['id'=>$value,'value'=>$item]; })
|
||||
->values();
|
||||
}
|
||||
|
||||
|
@@ -92,7 +92,7 @@ class ProductController extends Controller
|
||||
|
||||
public function details_addedit(ProductAddEdit $request,Product $o)
|
||||
{
|
||||
foreach ($request->except(['_token','submit','translate']) as $key => $item)
|
||||
foreach ($request->except(['_token','submit','translate','accounting']) as $key => $item)
|
||||
$o->{$key} = $item;
|
||||
|
||||
$o->active = (bool)$request->active;
|
||||
@@ -122,6 +122,15 @@ class ProductController extends Controller
|
||||
|
||||
$o->translate()->save($oo);
|
||||
|
||||
if ($request->accounting)
|
||||
foreach ($request->accounting as $k=>$v)
|
||||
$o->providers()->syncWithoutDetaching([
|
||||
$k => [
|
||||
'ref' => $v,
|
||||
'site_id'=>$o->site_id,
|
||||
],
|
||||
]);
|
||||
|
||||
return redirect()->back()
|
||||
->with('success','Product saved');
|
||||
}
|
||||
|
Reference in New Issue
Block a user