add product/items logic

This commit is contained in:
karneaud 2024-08-13 12:35:50 -04:00
parent 7f9010b9a5
commit 9dcf0fac77
3 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,11 @@
<?php
namespace App\Repositories\Import\Quickbooks;
use App\Repositories\Import\Quickbooks\Repository;
use App\Repositories\Import\Quickbooks\Contracts\RepositoryInterface;
class ItemRepository extends Repository implements RepositoryInterface
{
protected string $entity = "Item";
}

View File

@ -34,6 +34,18 @@ class Transformer
]);
}
protected function transformItems(array $items): Collection
{
return $this->transformation($items, [
'Name',
'Description',
'PurchaseCost',
'UnitPrice',
'QtyOnHand',
'MetaData'
]);
}
protected function transformation(array $items, array $keys) : Collection
{
return collect($items)->select($keys);

View File

@ -40,6 +40,17 @@ final class Service
return $this->transformer->transform($this->fetchRecords( 'Invoice', $max), 'Invoice');
}
/**
* fetch QuickBooks product records
* @param int $max The maximum records to fetch. Default 100
* @return Illuminate\Support\Collection;
*/
public function fetchItems(int $max = 100): Collection
{
return $this->fetchRecords('Item', $max) ;
}
protected function fetchRecords(string $entity, $max = 100) : Collection {
return (self::RepositoryFactory($entity))->get($max);
}