Item import re-factoring for multiple tax feature
This commit is contained in:
		
							
								
								
									
										34
									
								
								app/Imports/Common/Sheets/ItemTaxes.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								app/Imports/Common/Sheets/ItemTaxes.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Imports\Sales\Sheets;
 | 
			
		||||
 | 
			
		||||
use App\Abstracts\Import;
 | 
			
		||||
use App\Http\Requests\Common\ItemTax as Request;
 | 
			
		||||
use App\Models\Common\Item;
 | 
			
		||||
use App\Models\Sale\ItemTax as Model;
 | 
			
		||||
 | 
			
		||||
class InvoiceItemTaxes extends Import
 | 
			
		||||
{
 | 
			
		||||
    public function model(array $row)
 | 
			
		||||
    {
 | 
			
		||||
        return new Model($row);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function map($row): array
 | 
			
		||||
    {
 | 
			
		||||
        $row = parent::map($row);
 | 
			
		||||
 | 
			
		||||
        $row['tax_id'] = $this->getTaxId($row);
 | 
			
		||||
 | 
			
		||||
        if (empty($row['name']) && !empty($row['item_name'])) {
 | 
			
		||||
            $row['name'] = $row['item_name'];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $row;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function rules(): array
 | 
			
		||||
    {
 | 
			
		||||
        return (new Request())->rules();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user