mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 17:34:30 -04:00
Fixes for gateway fees
This commit is contained in:
parent
0f63ea782f
commit
c68bbf252c
@ -622,32 +622,34 @@ class InvoiceRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($productKey = trim($item['product_key'])) {
|
if (Auth::check()) {
|
||||||
if ($account->update_products
|
if ($productKey = trim($item['product_key'])) {
|
||||||
&& ! $invoice->has_tasks
|
if ($account->update_products
|
||||||
&& ! $invoice->has_expenses
|
&& ! $invoice->has_tasks
|
||||||
&& $productKey != trans('texts.surcharge')
|
&& ! $invoice->has_expenses
|
||||||
) {
|
&& $productKey != trans('texts.surcharge')
|
||||||
$product = Product::findProductByKey($productKey);
|
) {
|
||||||
if (! $product) {
|
$product = Product::findProductByKey($productKey);
|
||||||
if (Auth::user()->can('create', ENTITY_PRODUCT)) {
|
if (! $product) {
|
||||||
$product = Product::createNew();
|
if (Auth::user()->can('create', ENTITY_PRODUCT)) {
|
||||||
$product->product_key = trim($item['product_key']);
|
$product = Product::createNew();
|
||||||
} else {
|
$product->product_key = trim($item['product_key']);
|
||||||
$product = null;
|
} else {
|
||||||
|
$product = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($product && (Auth::user()->can('edit', $product))) {
|
||||||
|
$product->notes = ($task || $expense) ? '' : $item['notes'];
|
||||||
|
$product->cost = $expense ? 0 : $item['cost'];
|
||||||
|
$product->custom_value1 = isset($item['custom_value1']) ? $item['custom_value1'] : null;
|
||||||
|
$product->custom_value2 = isset($item['custom_value2']) ? $item['custom_value2'] : null;
|
||||||
|
$product->save();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ($product && (Auth::user()->can('edit', $product))) {
|
|
||||||
$product->notes = ($task || $expense) ? '' : $item['notes'];
|
|
||||||
$product->cost = $expense ? 0 : $item['cost'];
|
|
||||||
$product->custom_value1 = isset($item['custom_value1']) ? $item['custom_value1'] : null;
|
|
||||||
$product->custom_value2 = isset($item['custom_value2']) ? $item['custom_value2'] : null;
|
|
||||||
$product->save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoiceItem = InvoiceItem::createNew();
|
$invoiceItem = InvoiceItem::createNew($invoice);
|
||||||
$invoiceItem->fill($item);
|
$invoiceItem->fill($item);
|
||||||
$invoiceItem->product_id = isset($product) ? $product->id : null;
|
$invoiceItem->product_id = isset($product) ? $product->id : null;
|
||||||
$invoiceItem->product_key = isset($item['product_key']) ? (trim($invoice->is_recurring ? $item['product_key'] : Utils::processVariables($item['product_key']))) : '';
|
$invoiceItem->product_key = isset($item['product_key']) ? (trim($invoice->is_recurring ? $item['product_key'] : Utils::processVariables($item['product_key']))) : '';
|
||||||
@ -1043,6 +1045,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$data = $invoice->toArray();
|
$data = $invoice->toArray();
|
||||||
$data[$location] = 0;
|
$data[$location] = 0;
|
||||||
$this->save($data, $invoice);
|
$this->save($data, $invoice);
|
||||||
|
$invoice->load('invoice_items');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user