From 8b77dc10db11fe354dfb76c929e738649644715e Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Thu, 28 Jan 2021 15:10:04 +0300 Subject: [PATCH 1/3] onCalculateTotal should be called with timeout --- resources/assets/js/views/common/documents.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index 890151636..6fd874846 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -309,7 +309,9 @@ const app = new Vue({ // invoice_item_checkbox_sample: [], }); - this.onCalculateTotal(); + setTimeout(function() { + this.onCalculateTotal(); + }.bind(this), 800); }, onSelectedTax(item_index) { From 128e63b48f3f853850c6162ae9ea47ba383aadc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20=C3=87ak=C4=B1rel?= Date: Thu, 28 Jan 2021 15:37:54 +0300 Subject: [PATCH 2/3] Fixed document_item_id required error when importing --- app/Imports/Purchases/Sheets/BillItemTaxes.php | 4 ++-- app/Imports/Sales/Sheets/InvoiceItemTaxes.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Imports/Purchases/Sheets/BillItemTaxes.php b/app/Imports/Purchases/Sheets/BillItemTaxes.php index ce40d346e..7f7ebb871 100644 --- a/app/Imports/Purchases/Sheets/BillItemTaxes.php +++ b/app/Imports/Purchases/Sheets/BillItemTaxes.php @@ -31,9 +31,9 @@ class BillItemTaxes extends Import $row['document_id'] = (int) Document::bill()->number($row['bill_number'])->pluck('id')->first(); - if (empty($row['bill_item_id']) && !empty($row['item_name'])) { + if (empty($row['document_item_id']) && !empty($row['item_name'])) { $item_id = Item::name($row['item_name'])->pluck('id')->first(); - $row['bill_item_id'] = DocumentItem::bill()->where('item_id', $item_id)->pluck('id')->first(); + $row['document_item_id'] = DocumentItem::bill()->where('item_id', $item_id)->pluck('id')->first(); } $row['tax_id'] = $this->getTaxId($row); diff --git a/app/Imports/Sales/Sheets/InvoiceItemTaxes.php b/app/Imports/Sales/Sheets/InvoiceItemTaxes.php index cb7ea7186..45dcfdbb8 100644 --- a/app/Imports/Sales/Sheets/InvoiceItemTaxes.php +++ b/app/Imports/Sales/Sheets/InvoiceItemTaxes.php @@ -31,9 +31,9 @@ class InvoiceItemTaxes extends Import $row['document_id'] = (int) Document::invoice()->number($row['invoice_number'])->pluck('id')->first(); - if (empty($row['invoice_item_id']) && !empty($row['item_name'])) { + if (empty($row['document_item_id']) && !empty($row['item_name'])) { $item_id = Item::name($row['item_name'])->pluck('id')->first(); - $row['invoice_item_id'] = DocumentItem::invoice()->where('item_id', $item_id)->pluck('id')->first(); + $row['document_item_id'] = DocumentItem::invoice()->where('item_id', $item_id)->pluck('id')->first(); } $row['tax_id'] = $this->getTaxId($row); From a031a6e5a5643a48c63549d96606016068698cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20=C3=87ak=C4=B1rel?= Date: Thu, 28 Jan 2021 15:50:45 +0300 Subject: [PATCH 3/3] refs #1734 Add try-catch to show the formatting error to the user --- app/Abstracts/Import.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Abstracts/Import.php b/app/Abstracts/Import.php index 775565c50..7cd59dbe8 100644 --- a/app/Abstracts/Import.php +++ b/app/Abstracts/Import.php @@ -4,19 +4,21 @@ namespace App\Abstracts; use App\Traits\Import as ImportHelper; use App\Utilities\Date; +use Carbon\Exceptions\InvalidFormatException; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; use Maatwebsite\Excel\Concerns\Importable; -use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\SkipsOnError; use Maatwebsite\Excel\Concerns\SkipsOnFailure; +use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\WithBatchInserts; use Maatwebsite\Excel\Concerns\WithChunkReading; use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Concerns\WithValidation; use Maatwebsite\Excel\Validators\Failure; -use Illuminate\Support\Facades\Validator; use PhpOffice\PhpSpreadsheet\Shared\Date as ExcelDate; abstract class Import implements ToModel, SkipsOnError, SkipsOnFailure, WithBatchInserts, WithChunkReading, WithHeadingRow, WithMapping, WithValidation @@ -45,7 +47,12 @@ abstract class Import implements ToModel, SkipsOnError, SkipsOnFailure, WithBatc continue; } - $row[$date_field] = Date::parse(ExcelDate::excelToDateTimeObject($row[$date_field]))->format('Y-m-d H:i:s'); + try { + $row[$date_field] = Date::parse(ExcelDate::excelToDateTimeObject($row[$date_field])) + ->format('Y-m-d H:i:s'); + } catch (InvalidFormatException | \Exception $e) { + Log::info($e->getMessage()); + } } return $row;