Scenario tests
This commit is contained in:
parent
734d23858f
commit
cd3372fb12
|
|
@ -94,7 +94,7 @@ class EInvoiceController extends BaseController
|
||||||
$iban_id = new ID();
|
$iban_id = new ID();
|
||||||
$iban_id->value = $payment_means['iban'];
|
$iban_id->value = $payment_means['iban'];
|
||||||
$pfa->ID = $iban_id;
|
$pfa->ID = $iban_id;
|
||||||
$pfa->Name = $payment_means['payer_bank_account'];
|
$pfa->Name = $payment_means['account_holder'];
|
||||||
$pfa->FinancialInstitutionBranch = $fib;
|
$pfa->FinancialInstitutionBranch = $fib;
|
||||||
|
|
||||||
$pm->PayeeFinancialAccount = $pfa;
|
$pm->PayeeFinancialAccount = $pfa;
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ class UpdateCompanyRequest extends Request
|
||||||
'SK' => '/^SK\d{10}$/',
|
'SK' => '/^SK\d{10}$/',
|
||||||
'SI' => '/^SI\d{8}$/',
|
'SI' => '/^SI\d{8}$/',
|
||||||
'SE' => '/^SE\d{12}$/',
|
'SE' => '/^SE\d{12}$/',
|
||||||
|
'DE:STNR' => '/^[0-9]{11}$/', //de steurnummer,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,6 +78,10 @@ class UpdateCompanyRequest extends Request
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
|
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
@ -121,8 +126,8 @@ class UpdateCompanyRequest extends Request
|
||||||
'string',
|
'string',
|
||||||
'bail',
|
'bail',
|
||||||
'sometimes',
|
'sometimes',
|
||||||
Rule::requiredIf(function () {
|
Rule::requiredIf(function () use ($user) {
|
||||||
return $this->input('settings.e_invoice_type') === 'PEPPOL';
|
return $this->input('settings.e_invoice_type') === 'PEPPOL' && $user->company()->settings->classification != 'individual';
|
||||||
}),
|
}),
|
||||||
function ($attribute, $value, $fail) {
|
function ($attribute, $value, $fail) {
|
||||||
$country_code = $this->getCountryCode();
|
$country_code = $this->getCountryCode();
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ class StoreEntityRequest extends FormRequest
|
||||||
'SK' => '/^SK\d{10}$/',
|
'SK' => '/^SK\d{10}$/',
|
||||||
'SI' => '/^SI\d{8}$/',
|
'SI' => '/^SI\d{8}$/',
|
||||||
'SE' => '/^SE\d{12}$/',
|
'SE' => '/^SE\d{12}$/',
|
||||||
|
'DE:STNR' => '/^[0-9]{11}$/', //de steurnummer,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,18 @@ class UpdateEInvoiceConfiguration extends Request
|
||||||
|
|
||||||
return [...$rules, 'nullable'];
|
return [...$rules, 'nullable'];
|
||||||
}),
|
}),
|
||||||
|
'payment_means.*.account_holder' => Rule::forEach(function (string|null $value, string $attribute) {
|
||||||
|
$index = explode('.', $attribute)[1];
|
||||||
|
$code = $this->input("payment_means.{$index}.code");
|
||||||
|
$requirements = PaymentMeans::$payment_means_requirements_codes[$code] ?? [];
|
||||||
|
$rules = ['bail', 'sometimes', 'string', 'max:255'];
|
||||||
|
|
||||||
|
if (in_array('account_holder', $requirements)) {
|
||||||
|
return [...$rules, 'required'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...$rules, 'nullable'];
|
||||||
|
}),
|
||||||
'payment_means.*.information' => ['bail', 'sometimes', 'nullable', 'string'],
|
'payment_means.*.information' => ['bail', 'sometimes', 'nullable', 'string'],
|
||||||
'payment_means.*.card_type' => Rule::forEach(function (string|null $value, string $attribute) {
|
'payment_means.*.card_type' => Rule::forEach(function (string|null $value, string $attribute) {
|
||||||
$index = explode('.', $attribute)[1];
|
$index = explode('.', $attribute)[1];
|
||||||
|
|
|
||||||
|
|
@ -484,6 +484,7 @@ class BillingPortalPurchase extends Component
|
||||||
'invoice_id' => $this->invoice->hashed_id,
|
'invoice_id' => $this->invoice->hashed_id,
|
||||||
'context' => $context,
|
'context' => $context,
|
||||||
'campaign' => $this->campaign,
|
'campaign' => $this->campaign,
|
||||||
|
'request_data' => $this->request_data,
|
||||||
], now()->addMinutes(60));
|
], now()->addMinutes(60));
|
||||||
|
|
||||||
$this->dispatch('beforePaymentEventsCompleted');
|
$this->dispatch('beforePaymentEventsCompleted');
|
||||||
|
|
|
||||||
|
|
@ -381,6 +381,7 @@ class Storecove
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
nlog($r->body());
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,9 +137,8 @@ class StorecoveRouter
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//DE we can route via Steurnummer
|
//DE we can route via Steurnummer? double check with storecove @blocked
|
||||||
if($this->invoice && $country = "DE" && $classification == 'individual'){
|
if($country = "DE" && $classification == 'individual'){
|
||||||
// if($this->invoice && $country = "DE" && $classification == 'individual' && strlen($this->invoice->client->id_number ?? '') > 4){
|
|
||||||
return 'DE:STNR';
|
return 'DE:STNR';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5458,6 +5458,8 @@ $lang = array(
|
||||||
'peppol_routing_problem' => 'Routing problem. No recipient/destination found.',
|
'peppol_routing_problem' => 'Routing problem. No recipient/destination found.',
|
||||||
'peppol_sending_failed' => 'Technical delivery problem. Retry not possible',
|
'peppol_sending_failed' => 'Technical delivery problem. Retry not possible',
|
||||||
'peppol_cleared_for_sending' => 'Cleared by tax authority, sending to receiver',
|
'peppol_cleared_for_sending' => 'Cleared by tax authority, sending to receiver',
|
||||||
|
'account_holder' => 'Account Name',
|
||||||
|
'account_holder_help' => 'The name of the account',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $lang;
|
return $lang;
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,8 @@ class StorecoveTest extends TestCase
|
||||||
|
|
||||||
$settings = CompanySettings::defaults();
|
$settings = CompanySettings::defaults();
|
||||||
$settings->vat_number = $params['company_vat'] ?? 'DE123456789';
|
$settings->vat_number = $params['company_vat'] ?? 'DE123456789';
|
||||||
|
$settings->id_number = $params['company_id_number'] ?? '';
|
||||||
|
$settings->classification = $params['company_classification'] ?? 'business';
|
||||||
$settings->country_id = Country::where('iso_3166_2', 'DE')->first()->id;
|
$settings->country_id = Country::where('iso_3166_2', 'DE')->first()->id;
|
||||||
$settings->email = $this->faker->safeEmail();
|
$settings->email = $this->faker->safeEmail();
|
||||||
$settings->currency_id = '3';
|
$settings->currency_id = '3';
|
||||||
|
|
@ -170,8 +172,101 @@ class StorecoveTest extends TestCase
|
||||||
return compact('company', 'client', 'invoice');
|
return compact('company', 'client', 'invoice');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDEtoFRB2BReverseCharge()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->routing_id = 290868;
|
||||||
|
|
||||||
|
$scenario = [
|
||||||
|
'company_vat' => 'DE923356489',
|
||||||
|
'company_id_number' => '01234567890',
|
||||||
|
'company_country' => 'DE',
|
||||||
|
'company_classification' => 'business',
|
||||||
|
'client_country' => 'FR',
|
||||||
|
'client_vat' => 'FRAA123456789',
|
||||||
|
'client_id_number' => '',
|
||||||
|
'classification' => 'business',
|
||||||
|
'has_valid_vat' => false,
|
||||||
|
'over_threshold' => false,
|
||||||
|
'legal_entity_id' => 290868,
|
||||||
|
'is_tax_exempt' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = $this->setupTestData($scenario);
|
||||||
|
|
||||||
|
$invoice = $data['invoice'];
|
||||||
|
|
||||||
|
$line_items = $invoice->line_items;
|
||||||
|
|
||||||
|
foreach($line_items as &$item)
|
||||||
|
{
|
||||||
|
$item->tax_id = (string)\App\Models\Product::PRODUCT_TYPE_REVERSE_TAX;
|
||||||
|
}
|
||||||
|
unset($item);
|
||||||
|
|
||||||
|
$invoice->line_items = array_values($line_items);
|
||||||
|
|
||||||
|
$invoice = $invoice->calc()->getInvoice();
|
||||||
|
|
||||||
|
$this->assertEquals(floatval(0), floatval($invoice->total_taxes));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDEIToDEGNoTaxes()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->routing_id = 290868;
|
||||||
|
|
||||||
|
$scenario = [
|
||||||
|
'company_vat' => '',
|
||||||
|
'company_id_number' => '01234567890',
|
||||||
|
'company_country' => 'DE',
|
||||||
|
'company_classification' => 'individual',
|
||||||
|
'client_country' => 'DE',
|
||||||
|
'client_vat' => '',
|
||||||
|
'client_id_number' => '',
|
||||||
|
'classification' => 'government',
|
||||||
|
'has_valid_vat' => false,
|
||||||
|
'over_threshold' => false,
|
||||||
|
'legal_entity_id' => 290868,
|
||||||
|
'is_tax_exempt' => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = $this->setupTestData($scenario);
|
||||||
|
|
||||||
|
$invoice = $data['invoice'];
|
||||||
|
$invoice = $invoice->calc()->getInvoice();
|
||||||
|
|
||||||
|
$this->assertEquals(floatval(0), floatval($invoice->total_taxes));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDeNoVatNumberToDeVatNumber()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->routing_id = 290868;
|
||||||
|
|
||||||
|
$scenario = [
|
||||||
|
'company_vat' => '',
|
||||||
|
'company_id_number' => '01234567890',
|
||||||
|
'company_country' => 'DE',
|
||||||
|
'company_classification' => 'individual',
|
||||||
|
'client_country' => 'DE',
|
||||||
|
'client_vat' => 'DE923356489',
|
||||||
|
'client_id_number' => '',
|
||||||
|
'classification' => 'business',
|
||||||
|
'has_valid_vat' => true,
|
||||||
|
'over_threshold' => false,
|
||||||
|
'legal_entity_id' => 290868,
|
||||||
|
'is_tax_exempt' => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = $this->setupTestData($scenario);
|
||||||
|
|
||||||
|
$invoice = $data['invoice'];
|
||||||
|
$invoice = $invoice->calc()->getInvoice();
|
||||||
|
|
||||||
|
$this->assertGreaterThan(0, $invoice->total_taxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testDeToFrClientTaxExemptSending()
|
public function testDeToFrClientTaxExemptSending()
|
||||||
{
|
{
|
||||||
$this->routing_id = 290868;
|
$this->routing_id = 290868;
|
||||||
|
|
@ -209,7 +304,6 @@ class StorecoveTest extends TestCase
|
||||||
$this->assertEquals(floatval(0), floatval($invoice->total_taxes));
|
$this->assertEquals(floatval(0), floatval($invoice->total_taxes));
|
||||||
$this->sendDocument($invoice);
|
$this->sendDocument($invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PtestDeToDeClientTaxExemptSending
|
* PtestDeToDeClientTaxExemptSending
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue