bills import/export
This commit is contained in:
		@@ -9,7 +9,7 @@ class BillHistories extends Export
 | 
			
		||||
{
 | 
			
		||||
    public function collection()
 | 
			
		||||
    {
 | 
			
		||||
        $model = Model::usingSearchString(request('search'));
 | 
			
		||||
        $model = Model::with(['bill'])->usingSearchString(request('search'));
 | 
			
		||||
 | 
			
		||||
        if (!empty($this->ids)) {
 | 
			
		||||
            $model->whereIn('bill_id', (array) $this->ids);
 | 
			
		||||
@@ -18,10 +18,17 @@ class BillHistories extends Export
 | 
			
		||||
        return $model->get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function map($model): array
 | 
			
		||||
    {
 | 
			
		||||
        $model->bill_number = $model->bill->bill_number;
 | 
			
		||||
 | 
			
		||||
        return parent::map($model);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function fields(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'bill_id',
 | 
			
		||||
            'bill_number',
 | 
			
		||||
            'status',
 | 
			
		||||
            'notify',
 | 
			
		||||
            'description',
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ class BillItemTaxes extends Export
 | 
			
		||||
{
 | 
			
		||||
    public function collection()
 | 
			
		||||
    {
 | 
			
		||||
        $model = Model::usingSearchString(request('search'));
 | 
			
		||||
        $model = Model::with(['bill', 'item', 'tax'])->usingSearchString(request('search'));
 | 
			
		||||
 | 
			
		||||
        if (!empty($this->ids)) {
 | 
			
		||||
            $model->whereIn('bill_id', (array) $this->ids);
 | 
			
		||||
@@ -18,13 +18,21 @@ class BillItemTaxes extends Export
 | 
			
		||||
        return $model->get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function map($model): array
 | 
			
		||||
    {
 | 
			
		||||
        $model->bill_number = $model->bill->bill_number;
 | 
			
		||||
        $model->item_name = $model->item->name;
 | 
			
		||||
        $model->tax_rate = $model->tax->rate;
 | 
			
		||||
 | 
			
		||||
        return parent::map($model);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function fields(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'bill_id',
 | 
			
		||||
            'bill_item_id',
 | 
			
		||||
            'tax_id',
 | 
			
		||||
            'name',
 | 
			
		||||
            'bill_number',
 | 
			
		||||
            'item_name',
 | 
			
		||||
            'tax_rate',
 | 
			
		||||
            'amount',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ class BillItems extends Export
 | 
			
		||||
{
 | 
			
		||||
    public function collection()
 | 
			
		||||
    {
 | 
			
		||||
        $model = Model::usingSearchString(request('search'));
 | 
			
		||||
        $model = Model::with(['bill', 'item'])->usingSearchString(request('search'));
 | 
			
		||||
 | 
			
		||||
        if (!empty($this->ids)) {
 | 
			
		||||
            $model->whereIn('bill_id', (array) $this->ids);
 | 
			
		||||
@@ -18,12 +18,19 @@ class BillItems extends Export
 | 
			
		||||
        return $model->get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function map($model): array
 | 
			
		||||
    {
 | 
			
		||||
        $model->bill_number = $model->bill->bill_number;
 | 
			
		||||
        $model->item_name = $model->item->name;
 | 
			
		||||
 | 
			
		||||
        return parent::map($model);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function fields(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'bill_id',
 | 
			
		||||
            'item_id',
 | 
			
		||||
            'name',
 | 
			
		||||
            'bill_number',
 | 
			
		||||
            'item_name',
 | 
			
		||||
            'quantity',
 | 
			
		||||
            'price',
 | 
			
		||||
            'total',
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ class BillTotals extends Export
 | 
			
		||||
{
 | 
			
		||||
    public function collection()
 | 
			
		||||
    {
 | 
			
		||||
        $model = Model::usingSearchString(request('search'));
 | 
			
		||||
        $model = Model::with(['bill'])->usingSearchString(request('search'));
 | 
			
		||||
 | 
			
		||||
        if (!empty($this->ids)) {
 | 
			
		||||
            $model->whereIn('bill_id', (array) $this->ids);
 | 
			
		||||
@@ -18,11 +18,17 @@ class BillTotals extends Export
 | 
			
		||||
        return $model->get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function map($model): array
 | 
			
		||||
    {
 | 
			
		||||
        $model->bill_number = $model->bill->bill_number;
 | 
			
		||||
 | 
			
		||||
        return parent::map($model);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function fields(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'bill_id',
 | 
			
		||||
            'bill_number',
 | 
			
		||||
            'code',
 | 
			
		||||
            'name',
 | 
			
		||||
            'amount',
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ class BillTransactions extends Export
 | 
			
		||||
{
 | 
			
		||||
    public function collection()
 | 
			
		||||
    {
 | 
			
		||||
        $model = Model::type('expense')->isDocument()->usingSearchString(request('search'));
 | 
			
		||||
        $model = Model::with(['account', 'category', 'contact', 'bill'])->type('expense')->isDocument()->usingSearchString(request('search'));
 | 
			
		||||
 | 
			
		||||
        if (!empty($this->ids)) {
 | 
			
		||||
            $model->whereIn('document_id', (array) $this->ids);
 | 
			
		||||
@@ -18,17 +18,27 @@ class BillTransactions extends Export
 | 
			
		||||
        return $model->get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function map($model): array
 | 
			
		||||
    {
 | 
			
		||||
        $model->bill_number = $model->bill->bill_number;
 | 
			
		||||
        $model->account_name = $model->account->name;
 | 
			
		||||
        $model->category_name = $model->category->name;
 | 
			
		||||
        $model->contact_email = $model->contact->email;
 | 
			
		||||
 | 
			
		||||
        return parent::map($model);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function fields(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'bill_number',
 | 
			
		||||
            'paid_at',
 | 
			
		||||
            'amount',
 | 
			
		||||
            'currency_code',
 | 
			
		||||
            'currency_rate',
 | 
			
		||||
            'account_id',
 | 
			
		||||
            'document_id',
 | 
			
		||||
            'contact_id',
 | 
			
		||||
            'category_id',
 | 
			
		||||
            'account_name',
 | 
			
		||||
            'contact_email',
 | 
			
		||||
            'category_name',
 | 
			
		||||
            'description',
 | 
			
		||||
            'payment_method',
 | 
			
		||||
            'reference',
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ class Bills extends Export
 | 
			
		||||
{
 | 
			
		||||
    public function collection()
 | 
			
		||||
    {
 | 
			
		||||
        $model = Model::usingSearchString(request('search'));
 | 
			
		||||
        $model = Model::with(['category'])->usingSearchString(request('search'));
 | 
			
		||||
 | 
			
		||||
        if (!empty($this->ids)) {
 | 
			
		||||
            $model->whereIn('id', (array) $this->ids);
 | 
			
		||||
@@ -18,6 +18,13 @@ class Bills extends Export
 | 
			
		||||
        return $model->get();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function map($model): array
 | 
			
		||||
    {
 | 
			
		||||
        $model->category_name = $model->category->name;
 | 
			
		||||
 | 
			
		||||
        return parent::map($model);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function fields(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
@@ -29,8 +36,7 @@ class Bills extends Export
 | 
			
		||||
            'amount',
 | 
			
		||||
            'currency_code',
 | 
			
		||||
            'currency_rate',
 | 
			
		||||
            'category_id',
 | 
			
		||||
            'contact_id',
 | 
			
		||||
            'category_name',
 | 
			
		||||
            'contact_name',
 | 
			
		||||
            'contact_email',
 | 
			
		||||
            'contact_tax_number',
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user