mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
add product/items logic
This commit is contained in:
parent
7f9010b9a5
commit
9dcf0fac77
11
app/Repositories/Import/Quickbooks/ItemRepository.php
Normal file
11
app/Repositories/Import/Quickbooks/ItemRepository.php
Normal 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";
|
||||
}
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user