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 [
|
return [
|
||||||
'data' => Input::old('data'),
|
'data' => Input::old('data'),
|
||||||
'account' => Auth::user()->account->load('country'),
|
'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(),
|
'taxRates' => TaxRate::scope()->orderBy('name')->get(),
|
||||||
'currencies' => Cache::get('currencies'),
|
'currencies' => Cache::get('currencies'),
|
||||||
'languages' => Cache::get('languages'),
|
'languages' => Cache::get('languages'),
|
||||||
|
@ -402,6 +402,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$task = false;
|
||||||
if (isset($item['task_public_id']) && $item['task_public_id']) {
|
if (isset($item['task_public_id']) && $item['task_public_id']) {
|
||||||
$task = Task::scope($item['task_public_id'])->where('invoice_id', '=', null)->firstOrFail();
|
$task = Task::scope($item['task_public_id'])->where('invoice_id', '=', null)->firstOrFail();
|
||||||
$task->invoice_id = $invoice->id;
|
$task->invoice_id = $invoice->id;
|
||||||
@ -409,6 +410,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$task->save();
|
$task->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$expense = false;
|
||||||
if (isset($item['expense_public_id']) && $item['expense_public_id']) {
|
if (isset($item['expense_public_id']) && $item['expense_public_id']) {
|
||||||
$expense = Expense::scope($item['expense_public_id'])->where('invoice_id', '=', null)->firstOrFail();
|
$expense = Expense::scope($item['expense_public_id'])->where('invoice_id', '=', null)->firstOrFail();
|
||||||
$expense->invoice_id = $invoice->id;
|
$expense->invoice_id = $invoice->id;
|
||||||
@ -424,11 +426,8 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$product = Product::createNew();
|
$product = Product::createNew();
|
||||||
$product->product_key = trim($item['product_key']);
|
$product->product_key = trim($item['product_key']);
|
||||||
}
|
}
|
||||||
|
$product->notes = ($task || $expense) ? '' : $item['notes'];
|
||||||
$product->notes = $invoice->has_tasks ? '' : $item['notes'];
|
$product->cost = $expense ? 0 : $item['cost'];
|
||||||
$product->notes = $invoice->has_expenses ? '' : $item['notes'];
|
|
||||||
|
|
||||||
$product->cost = $item['cost'];
|
|
||||||
$product->save();
|
$product->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1130,4 +1130,5 @@ return array(
|
|||||||
'info' => 'Info',
|
'info' => 'Info',
|
||||||
'imported_expenses' => 'Successfully created :count_vendors vendor(s) and :count_expenses expense(s)',
|
'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);
|
+ window.location.search.substring(1);
|
||||||
</script></pre>
|
</script></pre>
|
||||||
<p>{{ trans('texts.iframe_url_help2') }}</p>
|
<p>{{ trans('texts.iframe_url_help2') }}</p>
|
||||||
|
<p><b>{{ trans('texts.iframe_url_help3') }}</b></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-footer" style="margin-top: 0px">
|
<div class="modal-footer" style="margin-top: 0px">
|
||||||
|
@ -937,10 +937,15 @@
|
|||||||
var product = products[i];
|
var product = products[i];
|
||||||
if (product.product_key == key) {
|
if (product.product_key == key) {
|
||||||
var model = ko.dataFor(this);
|
var model = ko.dataFor(this);
|
||||||
|
if (model.expense_public_id()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (product.notes) {
|
if (product.notes) {
|
||||||
model.notes(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()) {
|
if (!model.qty()) {
|
||||||
model.qty(1);
|
model.qty(1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user