mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-06 06:54:37 -04:00
Ensure line item gateway fees are not cloned
This commit is contained in:
parent
e491231090
commit
c71d7ffeec
@ -107,6 +107,7 @@ class StoreCreditRequest extends Request
|
|||||||
$input = $this->decodePrimaryKeys($input);
|
$input = $this->decodePrimaryKeys($input);
|
||||||
|
|
||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
|
$input['line_items'] = $this->cleanFeeItems($input['line_items']);
|
||||||
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
||||||
|
|
||||||
if (array_key_exists('exchange_rate', $input) && is_null($input['exchange_rate'])) {
|
if (array_key_exists('exchange_rate', $input) && is_null($input['exchange_rate'])) {
|
||||||
|
@ -108,6 +108,7 @@ class StoreInvoiceRequest extends Request
|
|||||||
|
|
||||||
if (isset($input['line_items']) && is_array($input['line_items'])) {
|
if (isset($input['line_items']) && is_array($input['line_items'])) {
|
||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
|
$input['line_items'] = $this->cleanFeeItems($input['line_items']);
|
||||||
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
||||||
}
|
}
|
||||||
if(isset($input['partial']) && $input['partial'] == 0) {
|
if(isset($input['partial']) && $input['partial'] == 0) {
|
||||||
|
@ -95,6 +95,7 @@ class StorePurchaseOrderRequest extends Request
|
|||||||
|
|
||||||
if (isset($input['line_items']) && is_array($input['line_items'])) {
|
if (isset($input['line_items']) && is_array($input['line_items'])) {
|
||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
|
$input['line_items'] = $this->cleanFeeItems($input['line_items']);
|
||||||
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ class StoreQuoteRequest extends Request
|
|||||||
|
|
||||||
if (isset($input['line_items']) && is_array($input['line_items'])) {
|
if (isset($input['line_items']) && is_array($input['line_items'])) {
|
||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
|
$input['line_items'] = $this->cleanFeeItems($input['line_items']);
|
||||||
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
||||||
}
|
}
|
||||||
if(isset($input['partial']) && $input['partial'] == 0) {
|
if(isset($input['partial']) && $input['partial'] == 0) {
|
||||||
|
@ -148,6 +148,8 @@ class StoreRecurringInvoiceRequest extends Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
$input['line_items'] = isset($input['line_items']) ? $this->cleanItems($input['line_items']) : [];
|
||||||
|
$input['line_items'] = $this->cleanFeeItems($input['line_items']);
|
||||||
|
|
||||||
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
$input['amount'] = $this->entityTotalAmount($input['line_items']);
|
||||||
|
|
||||||
if (isset($input['auto_bill'])) {
|
if (isset($input['auto_bill'])) {
|
||||||
|
@ -148,6 +148,7 @@ class AutoBillInvoice extends AbstractService
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
nlog("Payment hash created => {$payment_hash->id}");
|
nlog("Payment hash created => {$payment_hash->id}");
|
||||||
|
$this->invoice->saveQuietly();
|
||||||
|
|
||||||
$payment = false;
|
$payment = false;
|
||||||
try {
|
try {
|
||||||
@ -162,6 +163,7 @@ class AutoBillInvoice extends AbstractService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->invoice = $this->invoice->fresh();
|
||||||
$this->invoice->auto_bill_tries += 1;
|
$this->invoice->auto_bill_tries += 1;
|
||||||
|
|
||||||
if ($this->invoice->auto_bill_tries == 3) {
|
if ($this->invoice->auto_bill_tries == 3) {
|
||||||
|
@ -34,6 +34,20 @@ trait CleanLineItems
|
|||||||
return $cleaned_items;
|
return $cleaned_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function cleanFeeItems($items): array
|
||||||
|
{
|
||||||
|
|
||||||
|
//ensure we never allow gateway fees to be cloned across to new entities
|
||||||
|
foreach ($items as $key => $value) {
|
||||||
|
if (in_array($value->type_id, ['3','4'])) {
|
||||||
|
unset($items[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $items;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets default values for the line_items.
|
* Sets default values for the line_items.
|
||||||
* @param $item
|
* @param $item
|
||||||
|
@ -73,8 +73,6 @@ class TaskStatusApiTest extends TestCase
|
|||||||
])->put('/api/v1/task_statuses/'.$task_status->hashed_id, $data);
|
])->put('/api/v1/task_statuses/'.$task_status->hashed_id, $data);
|
||||||
|
|
||||||
|
|
||||||
$xx = TaskStatus::where('company_id', $this->company->id)->pluck('status_order');
|
|
||||||
|
|
||||||
$t = TaskStatus::where('company_id', $this->company->id)->orderBy('status_order', 'asc')->first();
|
$t = TaskStatus::where('company_id', $this->company->id)->orderBy('status_order', 'asc')->first();
|
||||||
|
|
||||||
$this->assertEquals($id, $t->id);
|
$this->assertEquals($id, $t->id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user