mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 22:54:25 +01:00
Split einvoice gateways
This commit is contained in:
parent
bfbf7f5c6a
commit
9c6568aae1
@ -34,6 +34,8 @@ interface MutatorInterface
|
||||
|
||||
public function getInvoice(): mixed;
|
||||
|
||||
public function getSetting(string $property_path): mixed;
|
||||
|
||||
// Country-specific methods
|
||||
public function DE(): self;
|
||||
|
||||
|
@ -76,6 +76,11 @@ class Mutator implements MutatorInterface
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
public function getSetting(string $property_path): mixed
|
||||
{
|
||||
return $this->mutator_util->getSetting($property_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* senderSpecificLevelMutators
|
||||
*
|
||||
|
@ -109,6 +109,10 @@ class Mutator implements MutatorInterface
|
||||
return $this->invoice;
|
||||
}
|
||||
|
||||
public function getSetting(string $property_path): mixed
|
||||
{
|
||||
return $this->mutator_util->getSetting($property_path);
|
||||
}
|
||||
/**
|
||||
* senderSpecificLevelMutators
|
||||
*
|
||||
|
@ -51,11 +51,6 @@ class SendEDocument implements ShouldQueue
|
||||
|
||||
$model = $this->entity::find($this->id);
|
||||
|
||||
// $e_invoice_standard = $model->client ? $model->client->getSetting('e_invoice_type') : $model->company->getSetting('e_invoice_type');
|
||||
|
||||
// if($e_invoice_standard != 'PEPPOL')
|
||||
// return;
|
||||
|
||||
if(Ninja::isSelfHost() && ($model instanceof Invoice) && $model->company->legal_entity_id)
|
||||
{
|
||||
|
||||
|
@ -313,8 +313,8 @@ class Peppol extends AbstractService
|
||||
$this->company = $invoice->company;
|
||||
$this->calc = $this->invoice->calc();
|
||||
$this->e = new EInvoice();
|
||||
$this->setSettings()->setInvoice();
|
||||
$this->gateway = new $this->api_network;
|
||||
$this->setSettings()->setInvoice();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -338,15 +338,10 @@ class Peppol extends AbstractService
|
||||
|
||||
$this->p_invoice->LegalMonetaryTotal = $this->getLegalMonetaryTotal();
|
||||
|
||||
|
||||
$this->setOrderReference();
|
||||
|
||||
$this->p_invoice = $this->gateway
|
||||
->mutator
|
||||
->setInvoice($this->invoice)
|
||||
->setPeppol($this->p_invoice)
|
||||
->setClientSettings($this->_client_settings)
|
||||
->setCompanySettings($this->_company_settings)
|
||||
->senderSpecificLevelMutators()
|
||||
->receiverSpecificLevelMutators()
|
||||
->getPeppol();
|
||||
@ -379,6 +374,13 @@ class Peppol extends AbstractService
|
||||
|
||||
$this->p_invoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice();
|
||||
|
||||
$this->gateway
|
||||
->mutator
|
||||
->setInvoice($this->invoice)
|
||||
->setPeppol($this->p_invoice)
|
||||
->setClientSettings($this->_client_settings)
|
||||
->setCompanySettings($this->_company_settings);
|
||||
|
||||
$this->setInvoiceDefaults();
|
||||
|
||||
return $this;
|
||||
@ -528,22 +530,11 @@ class Peppol extends AbstractService
|
||||
}
|
||||
|
||||
/**
|
||||
* getTotalTaxAmount
|
||||
* getTaxType
|
||||
*
|
||||
* @return float
|
||||
* @param string $tax_id
|
||||
* @return string
|
||||
*/
|
||||
// private function getTotalTaxAmount(): float
|
||||
// {
|
||||
// if(!$this->invoice->total_taxes) {
|
||||
// return 0;
|
||||
// } elseif($this->invoice->uses_inclusive_taxes) {
|
||||
// return $this->invoice->total_taxes;
|
||||
// }
|
||||
|
||||
// return $this->calcAmountLineTax($this->invoice->tax_rate1, $this->invoice->amount) ?? 0;
|
||||
// }
|
||||
|
||||
|
||||
private function getTaxType(string $tax_id = ''): string
|
||||
{
|
||||
$tax_type = null;
|
||||
@ -895,9 +886,9 @@ class Peppol extends AbstractService
|
||||
$party->PhysicalLocation = $address;
|
||||
|
||||
$contact = new Contact();
|
||||
$contact->ElectronicMail = $this->getSetting('Invoice.AccountingSupplierParty.Party.Contact') ?? $this->invoice->company->owner()->present()->email();
|
||||
$contact->Telephone = $this->getSetting('Invoice.AccountingSupplierParty.Party.Telephone') ?? $this->invoice->company->getSetting('phone');
|
||||
$contact->Name = $this->getSetting('Invoice.AccountingSupplierParty.Party.Name') ?? $this->invoice->company->owner()->present()->name();
|
||||
$contact->ElectronicMail = $this->gateway->mutator->getSetting('Invoice.AccountingSupplierParty.Party.Contact') ?? $this->invoice->company->owner()->present()->email();
|
||||
$contact->Telephone = $this->gateway->mutator->getSetting('Invoice.AccountingSupplierParty.Party.Telephone') ?? $this->invoice->company->getSetting('phone');
|
||||
$contact->Name = $this->gateway->mutator->getSetting('Invoice.AccountingSupplierParty.Party.Name') ?? $this->invoice->company->owner()->present()->name();
|
||||
|
||||
$party->Contact = $contact;
|
||||
|
||||
@ -1082,7 +1073,7 @@ class Peppol extends AbstractService
|
||||
//only scans for top level props
|
||||
foreach($settings as $prop => $visibility) {
|
||||
|
||||
if($prop_value = $this->getSetting($prop)) {
|
||||
if($prop_value = $this->gateway->mutator->getSetting($prop)) {
|
||||
$this->p_invoice->{$prop} = $prop_value;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user