1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

More fixes

This commit is contained in:
Lars Kusch 2023-04-03 17:55:40 +02:00
parent 0e74d6e03d
commit 1c339cd208
5 changed files with 20 additions and 6 deletions

View File

@ -69,7 +69,7 @@ class CreateXInvoice implements ShouldQueue
->setDocumentInformation($invoice->number, "380", date_create($invoice->date), $invoice->client->getCurrencyCode())
->addDocumentNote($invoice->public_notes)
->setDocumentSupplyChainEvent(date_create($invoice->date))
->setDocumentSeller($company->name)
// ->setDocumentSeller($company->name)
->setDocumentSellerAddress($company->address1, "", "", $company->postal_code, $company->city, $company->country->country->iso_3166_2)
->setDocumentBuyer($client->name, $client->number)
->setDocumentBuyerAddress($client->address1, "", "", $client->postal_code, $client->city, $client->country->country->iso_3166_2)
@ -286,7 +286,7 @@ class CreateXInvoice implements ShouldQueue
if ($taxnet_3 > 0) {
$xrechnung->addDocumentTax($taxtype3, "VAT", $taxnet_3, $taxamount_3, $invoice->tax_rate3);
}
$xrechnung->writeFile(explode(".", $client->invoice_filepath($invoice->invitations->first()))[0] . "-xinvoice.xml");
$xrechnung->writeFile(explode(".", $client->xinvoice_filepath($invoice->invitations->first()))[0] . "-xinvoice.xml");
$filepath_pdf = $client->invoice_filepath($invoice->invitations->first());
$disk = config('filesystems.default');

View File

@ -732,6 +732,12 @@ class Client extends BaseModel implements HasLocalePreference
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/invoices/';
}
public function xinvoice_filepath($invitation)
{
$contact_key = $invitation->contact->contact_key;
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/xinvoice/';
}
public function quote_filepath($invitation)
{

View File

@ -38,7 +38,7 @@ class GetInvoiceXInvoice extends AbstractService
$invitation = $this->invoice->invitations->first();
}
$path = $this->invoice->client->invoice_filepath($invitation);
$path = $this->invoice->client->xinvoice_filepath($invitation);
$file_path = $path.$this->invoice->numberFormatter().'-xinvoice.xml';

View File

@ -19,6 +19,7 @@ use App\Libraries\Currency\Conversion\CurrencyApi;
use App\Models\CompanyGateway;
use App\Models\Expense;
use App\Models\Invoice;
use App\Models\InvoiceInvitation;
use App\Models\Payment;
use App\Models\Task;
use App\Utils\Ninja;
@ -448,7 +449,10 @@ class InvoiceService
if ($force) {
$this->invoice->invitations->each(function ($invitation) {
(new CreateEntityPdf($invitation))->handle();
(new CreateXInvoice($invitation))->handle();
if ($invitation instanceof InvoiceInvitation)
{
(new CreateXInvoice($invitation->invoice))->handle();
}
});
return $this;
@ -456,7 +460,10 @@ class InvoiceService
$this->invoice->invitations->each(function ($invitation) {
CreateEntityPdf::dispatch($invitation);
CreateXInvoice::dispatch($invitation);
if ($invitation instanceof InvoiceInvitation)
{
CreateXInvoice::dispatch($invitation->invoice);
}
});
} catch (\Exception $e) {
nlog('failed creating invoices in Touch PDF');

View File

@ -96,7 +96,7 @@ Route::group(['middleware' => ['auth:contact', 'locale', 'domain_db','check_clie
Route::resource('documents', App\Http\Controllers\ClientPortal\DocumentController::class)->only(['index', 'show']);
Route::get('subscriptions/{recurring_invoice}/plan_switch/{target}', [App\Http\Controllers\ClientPortal\SubscriptionPlanSwitchController::class, 'index'])->name('subscription.plan_switch');
Route::get('subscriptions/{recurring_invoice}', [SubscriptionController::class, 'show'])->middleware('portal_enabled')->name('subscriptions.show');
Route::get('subscriptions', [SubscriptionController::class, 'index'])->middleware('portal_enabled')->name('subscriptions.index');
@ -124,6 +124,7 @@ Route::group(['middleware' => ['invite_db'], 'prefix' => 'client', 'as' => 'clie
Route::get('credit/{invitation_key}', [App\Http\Controllers\ClientPortal\InvitationController::class, 'creditRouter']);
Route::get('recurring_invoice/{invitation_key}/download_pdf', [RecurringInvoiceController::class, 'downloadPdf'])->name('recurring_invoice.download_invitation_key');
Route::get('invoice/{invitation_key}/download_pdf', [InvoiceController::class, 'downloadPdf'])->name('invoice.download_invitation_key');
Route::get('invoice/{invitation_key}/download_xinvoice', [InvoiceController::class, 'downloadXInvoice'])->name('invoice.download_xinvoice');
Route::get('quote/{invitation_key}/download_pdf', [QuoteController::class, 'downloadPdf'])->name('quote.download_invitation_key');
Route::get('credit/{invitation_key}/download_pdf', [CreditController::class, 'downloadPdf'])->name('credit.download_invitation_key');
Route::get('{entity}/{invitation_key}/download', [App\Http\Controllers\ClientPortal\InvitationController::class, 'routerForDownload']);