Skip to content

Commit

Permalink
Fixes for expense imports
Browse files Browse the repository at this point in the history
  • Loading branch information
turbo124 committed Oct 16, 2024
1 parent 34524f3 commit b90fb45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/Jobs/EDocument/ImportEDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function handle(): Expense

public function middleware()
{
return [new WithoutOverlapping($this->company->company_key)];
return [new WithoutOverlapping($this->company->company_key."_expense_import")];
}

public function failed($exception = null)
Expand All @@ -63,7 +63,6 @@ public function failed($exception = null)
}

$this->fail($exception); //manually fail - prevents future jobs with the same name from being discarded

config(['queue.failed.driver' => null]);
}
}
2 changes: 2 additions & 0 deletions app/Services/EDocument/Imports/ParseEDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function run(): Expense
return (new ZugferdEDocument($this->file, $this->company))->run();
} catch (\Throwable $e) {
nlog("Zugferd Exception: " . $e->getMessage());
break;
}
case ($extension == 'xml' || $mimetype == 'application/xml') && stristr($this->file->get(), "urn:cen.eu:en16931:2017"):
case ($extension == 'xml' || $mimetype == 'application/xml') && stristr($this->file->get(), "urn:oasis:names:specification:ubl"):
Expand All @@ -68,6 +69,7 @@ public function run(): Expense
}
catch(\Throwable $e){
nlog("UBL Import Exception: " . $e->getMessage());
break;
}
}

Expand Down
6 changes: 5 additions & 1 deletion app/Services/EDocument/Imports/ZugferdEDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
use Exception;
use App\Models\Company;
use App\Repositories\ExpenseRepository;
use App\Repositories\VendorContactRepository;
use App\Repositories\VendorRepository;
use horstoeko\zugferd\ZugferdDocumentReader;
use horstoeko\zugferdvisualizer\ZugferdVisualizer;
use horstoeko\zugferdvisualizer\renderer\ZugferdVisualizerLaravelRenderer;
Expand Down Expand Up @@ -139,7 +141,9 @@ public function run(): Expense
if ($country)
$vendor->country_id = $country->id;

$vendor->save();
$vendor_repo = new VendorRepository(new VendorContactRepository());
$vendor = $vendor_repo->save([], $vendor);

$expense->vendor_id = $vendor->id;
}
$expense->transaction_reference = $documentno;
Expand Down

0 comments on commit b90fb45

Please sign in to comment.