mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refining how expenses convert to products
This commit is contained in:
parent
a7f2d3354c
commit
bdeb062657
@ -296,7 +296,7 @@ class InvoiceController extends BaseController
|
||||
return [
|
||||
'data' => Input::old('data'),
|
||||
'account' => Auth::user()->account->load('country'),
|
||||
'products' => Product::scope()->with('default_tax_rate')->orderBy('id')->get(),
|
||||
'products' => Product::scope()->with('default_tax_rate')->orderBy('product_key')->get(),
|
||||
'taxRates' => TaxRate::scope()->orderBy('name')->get(),
|
||||
'currencies' => Cache::get('currencies'),
|
||||
'languages' => Cache::get('languages'),
|
||||
|
@ -402,6 +402,7 @@ class InvoiceRepository extends BaseRepository
|
||||
continue;
|
||||
}
|
||||
|
||||
$task = false;
|
||||
if (isset($item['task_public_id']) && $item['task_public_id']) {
|
||||
$task = Task::scope($item['task_public_id'])->where('invoice_id', '=', null)->firstOrFail();
|
||||
$task->invoice_id = $invoice->id;
|
||||
@ -409,6 +410,7 @@ class InvoiceRepository extends BaseRepository
|
||||
$task->save();
|
||||
}
|
||||
|
||||
$expense = false;
|
||||
if (isset($item['expense_public_id']) && $item['expense_public_id']) {
|
||||
$expense = Expense::scope($item['expense_public_id'])->where('invoice_id', '=', null)->firstOrFail();
|
||||
$expense->invoice_id = $invoice->id;
|
||||
@ -424,11 +426,8 @@ class InvoiceRepository extends BaseRepository
|
||||
$product = Product::createNew();
|
||||
$product->product_key = trim($item['product_key']);
|
||||
}
|
||||
|
||||
$product->notes = $invoice->has_tasks ? '' : $item['notes'];
|
||||
$product->notes = $invoice->has_expenses ? '' : $item['notes'];
|
||||
|
||||
$product->cost = $item['cost'];
|
||||
$product->notes = ($task || $expense) ? '' : $item['notes'];
|
||||
$product->cost = $expense ? 0 : $item['cost'];
|
||||
$product->save();
|
||||
}
|
||||
}
|
||||
|
@ -1130,4 +1130,5 @@ return array(
|
||||
'info' => 'Info',
|
||||
'imported_expenses' => 'Successfully created :count_vendors vendor(s) and :count_expenses expense(s)',
|
||||
|
||||
'iframe_url_help3' => 'Note: if you plan on accepting credit cards we strongly recommend having HTTPS enabled on your site.',
|
||||
);
|
||||
|
@ -96,6 +96,7 @@
|
||||
+ window.location.search.substring(1);
|
||||
</script></pre>
|
||||
<p>{{ trans('texts.iframe_url_help2') }}</p>
|
||||
<p><b>{{ trans('texts.iframe_url_help3') }}</b></p>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer" style="margin-top: 0px">
|
||||
|
@ -937,10 +937,15 @@
|
||||
var product = products[i];
|
||||
if (product.product_key == key) {
|
||||
var model = ko.dataFor(this);
|
||||
if (model.expense_public_id()) {
|
||||
return;
|
||||
}
|
||||
if (product.notes) {
|
||||
model.notes(product.notes);
|
||||
}
|
||||
model.cost(accounting.toFixed(product.cost,2));
|
||||
if (product.cost) {
|
||||
model.cost(accounting.toFixed(product.cost, 2));
|
||||
}
|
||||
if (!model.qty()) {
|
||||
model.qty(1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user