mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 19:54:30 -04:00
Support importing line items taxes
This commit is contained in:
parent
9995dc7ab2
commit
94de590af2
@ -115,6 +115,8 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
'terms',
|
'terms',
|
||||||
'product',
|
'product',
|
||||||
'quantity',
|
'quantity',
|
||||||
|
'tax1',
|
||||||
|
'tax2',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +137,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
'notes' => 'notes',
|
'notes' => 'notes',
|
||||||
'product|item' => 'product',
|
'product|item' => 'product',
|
||||||
'quantity|qty' => 'quantity',
|
'quantity|qty' => 'quantity',
|
||||||
|
'tax' => 'tax1',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +156,30 @@ class BaseTransformer extends TransformerAbstract
|
|||||||
return isset($this->maps['countries2'][$name]) ? $this->maps['countries2'][$name] : null;
|
return isset($this->maps['countries2'][$name]) ? $this->maps['countries2'][$name] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function getTaxRate($name)
|
||||||
|
{
|
||||||
|
$name = strtolower(trim($name));
|
||||||
|
|
||||||
|
return isset($this->maps['tax_rates'][$name]) ? $this->maps['tax_rates'][$name] : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function getTaxName($name)
|
||||||
|
{
|
||||||
|
$name = strtolower(trim($name));
|
||||||
|
|
||||||
|
return isset($this->maps['tax_names'][$name]) ? $this->maps['tax_names'][$name] : '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
*
|
*
|
||||||
|
@ -41,6 +41,10 @@ class InvoiceTransformer extends BaseTransformer
|
|||||||
'notes' => $this->getString($data, 'notes') ?: $this->getProductNotes($this->getString($data, 'product')),
|
'notes' => $this->getString($data, 'notes') ?: $this->getProductNotes($this->getString($data, 'product')),
|
||||||
'cost' => $this->getFloat($data, 'amount') ?: $this->getProductCost($this->getString($data, 'product')),
|
'cost' => $this->getFloat($data, 'amount') ?: $this->getProductCost($this->getString($data, 'product')),
|
||||||
'qty' => $this->getFloat($data, 'quantity') ?: 1,
|
'qty' => $this->getFloat($data, 'quantity') ?: 1,
|
||||||
|
'tax_name1' => $this->getTaxName($this->getString($data, 'tax1')),
|
||||||
|
'tax_rate1' => $this->getTaxRate($this->getString($data, 'tax1')),
|
||||||
|
'tax_name2' => $this->getTaxName($this->getString($data, 'tax2')),
|
||||||
|
'tax_rate2' => $this->getTaxRate($this->getString($data, 'tax2')),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -13,6 +13,11 @@ class TaxRateRepository extends BaseRepository
|
|||||||
return 'App\Models\TaxRate';
|
return 'App\Models\TaxRate';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function all()
|
||||||
|
{
|
||||||
|
return TaxRate::scope()->get();
|
||||||
|
}
|
||||||
|
|
||||||
public function find($accountId)
|
public function find($accountId)
|
||||||
{
|
{
|
||||||
return DB::table('tax_rates')
|
return DB::table('tax_rates')
|
||||||
|
@ -19,6 +19,7 @@ use App\Ninja\Repositories\InvoiceRepository;
|
|||||||
use App\Ninja\Repositories\PaymentRepository;
|
use App\Ninja\Repositories\PaymentRepository;
|
||||||
use App\Ninja\Repositories\ProductRepository;
|
use App\Ninja\Repositories\ProductRepository;
|
||||||
use App\Ninja\Repositories\VendorRepository;
|
use App\Ninja\Repositories\VendorRepository;
|
||||||
|
use App\Ninja\Repositories\TaxRateRepository;
|
||||||
use App\Ninja\Serializers\ArraySerializer;
|
use App\Ninja\Serializers\ArraySerializer;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Cache;
|
use Cache;
|
||||||
@ -126,7 +127,8 @@ class ImportService
|
|||||||
ProductRepository $productRepo,
|
ProductRepository $productRepo,
|
||||||
ExpenseRepository $expenseRepo,
|
ExpenseRepository $expenseRepo,
|
||||||
VendorRepository $vendorRepo,
|
VendorRepository $vendorRepo,
|
||||||
ExpenseCategoryRepository $expenseCategoryRepo
|
ExpenseCategoryRepository $expenseCategoryRepo,
|
||||||
|
TaxRateRepository $taxRateRepository
|
||||||
) {
|
) {
|
||||||
$this->fractal = $manager;
|
$this->fractal = $manager;
|
||||||
$this->fractal->setSerializer(new ArraySerializer());
|
$this->fractal->setSerializer(new ArraySerializer());
|
||||||
@ -139,6 +141,7 @@ class ImportService
|
|||||||
$this->expenseRepo = $expenseRepo;
|
$this->expenseRepo = $expenseRepo;
|
||||||
$this->vendorRepo = $vendorRepo;
|
$this->vendorRepo = $vendorRepo;
|
||||||
$this->expenseCategoryRepo = $expenseCategoryRepo;
|
$this->expenseCategoryRepo = $expenseCategoryRepo;
|
||||||
|
$this->taxRateRepository = $taxRateRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -849,6 +852,8 @@ class ImportService
|
|||||||
'invoice_ids' => [],
|
'invoice_ids' => [],
|
||||||
'vendors' => [],
|
'vendors' => [],
|
||||||
'expense_categories' => [],
|
'expense_categories' => [],
|
||||||
|
'tax_rates' => [],
|
||||||
|
'tax_names' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
$clients = $this->clientRepo->all();
|
$clients = $this->clientRepo->all();
|
||||||
@ -886,6 +891,13 @@ class ImportService
|
|||||||
foreach ($expenseCaegories as $category) {
|
foreach ($expenseCaegories as $category) {
|
||||||
$this->addExpenseCategoryToMaps($category);
|
$this->addExpenseCategoryToMaps($category);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$taxRates = $this->taxRateRepository->all();
|
||||||
|
foreach ($taxRates as $taxRate) {
|
||||||
|
$name = trim(strtolower($taxRate->name));
|
||||||
|
$this->maps['tax_rates'][$name] = $taxRate->rate;
|
||||||
|
$this->maps['tax_names'][$name] = $taxRate->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2389,6 +2389,8 @@ $LANG = array(
|
|||||||
'currency_peruvian_sol' => 'Peruvian Sol',
|
'currency_peruvian_sol' => 'Peruvian Sol',
|
||||||
|
|
||||||
'use_english_version' => 'Make sure to use the English version of the files.<br/>We use the column headers to match the fields.',
|
'use_english_version' => 'Make sure to use the English version of the files.<br/>We use the column headers to match the fields.',
|
||||||
|
'tax1' => 'First Tax',
|
||||||
|
'tax2' => 'Second Tax',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user