Fixes for tests

This commit is contained in:
David Bomba 2024-08-07 10:15:21 +10:00
parent 50a9a917b3
commit 2214b546ed
2 changed files with 63 additions and 18 deletions

View File

@ -57,6 +57,12 @@ class Peppol extends AbstractService
use NumberFormatter;
/**
* Assumptions:
*
* Line Item Taxes Only
* Exclusive Taxes
*
*
* used as a proxy for
* the schemeID of partyidentification
* property - for Storecove only:
@ -154,7 +160,9 @@ class Peppol extends AbstractService
private \InvoiceNinja\EInvoice\Models\Peppol\Invoice $p_invoice;
private ?\InvoiceNinja\EInvoice\Models\Peppol\Invoice $_client_settings;
private ?\InvoiceNinja\EInvoice\Models\Peppol\Invoice $_company_settings;
private EInvoice $e;
/**
@ -761,13 +769,13 @@ class Peppol extends AbstractService
public function getSetting(string $property_path): mixed
{
if($prop_value = PropertyResolver::resolve($this->invoice->e_invoice, $property_path))
if($prop_value = PropertyResolver::resolve($this->p_invoice, $property_path)) {
return $prop_value;
elseif($prop_value = PropertyResolver::resolve($this->_client_settings, $property_path))
}elseif($prop_value = PropertyResolver::resolve($this->_client_settings, $property_path)) {
return $prop_value;
elseif($prop_value = PropertyResolver::resolve($this->_company_settings, $property_path))
}elseif($prop_value = PropertyResolver::resolve($this->_company_settings, $property_path)) {
return $prop_value;
}
return null;
}
@ -786,7 +794,7 @@ class Peppol extends AbstractService
if(isset($this->p_invoice->PaymentMeans))
return $this;
elseif(!isset($this->p_invoice->PaymentMeans) && $paymentMeans = $this->getSetting('Invoice.PaymentMeans')){
elseif($paymentMeans = $this->getSetting('Invoice.PaymentMeans')){
$this->p_invoice->PaymentMeans = is_array($paymentMeans) ? $paymentMeans : [$paymentMeans];
return $this;
}
@ -797,23 +805,47 @@ class Peppol extends AbstractService
return $this;
}
/**
* DE
*
* @Completed
* @Tested
*
* @return self
*/
private function DE(): self
{
// accountingsupplierparty.party.contact MUST be set - Name / Telephone / Electronic Mail
// this is forced by default.
$this->setPaymentMeans(true);
return $this;
}
/**
* CH
*
* @Completed
*
* Completed - QR-Bill to be implemented at a later date.
* @return self
*/
private function CH(): self
{
//if QR-Bill support required - then special flow required.... optional.
return $this;
}
/**
* AT
*
* @Pending
*
* Need to ensure when sending to government entities that we route appropriately
* Also need to ensure customerAssignedAccountIdValue is set so that the sender can be resolved.
*
* Need a way to define if the client is a government entity.
*
* @return self
*/
private function AT(): self
{
//special fields for sending to AT:GOV
@ -827,6 +859,13 @@ class Peppol extends AbstractService
return $this;
}
/**
* ES
*
* @Pending - testing.
*
* @return self
*/
private function ES(): self
{

View File

@ -67,10 +67,8 @@ class PeppolTest extends TestCase
$settings->country_id = '276';
$settings->currency_id = '3';
$einvoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice();
$fib = new FinancialInstitutionBranch();
$fib->ID = "DEUTDEMMXXX"; //BIC
$fib->Name = 'Deutsche Bank';
@ -88,10 +86,13 @@ class PeppolTest extends TestCase
$pm->PayeeFinancialAccount = $pfa;
$einvoice->PaymentMeans[] = $pm;
$stub = new \stdClass;
$stub->Invoice = $einvoice;
$company = Company::factory()->create([
'account_id' => $this->account->id,
'settings' => $settings,
'e_invoice' => $einvoice,
'e_invoice' => $stub,
]);
$cu = CompanyUserFactory::create($this->user->id, $company->id, $this->account->id);
@ -149,11 +150,12 @@ class PeppolTest extends TestCase
$this->assertEquals(119, $invoice->amount);
$peppol = new Peppol($invoice);
$peppol->setInvoiceDefaults();
$peppol->run();
nlog($peppol->toXml());
$de_invoice = $peppol->getInvoice();
$this->assertNotNull($de_invoice);
@ -207,10 +209,14 @@ class PeppolTest extends TestCase
$pm->PayeeFinancialAccount = $pfa;
$einvoice->PaymentMeans[] = $pm;
$stub = new \stdClass();
$stub->Invoice = $einvoice;
$company = Company::factory()->create([
'account_id' => $this->account->id,
'settings' => $settings,
'e_invoice' => $einvoice,
'e_invoice' => $stub,
]);
$cu = CompanyUserFactory::create($this->user->id, $company->id, $this->account->id);