mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 17:54:30 -04:00
Fixes for import / migrartions
This commit is contained in:
parent
507367f430
commit
6681b4fbfe
@ -315,7 +315,7 @@ class CheckData extends Command
|
||||
$total_invoice_payments += $credit_total_applied;
|
||||
} //todo this is contentious
|
||||
|
||||
nlog("total invoice payments = {$total_invoice_payments} with client paid to date of of {$client->paid_to_date}");
|
||||
// nlog("total invoice payments = {$total_invoice_payments} with client paid to date of of {$client->paid_to_date}");
|
||||
|
||||
if (round($total_invoice_payments, 2) != round($client->paid_to_date, 2)) {
|
||||
$wrong_paid_to_dates++;
|
||||
|
@ -238,7 +238,7 @@ class InvoiceItemSum
|
||||
|
||||
$item_tax += $item_tax_rate1_total;
|
||||
|
||||
if ($item_tax_rate1_total > 0) {
|
||||
if ($item_tax_rate1_total != 0) {
|
||||
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ class InvoiceItemSum
|
||||
|
||||
$item_tax += $item_tax_rate2_total;
|
||||
|
||||
if ($item_tax_rate2_total > 0) {
|
||||
if ($item_tax_rate2_total != 0) {
|
||||
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ class InvoiceItemSum
|
||||
|
||||
$item_tax += $item_tax_rate3_total;
|
||||
|
||||
if ($item_tax_rate3_total > 0) {
|
||||
if ($item_tax_rate3_total != 0) {
|
||||
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ class InvoiceItemSumInclusive
|
||||
|
||||
$item_tax += $item_tax_rate1_total;
|
||||
|
||||
if ($item_tax_rate1_total > 0) {
|
||||
if ($item_tax_rate1_total != 0) {
|
||||
$this->groupTax($this->item->tax_name1, $this->item->tax_rate1, $item_tax_rate1_total);
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ class InvoiceItemSumInclusive
|
||||
|
||||
$item_tax += $item_tax_rate2_total;
|
||||
|
||||
if ($item_tax_rate2_total > 0) {
|
||||
if ($item_tax_rate2_total != 0) {
|
||||
$this->groupTax($this->item->tax_name2, $this->item->tax_rate2, $item_tax_rate2_total);
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ class InvoiceItemSumInclusive
|
||||
|
||||
$item_tax += $item_tax_rate3_total;
|
||||
|
||||
if ($item_tax_rate3_total > 0) {
|
||||
if ($item_tax_rate3_total != 0) {
|
||||
$this->groupTax($this->item->tax_name3, $this->item->tax_rate3, $item_tax_rate3_total);
|
||||
}
|
||||
}
|
||||
|
@ -932,6 +932,11 @@ class Import implements ShouldQueue
|
||||
],
|
||||
];
|
||||
|
||||
if(in_array($payment->status_id, [Payment::STATUS_REFUNDED, Payment::STATUS_PARTIALLY_REFUNDED])) {
|
||||
$this->processPaymentRefund($payment);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Payment::reguard();
|
||||
@ -941,6 +946,24 @@ class Import implements ShouldQueue
|
||||
$payment_repository = null;
|
||||
}
|
||||
|
||||
private function processPaymentRefund($payment)
|
||||
{
|
||||
$invoices = $payment->invoices()->get();
|
||||
|
||||
$invoices->each(function ($invoice) use($payment) {
|
||||
|
||||
if ($payment->refunded > 0 && in_array($invoice->status_id, [Invoice::STATUS_SENT])) {
|
||||
|
||||
$invoice->service()
|
||||
->updateBalance($payment->refunded)
|
||||
->updatePaidToDate($payment->refunded*-1)
|
||||
->updateStatus()
|
||||
->save();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private function updatePaymentForStatus($payment, $status_id) :Payment
|
||||
{
|
||||
// define('PAYMENT_STATUS_PENDING', 1);
|
||||
|
@ -92,6 +92,7 @@ class PaymentMigrationRepository extends BaseRepository
|
||||
}
|
||||
|
||||
$payment->status_id = $data['status_id'];
|
||||
$payment->refunded = $data['refunded'];
|
||||
|
||||
if($payment->status_id == Payment::STATUS_CANCELLED)
|
||||
$payment->is_deleted = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user