mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Renamed to e_invoice
This commit is contained in:
parent
24b2993198
commit
81b5c8783e
@ -175,8 +175,8 @@ class SendRemindersCron extends Command
|
||||
$invoice->calc()->getInvoice()->save();
|
||||
$invoice->fresh();
|
||||
$invoice->service()->deletePdf()->save();
|
||||
if ($invoice->company->use_xinvoice){
|
||||
$invoice->service()->deleteXInvoice()->save();
|
||||
if ($invoice->company->enable_e_invoice){
|
||||
$invoice->service()->deleteEInvoice()->save();
|
||||
}
|
||||
|
||||
/* Refresh the client here to ensure the balance is fresh */
|
||||
|
@ -903,7 +903,7 @@ class InvoiceController extends BaseController
|
||||
* @param $invitation_key
|
||||
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||
*/
|
||||
public function downloadXInvoice($invitation_key)
|
||||
public function downloadEInvoice($invitation_key)
|
||||
{
|
||||
$invitation = $this->invoice_repo->getInvitationByKey($invitation_key);
|
||||
|
||||
@ -914,7 +914,7 @@ class InvoiceController extends BaseController
|
||||
$contact = $invitation->contact;
|
||||
$invoice = $invitation->invoice;
|
||||
|
||||
$file = $invoice->service()->getXInvoice($contact);
|
||||
$file = $invoice->service()->getEInvoice($contact);
|
||||
|
||||
$headers = ['Content-Type' => 'application/xml'];
|
||||
|
||||
|
@ -212,7 +212,7 @@ class CreateEntityPdf implements ShouldQueue
|
||||
throw new FilePermissionsFailure($e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($this->entity_string == "invoice" && $this->company->use_xinvoice){
|
||||
if ($this->entity_string == "invoice" && $this->company->enable_e_invoice){
|
||||
(new CreateXInvoice($this->entity, true))->handle();
|
||||
}
|
||||
$this->invitation = null;
|
||||
|
@ -43,7 +43,7 @@ class CreateXInvoice implements ShouldQueue
|
||||
$company = $invoice->company;
|
||||
$client = $invoice->client;
|
||||
$profile = "";
|
||||
switch ($company->xinvoice_type) {
|
||||
switch ($company->e_invoice_type) {
|
||||
case "EN16931":
|
||||
$profile = ZugferdProfiles::PROFILE_EN16931;
|
||||
break;
|
||||
@ -79,7 +79,7 @@ class CreateXInvoice implements ShouldQueue
|
||||
->setDocumentSellerContact($invoice->user->first_name." ".$invoice->user->last_name, "", $invoice->user->phone, "", $invoice->user->email)
|
||||
->setDocumentBuyer($client->name, $client->number)
|
||||
->setDocumentBuyerAddress($client->address1, "", "", $client->postal_code, $client->city, $client->country->iso_3166_2)
|
||||
->setDocumentBuyerReference($client->leitweg_id)
|
||||
->setDocumentBuyerReference($client->routing_id)
|
||||
->setDocumentBuyerContact($client->primary_contact()->first()->first_name . " " . $client->primary_contact()->first()->last_name, "", $client->primary_contact()->first()->phone, "", $client->primary_contact()->first()->email)
|
||||
->setDocumentShipToAddress($client->shipping_address1, $client->shipping_address2, "", $client->shipping_postal_code, $client->shipping_city, $client->shipping_country->iso_3166_2, $client->shipping_state)
|
||||
->addDocumentPaymentTerm(ctrans("texts.xinvoice_payable", ['payeddue' => date_create($invoice->date)->diff(date_create($invoice->due_date))->format("%d"), 'paydate' => $invoice->due_date]));
|
||||
@ -89,7 +89,7 @@ class CreateXInvoice implements ShouldQueue
|
||||
if (!empty($invoice->po_number)) {
|
||||
$xrechnung->setDocumentBuyerOrderReferencedDocument($invoice->po_number);
|
||||
}
|
||||
if (empty($client->leitweg_id)){
|
||||
if (empty($client->routing_id)){
|
||||
$xrechnung->setDocumentBuyerReference(ctrans("texts.xinvoice_no_buyers_reference"));
|
||||
}
|
||||
$xrechnung->addDocumentPaymentMean(68, ctrans("texts.xinvoice_online_payment"));
|
||||
@ -170,10 +170,10 @@ class CreateXInvoice implements ShouldQueue
|
||||
}
|
||||
|
||||
$disk = config('filesystems.default');
|
||||
if (!Storage::exists($client->xinvoice_filepath($invoice->invitations->first()))) {
|
||||
Storage::makeDirectory($client->xinvoice_filepath($invoice->invitations->first()));
|
||||
if (!Storage::exists($client->e_invoice_filepath($invoice->invitations->first()))) {
|
||||
Storage::makeDirectory($client->e_invoice_filepath($invoice->invitations->first()));
|
||||
}
|
||||
$xrechnung->writeFile(Storage::disk($disk)->path($client->xinvoice_filepath($invoice->invitations->first()) . $invoice->getFileName("xml")));
|
||||
$xrechnung->writeFile(Storage::disk($disk)->path($client->e_invoice_filepath($invoice->invitations->first()) . $invoice->getFileName("xml")));
|
||||
// The validity can be checked using https://portal3.gefeg.com/invoice/validation
|
||||
|
||||
if ($this->alterpdf) {
|
||||
@ -192,7 +192,7 @@ class CreateXInvoice implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
return $client->xinvoice_filepath($invoice->invitations->first()) . $invoice->getFileName("xml");
|
||||
return $client->e_invoice_filepath($invoice->invitations->first()) . $invoice->getFileName("xml");
|
||||
}
|
||||
|
||||
private function getTaxType($name, Invoice $invoice): string
|
||||
|
@ -41,7 +41,7 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property string|null $client_hash
|
||||
* @property string|null $logo
|
||||
* @property string|null $phone
|
||||
* @property string|null leitweg_id
|
||||
* @property string|null routing_id
|
||||
* @property string $balance
|
||||
* @property string $paid_to_date
|
||||
* @property string $credit_balance
|
||||
@ -363,7 +363,7 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
'public_notes',
|
||||
'phone',
|
||||
'number',
|
||||
'leitweg_id',
|
||||
'routing_id',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
@ -413,7 +413,7 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
'id_number',
|
||||
'public_notes',
|
||||
'phone',
|
||||
'leitweg_id',
|
||||
'routing_id',
|
||||
];
|
||||
|
||||
// public function scopeExclude($query)
|
||||
@ -875,11 +875,11 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
|
||||
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/invoices/';
|
||||
}
|
||||
public function xinvoice_filepath($invitation)
|
||||
public function e_invoice_filepath($invitation)
|
||||
{
|
||||
$contact_key = $invitation->contact->contact_key;
|
||||
|
||||
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/xinvoice/';
|
||||
return $this->company->company_key.'/'.$this->client_hash.'/'.$contact_key.'/e_invoice/';
|
||||
}
|
||||
|
||||
public function quote_filepath($invitation)
|
||||
|
@ -97,8 +97,8 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property int $stock_notification
|
||||
* @property string|null $matomo_url
|
||||
* @property int|null $matomo_id
|
||||
* @property bool $use_xinvoice
|
||||
* @property string $xinvoice_type
|
||||
* @property bool $enable_e_invoice
|
||||
* @property string $e_invoice_type
|
||||
* @property int $enabled_expense_tax_rates
|
||||
* @property int $invoice_task_project
|
||||
* @property int $report_include_deleted
|
||||
@ -746,8 +746,8 @@ class Company extends BaseModel
|
||||
'google_analytics_key',
|
||||
'matomo_url',
|
||||
'matomo_id',
|
||||
'use_xinvoice',
|
||||
'xinvoice_type',
|
||||
'enable_e_invoice',
|
||||
'e_invoice_type',
|
||||
'client_can_register',
|
||||
'enable_shop_api',
|
||||
'invoice_task_timelog',
|
||||
@ -825,7 +825,7 @@ class Company extends BaseModel
|
||||
|
||||
public function refreshTaxData()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function documents()
|
||||
|
@ -267,7 +267,7 @@ class EmailDefaults
|
||||
return $this;
|
||||
// return $this->email->email_object->cc;
|
||||
// return [
|
||||
|
||||
|
||||
// ];
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ class EmailDefaults
|
||||
$this->email->email_object->entity instanceof Quote ||
|
||||
$this->email->email_object->entity instanceof Credit)) {
|
||||
$pdf = ((new CreateRawPdf($this->email->email_object->invitation, $this->email->company->db))->handle());
|
||||
if ($this->email->email_object->company->use_xinvoice && $this->email->email_object->entity instanceof Invoice) {
|
||||
if ($this->email->email_object->company->enable_e_invoice && $this->email->email_object->entity instanceof Invoice) {
|
||||
$tempfile = tmpfile();
|
||||
file_put_contents(stream_get_meta_data($tempfile)['uri'], $pdf);
|
||||
$xinvoice_path = (new CreateXInvoice($this->email->email_object->entity, true, stream_get_meta_data($tempfile)['uri']))->handle();
|
||||
@ -319,10 +319,10 @@ class EmailDefaults
|
||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($ubl_string), 'name' => $this->email->email_object->entity->getFileName('xml')]]);
|
||||
}
|
||||
}
|
||||
/** XInvoice xml file */
|
||||
if ($this->email->email_object->company->use_xinvoice && $this->email->email_object->entity instanceof Invoice) {
|
||||
/** E-Invoice xml file */
|
||||
if ($this->email->email_object->company->enable_e_invoice && $this->email->email_object->entity instanceof Invoice) {
|
||||
$xinvoice_path = (new GetInvoiceXInvoice($this->email->email_object->entity))->run();
|
||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode(file_get_contents($xinvoice_path)), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-xinvoice.xml"]]);
|
||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode(file_get_contents($xinvoice_path)), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-e_invoice.xml"]]);
|
||||
}
|
||||
|
||||
if (!$this->email->email_object->settings->document_email_attachment || !$this->email->company->account->hasFeature(Account::FEATURE_DOCUMENTS)) {
|
||||
|
@ -38,7 +38,7 @@ class GetInvoiceXInvoice extends AbstractService
|
||||
$invitation = $this->invoice->invitations->first();
|
||||
}
|
||||
|
||||
$file_path = $this->invoice->client->xinvoice_filepath($this->invoice->invitations->first()). $this->invoice->getFileName("xml");
|
||||
$file_path = $this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()). $this->invoice->getFileName("xml");
|
||||
|
||||
// $disk = 'public';
|
||||
$disk = config('filesystems.default');
|
||||
|
@ -186,7 +186,7 @@ class InvoiceService
|
||||
return (new GenerateDeliveryNote($invoice, $contact))->run();
|
||||
}
|
||||
|
||||
public function getXInvoice($contact = null)
|
||||
public function getEInvoice($contact = null)
|
||||
{
|
||||
return (new GetInvoiceXInvoice($this->invoice, $contact))->run();
|
||||
}
|
||||
@ -358,18 +358,18 @@ class InvoiceService
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function deleteXInvoice()
|
||||
public function deleteEInvoice()
|
||||
{
|
||||
$this->invoice->load('invitations');
|
||||
|
||||
$this->invoice->invitations->each(function ($invitation) {
|
||||
try {
|
||||
if (Storage::disk(config('filesystems.default'))->exists($this->invoice->client->xinvoice_filepath($invitation).$this->invoice->getFileName("xml"))) {
|
||||
Storage::disk(config('filesystems.default'))->delete($this->invoice->client->xinvoice_filepath($invitation).$this->invoice->getFileName("xml"));
|
||||
if (Storage::disk(config('filesystems.default'))->exists($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"))) {
|
||||
Storage::disk(config('filesystems.default'))->delete($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"));
|
||||
}
|
||||
|
||||
if (Ninja::isHosted() && Storage::disk('public')->exists($this->invoice->client->invoice_filepath($invitation).$this->invoice->getFileName("xml"))) {
|
||||
Storage::disk('public')->delete($this->invoice->client->invoice_filepath($invitation).$this->invoice->getFileName("xml"));
|
||||
if (Ninja::isHosted() && Storage::disk('public')->exists($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"))) {
|
||||
Storage::disk('public')->delete($this->invoice->client->e_invoice_filepath($invitation).$this->invoice->getFileName("xml"));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
nlog($e->getMessage());
|
||||
|
@ -15,11 +15,11 @@ return new class extends Migration
|
||||
{
|
||||
|
||||
Schema::table('clients', function (Blueprint $table) {
|
||||
$table->string('leitweg_id')->default(null);
|
||||
$table->string('routing_id')->default(null)->nullable();
|
||||
});
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->boolean('use_xinvoice')->default(false);
|
||||
$table->string('xinvoice_type')->default("EN16931");
|
||||
$table->boolean('enable_e_invoice')->default(false);
|
||||
$table->string('e_invoice_type')->default("EN16931");
|
||||
});
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ Route::group(['middleware' => ['throttle:api', 'api_db', 'token_auth', 'locale']
|
||||
Route::get('invoices/{invoice}/{action}', [InvoiceController::class, 'action'])->name('invoices.action');
|
||||
Route::put('invoices/{invoice}/upload', [InvoiceController::class, 'upload'])->name('invoices.upload');
|
||||
Route::get('invoice/{invitation_key}/download', [InvoiceController::class, 'downloadPdf'])->name('invoices.downloadPdf');
|
||||
Route::get('invoice/{invitation_key}/download_xinvoice', [InvoiceController::class, 'downloadXInvoice_pdf'])->name('invoices.downloadXInvoice');
|
||||
Route::get('invoice/{invitation_key}/download_e_invoice', [InvoiceController::class, 'downloadEInvoice'])->name('invoices.downloadEInvoice');
|
||||
Route::post('invoices/bulk', [InvoiceController::class, 'bulk'])->name('invoices.bulk');
|
||||
Route::post('invoices/update_reminders', [InvoiceController::class, 'update_reminders'])->name('invoices.update_reminders');
|
||||
|
||||
|
@ -128,7 +128,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('invoice/{invitation_key}/download_e_invoice', [InvoiceController::class, 'downloadEInvoice'])->name('invoice.download_e_invoice');
|
||||
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']);
|
||||
|
@ -19,9 +19,9 @@ use horstoeko\zugferd\ZugferdDocumentReader;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers App\Jobs\Invoice\CreateUbl
|
||||
* @covers App\Jobs\Invoice\CreateXInvoice
|
||||
*/
|
||||
class XInvoiceTest extends TestCase
|
||||
class EInvoiceTest extends TestCase
|
||||
{
|
||||
use MockAccountData;
|
||||
use DatabaseTransactions;
|
||||
@ -36,13 +36,16 @@ class XInvoiceTest extends TestCase
|
||||
$this->makeTestData();
|
||||
}
|
||||
|
||||
public function testXInvoiceGenerates()
|
||||
public function testEInvoiceGenerates()
|
||||
{
|
||||
$xinvoice = (new CreateXInvoice($this->invoice, false))->handle();
|
||||
$this->assertNotNull($xinvoice);
|
||||
$this->assertFileExists($xinvoice);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testValidityofXMLFile()
|
||||
{
|
||||
$xinvoice = (new CreateXInvoice($this->invoice, false))->handle();
|
||||
@ -50,6 +53,10 @@ class XInvoiceTest extends TestCase
|
||||
$document ->getDocumentInformation($documentno);
|
||||
$this->assertEquals($this->invoice->number, $documentno);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function checkEmbededPDFFile()
|
||||
{
|
||||
$pdf = (new CreateEntityPdf($this->invoice->invitations()->first()));
|
Loading…
x
Reference in New Issue
Block a user