mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Fixes for migrations
This commit is contained in:
parent
4b1aabbac7
commit
0991dbf8d7
@ -249,7 +249,7 @@ class MigrationController extends BaseController
|
||||
if ($checks['existing_company'] == true && $checks['force'] == false) {
|
||||
info('Migrating: Existing company without force. (CASE_01)');
|
||||
|
||||
MailRouter::dispatch(new ExistingMigration(), $company, $user);
|
||||
MailRouter::dispatch(new ExistingMigration(), $existing_company, $user);
|
||||
|
||||
return response()->json([
|
||||
'_id' => Str::uuid(),
|
||||
|
@ -150,9 +150,9 @@ class Import implements ShouldQueue
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
public $timeout = 86400;
|
||||
public $timeout = 864000;
|
||||
|
||||
public $backoff = 86430;
|
||||
// public $backoff = 86430;
|
||||
|
||||
// public $maxExceptions = 2;
|
||||
/**
|
||||
|
@ -53,11 +53,11 @@ class StartMigration implements ShouldQueue
|
||||
*/
|
||||
public $tries = 1;
|
||||
|
||||
public $timeout = 86400;
|
||||
public $timeout = 864000;
|
||||
|
||||
// public $maxExceptions = 2;
|
||||
|
||||
//public $backoff = 86430;
|
||||
public $backoff = 86430;
|
||||
|
||||
public function __construct($filepath, User $user, Company $company)
|
||||
{
|
||||
|
@ -102,13 +102,15 @@ class PaymentMigrationRepository extends BaseRepository
|
||||
/*Iterate through invoices and apply payments*/
|
||||
if (array_key_exists('invoices', $data) && is_array($data['invoices']) && count($data['invoices']) > 0) {
|
||||
$invoice_totals = array_sum(array_column($data['invoices'], 'amount'));
|
||||
$refund_totals = array_sum(array_column($data['invoices'], 'refunded'));
|
||||
|
||||
$invoices = Invoice::whereIn('id', array_column($data['invoices'], 'invoice_id'))->get();
|
||||
|
||||
$payment->invoices()->saveMany($invoices);
|
||||
|
||||
$payment->invoices->each(function ($inv) use ($invoice_totals) {
|
||||
$payment->invoices->each(function ($inv) use ($invoice_totals, $refund_totals) {
|
||||
$inv->pivot->amount = $invoice_totals;
|
||||
$inv->pivot->refunded = $refund_totals;
|
||||
$inv->pivot->save();
|
||||
});
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class PaymentRepository extends BaseRepository
|
||||
$this->processExchangeRates($data, $payment);
|
||||
|
||||
$is_existing_payment = false;
|
||||
$client = Client::find($data['client_id']);
|
||||
$client = Client::find($data['client_id'])->withTrashed();
|
||||
|
||||
/*We only update the paid to date ONCE per payment*/
|
||||
if (array_key_exists('invoices', $data) && is_array($data['invoices']) && count($data['invoices']) > 0) {
|
||||
@ -146,7 +146,7 @@ class PaymentRepository extends BaseRepository
|
||||
|
||||
//todo optimize into a single query
|
||||
foreach ($data['credits'] as $paid_credit) {
|
||||
$credit = Credit::find($this->decodePrimaryKey($paid_credit['credit_id']));
|
||||
$credit = Credit::find($this->decodePrimaryKey($paid_credit['credit_id']))->withTrashed();
|
||||
|
||||
if ($credit) {
|
||||
ApplyCreditPayment::dispatchNow($credit, $payment, $paid_credit['amount'], $credit->company);
|
||||
|
Loading…
Reference in New Issue
Block a user