mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Reorder action on invoices after payment
This commit is contained in:
parent
2e19d1e4a9
commit
396540a2f1
@ -794,7 +794,6 @@ class CompanyImport implements ShouldQueue
|
|||||||
private function import_expenses()
|
private function import_expenses()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$this->genericImport(Expense::class,
|
$this->genericImport(Expense::class,
|
||||||
['assigned_user_id', 'user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'project_id','vendor_id','recurring_expense_id'],
|
['assigned_user_id', 'user_id', 'client_id', 'company_id', 'id', 'hashed_id', 'project_id','vendor_id','recurring_expense_id'],
|
||||||
[
|
[
|
||||||
@ -1292,8 +1291,8 @@ class CompanyImport implements ShouldQueue
|
|||||||
$class::unguard();
|
$class::unguard();
|
||||||
$x = 0;
|
$x = 0;
|
||||||
foreach((object)$this->getObject($object_property) as $obj)
|
foreach((object)$this->getObject($object_property) as $obj)
|
||||||
// foreach($this->backup_file->{$object_property} as $obj)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Remove unwanted keys*/
|
/* Remove unwanted keys*/
|
||||||
$obj_array = (array)$obj;
|
$obj_array = (array)$obj;
|
||||||
foreach($unset as $un){
|
foreach($unset as $un){
|
||||||
@ -1322,16 +1321,26 @@ class CompanyImport implements ShouldQueue
|
|||||||
$obj_array['webhook_configuration'] = (array)$obj_array['webhook_configuration'];
|
$obj_array['webhook_configuration'] = (array)$obj_array['webhook_configuration'];
|
||||||
$obj_array['recurring_product_ids'] = '';
|
$obj_array['recurring_product_ids'] = '';
|
||||||
$obj_array['product_ids'] = '';
|
$obj_array['product_ids'] = '';
|
||||||
nlog($obj_array);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expenses that don't have a number will not be inserted - so need to override here*/
|
/* Expenses that don't have a number will not be inserted - so need to override here*/
|
||||||
if($class == 'App\Models\Expense' && is_null($obj->{$match_key})){
|
if($class == 'App\Models\Expense' && is_null($obj->{$match_key})){
|
||||||
$new_obj = new Expense();
|
$new_obj = new Expense();
|
||||||
$new_obj->company_id = $this->company->id;
|
$new_obj->company_id = $this->company->id;
|
||||||
|
|
||||||
|
if(array_key_exists('number', $obj_array) && !$this->checkNumberAvailable(Expense::class, $new_obj, $obj_array['number'])){
|
||||||
|
nlog(" found match - unsetting ".$obj_array['number']);
|
||||||
|
unset($obj_array['number']);
|
||||||
|
}
|
||||||
|
|
||||||
$new_obj->fill($obj_array);
|
$new_obj->fill($obj_array);
|
||||||
$new_obj->save(['timestamps' => false]);
|
$new_obj->save(['timestamps' => false]);
|
||||||
$new_obj->number = $this->getNextExpenseNumber($new_obj);
|
|
||||||
|
if(!$new_obj->number){
|
||||||
|
$new_obj->number = $this->getNextExpenseNumber($new_obj);
|
||||||
|
nlog($new_obj->number . "setting new expenses number");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif($class == 'App\Models\Invoice' && is_null($obj->{$match_key})){
|
elseif($class == 'App\Models\Invoice' && is_null($obj->{$match_key})){
|
||||||
$new_obj = new Invoice();
|
$new_obj = new Invoice();
|
||||||
|
@ -256,13 +256,13 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
$this->payment_hash->payment_id = $payment->id;
|
$this->payment_hash->payment_id = $payment->id;
|
||||||
$this->payment_hash->save();
|
$this->payment_hash->save();
|
||||||
|
|
||||||
$this->attachInvoices($payment, $this->payment_hash);
|
|
||||||
|
|
||||||
if($this->payment_hash->credits_total() > 0)
|
if($this->payment_hash->credits_total() > 0)
|
||||||
$payment = $payment->service()->applyCredits($this->payment_hash)->save();
|
$payment = $payment->service()->applyCredits($this->payment_hash)->save();
|
||||||
|
|
||||||
$payment->service()->updateInvoicePayment($this->payment_hash);
|
$payment->service()->updateInvoicePayment($this->payment_hash);
|
||||||
|
|
||||||
|
$this->attachInvoices($payment, $this->payment_hash);
|
||||||
|
|
||||||
event('eloquent.created: App\Models\Payment', $payment);
|
event('eloquent.created: App\Models\Payment', $payment);
|
||||||
|
|
||||||
if ($this->client->getSetting('client_online_payment_notification') && in_array($status, [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING]))
|
if ($this->client->getSetting('client_online_payment_notification') && in_array($status, [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user