mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #9846 from turbo124/v5-develop
Fixes for PayPal FraudNet
This commit is contained in:
commit
5f0caf370d
@ -1258,7 +1258,7 @@ class BaseExport
|
||||
|
||||
$date_range = $this->input['date_range'];
|
||||
|
||||
if (array_key_exists('date_key', $this->input) && strlen($this->input['date_key']) > 1 && ($table_name && $this->columnExists($table_name, $this->input['date_key']))) {
|
||||
if (array_key_exists('date_key', $this->input) && strlen($this->input['date_key'] ?? '') > 1 && ($table_name && $this->columnExists($table_name, $this->input['date_key']))) {
|
||||
$this->date_key = $this->input['date_key'];
|
||||
}
|
||||
|
||||
@ -1269,7 +1269,7 @@ class BaseExport
|
||||
$custom_start_date = now()->startOfYear();
|
||||
$custom_end_date = now();
|
||||
}
|
||||
|
||||
|
||||
switch ($date_range) {
|
||||
case 'all':
|
||||
$this->start_date = 'All available data';
|
||||
|
@ -29,7 +29,7 @@ class TaskExport extends BaseExport
|
||||
{
|
||||
private $entity_transformer;
|
||||
|
||||
public string $date_key = 'created_at';
|
||||
public string $date_key = 'calculated_start_date';
|
||||
|
||||
private string $date_format = 'Y-m-d';
|
||||
|
||||
|
@ -15,6 +15,7 @@ use App\Models\Quote;
|
||||
use App\Utils\Number;
|
||||
use App\Models\Client;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Models\RecurringQuote;
|
||||
@ -121,7 +122,7 @@ class InvoiceItemSum
|
||||
|
||||
private $tax_collection;
|
||||
|
||||
private ?Client $client;
|
||||
private Client | Vendor $client;
|
||||
|
||||
private bool $calc_tax = false;
|
||||
|
||||
@ -132,10 +133,10 @@ class InvoiceItemSum
|
||||
$this->tax_collection = collect([]);
|
||||
|
||||
$this->invoice = $invoice;
|
||||
$this->client = $invoice->client ?? $invoice->vendor;
|
||||
|
||||
if ($this->invoice->client) {
|
||||
$this->currency = $this->invoice->client->currency();
|
||||
$this->client = $this->invoice->client;
|
||||
$this->shouldCalculateTax();
|
||||
} else {
|
||||
$this->currency = $this->invoice->vendor->currency();
|
||||
|
@ -15,6 +15,7 @@ use App\Models\Quote;
|
||||
use App\Utils\Number;
|
||||
use App\Models\Client;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Models\RecurringQuote;
|
||||
@ -110,7 +111,7 @@ class InvoiceItemSumInclusive
|
||||
|
||||
private bool $calc_tax = false;
|
||||
|
||||
private ?Client $client;
|
||||
private Client | Vendor $client;
|
||||
|
||||
private RuleInterface $rule;
|
||||
|
||||
@ -119,10 +120,10 @@ class InvoiceItemSumInclusive
|
||||
$this->tax_collection = collect([]);
|
||||
|
||||
$this->invoice = $invoice;
|
||||
$this->client = $invoice->client ?? $invoice->vendor;
|
||||
|
||||
if ($this->invoice->client) {
|
||||
$this->currency = $this->invoice->client->currency();
|
||||
$this->client = $this->invoice->client;
|
||||
$this->shouldCalculateTax();
|
||||
} else {
|
||||
$this->currency = $this->invoice->vendor->currency();
|
||||
|
@ -11,12 +11,14 @@
|
||||
|
||||
namespace App\Helpers\Invoice;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Models\Quote;
|
||||
use App\Models\RecurringInvoice;
|
||||
use App\Models\RecurringQuote;
|
||||
use App\Models\Vendor;
|
||||
use App\Utils\Number;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use Illuminate\Support\Collection;
|
||||
@ -50,6 +52,8 @@ class InvoiceSum
|
||||
|
||||
private $precision;
|
||||
|
||||
private Client | Vendor $client;
|
||||
|
||||
public InvoiceItemSum $invoice_items;
|
||||
|
||||
private $rappen_rounding = false;
|
||||
@ -60,18 +64,15 @@ class InvoiceSum
|
||||
*/
|
||||
public function __construct($invoice)
|
||||
{
|
||||
|
||||
$this->invoice = $invoice;
|
||||
$this->client = $invoice->client ?? $invoice->vendor;
|
||||
|
||||
if ($this->invoice->client) {
|
||||
$this->precision = $this->invoice->client->currency()->precision;
|
||||
$this->rappen_rounding = $this->invoice->client->getSetting('enable_rappen_rounding');
|
||||
} else {
|
||||
$this->precision = $this->invoice->vendor->currency()->precision;
|
||||
$this->rappen_rounding = $this->invoice->vendor->getSetting('enable_rappen_rounding');
|
||||
|
||||
}
|
||||
$this->precision = $this->client->currency()->precision;
|
||||
$this->rappen_rounding = $this->client->getSetting('enable_rappen_rounding');
|
||||
|
||||
$this->tax_map = new Collection();
|
||||
|
||||
}
|
||||
|
||||
public function build()
|
||||
@ -131,7 +132,7 @@ class InvoiceSum
|
||||
$tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name1, $this->invoice->tax_rate1);
|
||||
|
||||
$this->total_taxes += $tax;
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate1), $this->invoice->client).'%', 'total' => $tax];
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate1), $this->client).'%', 'total' => $tax];
|
||||
}
|
||||
|
||||
if (is_string($this->invoice->tax_name2) && strlen($this->invoice->tax_name2) >= 2) {
|
||||
@ -139,7 +140,7 @@ class InvoiceSum
|
||||
$tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name2, $this->invoice->tax_rate2);
|
||||
|
||||
$this->total_taxes += $tax;
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate2), $this->invoice->client).'%', 'total' => $tax];
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate2), $this->client).'%', 'total' => $tax];
|
||||
}
|
||||
|
||||
if (is_string($this->invoice->tax_name3) && strlen($this->invoice->tax_name3) >= 2) {
|
||||
@ -147,7 +148,7 @@ class InvoiceSum
|
||||
$tax += $this->getSurchargeTaxTotalForKey($this->invoice->tax_name3, $this->invoice->tax_rate3);
|
||||
|
||||
$this->total_taxes += $tax;
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate3), $this->invoice->client).'%', 'total' => $tax];
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate3), $this->client).'%', 'total' => $tax];
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -13,7 +13,9 @@ namespace App\Helpers\Invoice;
|
||||
|
||||
use App\Models\Quote;
|
||||
use App\Utils\Number;
|
||||
use App\Models\Client;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Models\RecurringQuote;
|
||||
@ -50,6 +52,8 @@ class InvoiceSumInclusive
|
||||
|
||||
private $rappen_rounding = false;
|
||||
|
||||
private Client | Vendor $client;
|
||||
|
||||
public InvoiceItemSumInclusive $invoice_items;
|
||||
/**
|
||||
* Constructs the object with Invoice and Settings object.
|
||||
@ -59,14 +63,10 @@ class InvoiceSumInclusive
|
||||
public function __construct($invoice)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
|
||||
if ($this->invoice->client) {
|
||||
$this->precision = $this->invoice->client->currency()->precision;
|
||||
$this->rappen_rounding = $this->invoice->client->getSetting('enable_rappen_rounding');
|
||||
} else {
|
||||
$this->precision = $this->invoice->vendor->currency()->precision;
|
||||
$this->rappen_rounding = $this->invoice->vendor->getSetting('enable_rappen_rounding');
|
||||
}
|
||||
$this->client = $invoice->client ?? $invoice->vendor;
|
||||
|
||||
$this->precision = $this->client->currency()->precision;
|
||||
$this->rappen_rounding = $this->client->getSetting('enable_rappen_rounding');
|
||||
|
||||
$this->tax_map = new Collection();
|
||||
}
|
||||
@ -158,19 +158,19 @@ class InvoiceSumInclusive
|
||||
$tax = $this->calcInclusiveLineTax($this->invoice->tax_rate1, $amount);
|
||||
$this->total_taxes += $tax;
|
||||
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate1), $this->invoice->client).'%', 'total' => $tax];
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name1.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate1), $this->client).'%', 'total' => $tax];
|
||||
}
|
||||
|
||||
if (is_string($this->invoice->tax_name2) && strlen($this->invoice->tax_name2) > 1) {
|
||||
$tax = $this->calcInclusiveLineTax($this->invoice->tax_rate2, $amount);
|
||||
$this->total_taxes += $tax;
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate2), $this->invoice->client).'%', 'total' => $tax];
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name2.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate2), $this->client).'%', 'total' => $tax];
|
||||
}
|
||||
|
||||
if (is_string($this->invoice->tax_name3) && strlen($this->invoice->tax_name3) > 1) {
|
||||
$tax = $this->calcInclusiveLineTax($this->invoice->tax_rate3, $amount);
|
||||
$this->total_taxes += $tax;
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate3), $this->invoice->client).'%', 'total' => $tax];
|
||||
$this->total_tax_map[] = ['name' => $this->invoice->tax_name3.' '.Number::formatValueNoTrailingZeroes(floatval($this->invoice->tax_rate3), $this->client).'%', 'total' => $tax];
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
namespace App\Jobs\EDocument;
|
||||
|
||||
use App\Services\EDocument\Standards\RoEInvoice;
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Quote;
|
||||
use App\Models\Credit;
|
||||
@ -23,10 +22,12 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use App\Services\EDocument\Standards\Peppol;
|
||||
use horstoeko\zugferd\ZugferdDocumentBuilder;
|
||||
use App\Services\EDocument\Standards\FatturaPA;
|
||||
use App\Services\EDocument\Standards\RoEInvoice;
|
||||
use App\Services\EDocument\Standards\OrderXDocument;
|
||||
use App\Services\EDocument\Standards\FacturaEInvoice;
|
||||
use App\Services\EDocument\Standards\FatturaPA;
|
||||
use App\Services\EDocument\Standards\ZugferdEDokument;
|
||||
|
||||
class CreateEDocument implements ShouldQueue
|
||||
@ -68,6 +69,8 @@ class CreateEDocument implements ShouldQueue
|
||||
|
||||
if ($this->document instanceof Invoice) {
|
||||
switch ($e_document_type) {
|
||||
case "PEPPOL":
|
||||
return (new Peppol($this->document))->toXml();
|
||||
case "FACT1":
|
||||
return (new RoEInvoice($this->document))->generateXml();
|
||||
case "FatturaPA":
|
||||
|
@ -95,4 +95,9 @@ class UserPresenter extends EntityPresenter
|
||||
{
|
||||
return $this->entity->phone ?? ' ';
|
||||
}
|
||||
|
||||
public function email(): string
|
||||
{
|
||||
return $this->entity->email ?? ' ';
|
||||
}
|
||||
}
|
||||
|
@ -273,14 +273,14 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
if($shipping = $this->getShippingAddress()) {
|
||||
if($shipping = $this->getShippingAddress())
|
||||
$order['purchase_units'][0]["shipping"] = $shipping;
|
||||
}
|
||||
|
||||
if(isset($data['payment_source'])) {
|
||||
if(isset($data['payment_source']))
|
||||
$order['payment_source'] = $data['payment_source'];
|
||||
}
|
||||
|
||||
if(isset($data['payer']))
|
||||
$order['payer'] = $data['payer'];
|
||||
|
||||
$r = $this->gatewayRequest('/v2/checkout/orders', 'post', $order);
|
||||
|
||||
@ -316,8 +316,17 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
||||
->firstOrFail();
|
||||
|
||||
$orderId = $response['orderID'];
|
||||
|
||||
$r = $this->gatewayRequest("/v1/checkout/orders/{$orderId}/", 'delete', ['body' => '']);
|
||||
|
||||
$data["payer"] = [
|
||||
"name" => [
|
||||
"given_name" => $this->client->present()->first_name(),
|
||||
"surname" => $this->client->present()->last_name()
|
||||
],
|
||||
"email_address" => $this->client->present()->email(),
|
||||
];
|
||||
|
||||
$data['amount_with_fee'] = $this->payment_hash->data->amount_with_fee;
|
||||
$data["payment_source"] = [
|
||||
"card" => [
|
||||
@ -393,6 +402,14 @@ class PayPalPPCPPaymentDriver extends PayPalBasePaymentDriver
|
||||
$data = [];
|
||||
$this->payment_hash = $payment_hash;
|
||||
|
||||
$data["payer"] = [
|
||||
"name" => [
|
||||
"given_name" => $this->client->present()->first_name(),
|
||||
"surname" => $this->client->present()->last_name()
|
||||
],
|
||||
"email_address" => $this->client->present()->email(),
|
||||
];
|
||||
|
||||
$data['amount_with_fee'] = $this->payment_hash->data->amount_with_fee;
|
||||
$data["payment_source"] = [
|
||||
"card" => [
|
||||
|
@ -157,10 +157,6 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function createOrder(array $data): string
|
||||
{
|
||||
|
||||
@ -213,6 +209,10 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
||||
$order['payment_source'] = $data['payment_source'];
|
||||
}
|
||||
|
||||
if(isset($data["payer"])){
|
||||
$order['payer'] = $data["payer"];
|
||||
}
|
||||
|
||||
$r = $this->gatewayRequest('/v2/checkout/orders', 'post', $order);
|
||||
|
||||
nlog($r->json());
|
||||
@ -274,6 +274,13 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
||||
|
||||
nlog($r->body());
|
||||
|
||||
$data["payer"] = [
|
||||
"name" => [
|
||||
"given_name" => $this->client->present()->first_name(),
|
||||
"surname" => $this->client->present()->last_name()
|
||||
],
|
||||
"email_address" => $this->client->present()->email(),
|
||||
];
|
||||
$data['amount_with_fee'] = $this->payment_hash->data->amount_with_fee;
|
||||
$data["payment_source"] = [
|
||||
"card" => [
|
||||
@ -349,6 +356,14 @@ class PayPalRestPaymentDriver extends PayPalBasePaymentDriver
|
||||
$data = [];
|
||||
$this->payment_hash = $payment_hash;
|
||||
|
||||
$data['payer'] = [
|
||||
"name" => [
|
||||
"given_name" => $this->client->present()->first_name(),
|
||||
"surname" => $this->client->present()->last_name()
|
||||
],
|
||||
"email_address" => $this->client->present()->email(),
|
||||
];
|
||||
|
||||
$data['amount_with_fee'] = $this->payment_hash->data->amount_with_fee;
|
||||
$data["payment_source"] = [
|
||||
"card" => [
|
||||
|
@ -95,6 +95,48 @@ class Storecove {
|
||||
// parseStrategy: ubl
|
||||
// }
|
||||
*/
|
||||
public function sendJsonDocument($document)
|
||||
{
|
||||
|
||||
|
||||
$payload = [
|
||||
"legalEntityId" => 290868,
|
||||
"idempotencyGuid" => \Illuminate\Support\Str::uuid(),
|
||||
"routing" => [
|
||||
"eIdentifiers" => [],
|
||||
"emails" => ["david@invoiceninja.com"]
|
||||
],
|
||||
// "document" => [
|
||||
// 'documentType' => 'invoice',
|
||||
// "rawDocumentData" => [
|
||||
// "document" => base64_encode($document),
|
||||
// "parse" => true,
|
||||
// "parseStrategy" => "ubl",
|
||||
// ],
|
||||
// ],
|
||||
"document"=> [
|
||||
"documentType" => "invoice",
|
||||
"invoice" => $document,
|
||||
],
|
||||
];
|
||||
|
||||
$uri = "document_submissions";
|
||||
|
||||
nlog($payload);
|
||||
|
||||
$r = $this->httpClient($uri, (HttpVerb::POST)->value, $payload, $this->getHeaders());
|
||||
|
||||
nlog($r->body());
|
||||
nlog($r->json());
|
||||
|
||||
if($r->successful()) {
|
||||
return $r->json()['guid'];
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public function sendDocument($document)
|
||||
{
|
||||
|
||||
@ -256,8 +298,6 @@ class Storecove {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function addIdentifier(int $legal_entity_id, string $identifier, string $scheme)
|
||||
{
|
||||
$uri = "legal_entities/{$legal_entity_id}/peppol_identifiers";
|
||||
@ -278,7 +318,6 @@ class Storecove {
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
private function getHeaders(array $headers = [])
|
||||
{
|
||||
@ -300,5 +339,4 @@ class Storecove {
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -151,14 +151,36 @@ class Peppol extends AbstractService
|
||||
|
||||
private InvoiceSum | InvoiceSumInclusive $calc;
|
||||
|
||||
private \InvoiceNinja\EInvoice\Models\Peppol\Invoice $p_invoice;
|
||||
/**
|
||||
* @param Invoice $invoice
|
||||
*/
|
||||
public function __construct(public Invoice $invoice, public ?\InvoiceNinja\EInvoice\Models\Peppol\Invoice $p_invoice = null)
|
||||
public function __construct(public Invoice $invoice)
|
||||
{
|
||||
$this->p_invoice = $p_invoice ?? new \InvoiceNinja\EInvoice\Models\Peppol\Invoice();
|
||||
$this->company = $invoice->company;
|
||||
$this->calc = $this->invoice->calc();
|
||||
$this->setInvoice();
|
||||
}
|
||||
|
||||
private function setInvoice(): self
|
||||
{
|
||||
|
||||
|
||||
if($this->invoice->e_invoice){
|
||||
|
||||
|
||||
$e = new EInvoice();
|
||||
$this->p_invoice = $e->decode('Peppol', json_encode($this->invoice->e_invoice->Invoice), 'json');
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
$this->p_invoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice();
|
||||
|
||||
$this->setInvoiceDefaults();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getInvoice(): \InvoiceNinja\EInvoice\Models\Peppol\Invoice
|
||||
@ -171,7 +193,31 @@ class Peppol extends AbstractService
|
||||
public function toXml(): string
|
||||
{
|
||||
$e = new EInvoice();
|
||||
return $e->encode($this->p_invoice, 'xml');
|
||||
$xml = $e->encode($this->p_invoice, 'xml');
|
||||
|
||||
$prefix = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<Invoice
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">';
|
||||
|
||||
return str_ireplace(['\n','<?xml version="1.0"?>'], ['', $prefix], $xml);
|
||||
|
||||
}
|
||||
|
||||
public function toJson(): string
|
||||
{
|
||||
$e = new EInvoice();
|
||||
$json = $e->encode($this->p_invoice, 'json');
|
||||
|
||||
return $json;
|
||||
// $prefixes = str_ireplace(["cac:","cbc:"], "", $json);
|
||||
// return str_ireplace(["InvoiceLine", "PostalAddress", "PartyName"], ["invoiceLines","address", "companyName"], $prefixes);
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return json_decode($this->toJson(), true);
|
||||
}
|
||||
|
||||
public function run()
|
||||
@ -188,31 +234,10 @@ class Peppol extends AbstractService
|
||||
|
||||
$this->countryLevelMutators();
|
||||
|
||||
// $this->p_invoice->PaymentMeans = $this->getPaymentMeans();
|
||||
|
||||
// $payeeFinancialAccount = (new PayeeFinancialAccount())
|
||||
// ->setBankId($company->settings->custom_value1)
|
||||
// ->setBankName($company->settings->custom_value2);
|
||||
|
||||
// $paymentMeans = (new PaymentMeans())
|
||||
// ->setPaymentMeansCode($invoice->custom_value1)
|
||||
// ->setPayeeFinancialAccount($payeeFinancialAccount);
|
||||
// $ubl_invoice->setPaymentMeans($paymentMeans);
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
// private function getPaymentMeans(): PaymentMeans
|
||||
// {
|
||||
// $payeeFinancialAccount = new PayeeFinancialAccount()
|
||||
// $payeeFinancialAccount->
|
||||
|
||||
// $ppm = new PaymentMeans();
|
||||
// $ppm->PayeeFinancialAccount = $payeeFinancialAccount;
|
||||
|
||||
// return $ppm;
|
||||
// }
|
||||
|
||||
private function getLegalMonetaryTotal(): LegalMonetaryTotal
|
||||
{
|
||||
$taxable = $this->getTaxable();
|
||||
@ -485,7 +510,7 @@ class Peppol extends AbstractService
|
||||
$tax_amount = new TaxAmount();
|
||||
$tax_amount->currencyID = $this->invoice->client->currency()->code;
|
||||
|
||||
$tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiveLineTax($item->tax_rate2, $item->line_total) : $this->calcAmountLineTax($item->tax_rate2, $item->line_total);
|
||||
$tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiveLineTax($item->tax_rate2, $item->line_total) : $this->calcAmountLineTax($item->tax_rate2, $item->line_total);
|
||||
|
||||
$tax_subtotal = new TaxSubtotal();
|
||||
$tax_subtotal->TaxAmount = $tax_amount;
|
||||
@ -519,7 +544,7 @@ $tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiv
|
||||
$tax_amount = new TaxAmount();
|
||||
$tax_amount->currencyID = $this->invoice->client->currency()->code;
|
||||
|
||||
$tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiveLineTax($item->tax_rate3, $item->line_total) : $this->calcAmountLineTax($item->tax_rate3, $item->line_total);
|
||||
$tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiveLineTax($item->tax_rate3, $item->line_total) : $this->calcAmountLineTax($item->tax_rate3, $item->line_total);
|
||||
|
||||
$tax_subtotal = new TaxSubtotal();
|
||||
$tax_subtotal->TaxAmount = $tax_amount;
|
||||
@ -575,9 +600,9 @@ $tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiv
|
||||
$party->PhysicalLocation = $address;
|
||||
|
||||
$contact = new Contact();
|
||||
$contact->ElectronicMail = $this->invoice->company->owner()->email ?? 'owner@gmail.com';
|
||||
$contact->Telephone = '';
|
||||
$contact->Name = '';
|
||||
$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();
|
||||
|
||||
$party->Contact = $contact;
|
||||
|
||||
@ -703,20 +728,26 @@ $tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiv
|
||||
//only scans for top level props
|
||||
foreach($settings as $prop => $visibility){
|
||||
|
||||
if($prop_value = PropertyResolver::resolve($this->invoice->client->e_invoice, $prop))
|
||||
if($prop_value = $this->getSetting($prop))
|
||||
$this->p_invoice->{$prop} = $prop_value;
|
||||
elseif($prop_value = PropertyResolver::resolve($this->invoice->company->e_invoice, $prop)) {
|
||||
$this->p_invoice->{$prop} = $prop_value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSetting(object $e_invoice, string $property_path): mixed
|
||||
public function getSetting(string $property_path): mixed
|
||||
{
|
||||
return PropertyResolver::resolve($e_invoice, $property_path);
|
||||
|
||||
if($prop_value = PropertyResolver::resolve($this->invoice->e_invoice, $property_path))
|
||||
return $prop_value;
|
||||
elseif($prop_value = PropertyResolver::resolve($this->invoice->client->e_invoice, $property_path))
|
||||
return $prop_value;
|
||||
elseif($prop_value = PropertyResolver::resolve($this->invoice->company->e_invoice, $property_path))
|
||||
return $prop_value;
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public function countryLevelMutators():self
|
||||
@ -728,14 +759,29 @@ $tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiv
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function setPaymentMeans(bool $required = false): self
|
||||
{
|
||||
|
||||
if($this->p_invoice->PaymentMeans)
|
||||
return $this;
|
||||
elseif(!isset($this->p_invoice->PaymentMeans) && $paymentMeans = $this->getSetting('Invoice.PaymentMeans')){
|
||||
$this->p_invoice->PaymentMeans = is_array($paymentMeans) ? $paymentMeans : [$paymentMeans];
|
||||
return $this;
|
||||
}
|
||||
|
||||
if($required)
|
||||
throw new \Exception('e-invoice generation halted:: Payment Means required');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function DE(): self
|
||||
{
|
||||
// accountingsupplierparty.party.contact MUST be set - Name / Telephone / Electronic Mail
|
||||
// this is forced by default.
|
||||
|
||||
$this->setPaymentMeans(true);
|
||||
|
||||
// ONE payment means MUST be set
|
||||
|
||||
//
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -762,7 +808,7 @@ $tax_amount->amount = $this->invoice->uses_inclusive_taxes ? $this->calcInclusiv
|
||||
private function ES(): self
|
||||
{
|
||||
|
||||
// For B2B, provide an ES:DIRE routing identifier and an ES:VAT tax identifier.
|
||||
// For B2B, provide an ES:DIRE routing identifier and an ES:VAT tax identifier.
|
||||
// both sender and receiver must be an ES company;
|
||||
// you must have a "credit_transfer" PaymentMean;
|
||||
// the "dueDate" property is mandatory.
|
||||
|
@ -557,15 +557,7 @@ class TemplateService
|
||||
'reminder_last_sent' => $this->translateDate($invoice->reminder_last_sent, $invoice->client->date_format(), $invoice->client->locale()),
|
||||
'paid_to_date' => Number::formatMoney($invoice->paid_to_date, $invoice->client),
|
||||
'auto_bill_enabled' => (bool) $invoice->auto_bill_enabled,
|
||||
'client' => [
|
||||
'name' => $invoice->client->present()->name(),
|
||||
'balance' => $invoice->client->balance,
|
||||
'payment_balance' => $invoice->client->payment_balance,
|
||||
'credit_balance' => $invoice->client->credit_balance,
|
||||
'vat_number' => $invoice->client->vat_number ?? '',
|
||||
'currency' => $invoice->client->currency()->code ?? 'USD',
|
||||
'locale' => substr($invoice->client->locale(), 0, 2),
|
||||
],
|
||||
'client' => $this->getClient($invoice),
|
||||
'payments' => $payments,
|
||||
'total_tax_map' => $invoice->calc()->getTotalTaxMap(),
|
||||
'line_tax_map' => $invoice->calc()->getTaxMap(),
|
||||
@ -680,14 +672,7 @@ class TemplateService
|
||||
'custom_value4' => $payment->custom_value4 ?? '',
|
||||
'created_at' => $this->translateDate($payment->created_at, $payment->client->date_format(), $payment->client->locale()),
|
||||
'updated_at' => $this->translateDate($payment->updated_at, $payment->client->date_format(), $payment->client->locale()),
|
||||
'client' => [
|
||||
'name' => $payment->client->present()->name(),
|
||||
'balance' => $payment->client->balance,
|
||||
'payment_balance' => $payment->client->payment_balance,
|
||||
'credit_balance' => $payment->client->credit_balance,
|
||||
'vat_number' => $payment->client->vat_number ?? '',
|
||||
'currency' => $payment->client->currency()->code ?? 'USD',
|
||||
],
|
||||
'client' => $this->getClient($payment),
|
||||
'paymentables' => $pivot,
|
||||
'refund_activity' => $this->getPaymentRefundActivity($payment),
|
||||
];
|
||||
@ -760,14 +745,7 @@ class TemplateService
|
||||
'amount' => Number::formatMoney($quote->amount, $quote->client),
|
||||
'balance' => Number::formatMoney($quote->balance, $quote->client),
|
||||
'balance_raw' => (float) $quote->balance,
|
||||
'client' => [
|
||||
'name' => $quote->client->present()->name(),
|
||||
'balance' => $quote->client->balance,
|
||||
'payment_balance' => $quote->client->payment_balance,
|
||||
'credit_balance' => $quote->client->credit_balance,
|
||||
'vat_number' => $quote->client->vat_number ?? '',
|
||||
'currency' => $quote->client->currency()->code ?? 'USD',
|
||||
],
|
||||
'client' => $this->getClient($quote),
|
||||
'status_id' => $quote->status_id,
|
||||
'status' => Quote::stringStatus($quote->status_id),
|
||||
'number' => $quote->number ?: '',
|
||||
@ -888,14 +866,7 @@ class TemplateService
|
||||
'reminder_last_sent' => $this->translateDate($credit->reminder_last_sent, $credit->client->date_format(), $credit->client->locale()),
|
||||
'paid_to_date' => Number::formatMoney($credit->paid_to_date, $credit->client),
|
||||
'auto_bill_enabled' => (bool) $credit->auto_bill_enabled,
|
||||
'client' => [
|
||||
'name' => $credit->client->present()->name(),
|
||||
'balance' => $credit->client->balance,
|
||||
'payment_balance' => $credit->client->payment_balance,
|
||||
'credit_balance' => $credit->client->credit_balance,
|
||||
'vat_number' => $credit->client->vat_number ?? '',
|
||||
'currency' => $credit->client->currency()->code ?? 'USD',
|
||||
],
|
||||
'client' => $this->getClient($credit),
|
||||
'payments' => $payments,
|
||||
'total_tax_map' => $credit->calc()->getTotalTaxMap(),
|
||||
'line_tax_map' => $credit->calc()->getTaxMap(),
|
||||
@ -924,6 +895,25 @@ class TemplateService
|
||||
|
||||
}
|
||||
|
||||
private function getClient($entity): array
|
||||
{
|
||||
|
||||
return $entity->client ? [
|
||||
'name' => $entity->client->present()->name(),
|
||||
'balance' => $entity->client->balance,
|
||||
'payment_balance' => $entity->client->payment_balance,
|
||||
'credit_balance' => $entity->client->credit_balance,
|
||||
'vat_number' => $entity->client->vat_number ?? '',
|
||||
'currency' => $entity->client->currency()->code ?? 'USD',
|
||||
'custom_value1' => $entity->client->custom_value1 ?? '',
|
||||
'custom_value2' => $entity->client->custom_value2 ?? '',
|
||||
'custom_value3' => $entity->client->custom_value3 ?? '',
|
||||
'custom_value4' => $entity->client->custom_value4 ?? '',
|
||||
'address' => $entity->client->present()->address(),
|
||||
'shipping_address' => $entity->client->present()->shipping_address(),
|
||||
'locale' => substr($entity->client->locale(), 0, 2),
|
||||
] : [];
|
||||
}
|
||||
/**
|
||||
* @todo refactor
|
||||
*
|
||||
@ -953,14 +943,7 @@ class TemplateService
|
||||
'custom_value4' => $task->custom_value4 ?: '',
|
||||
'status' => $task->status ? $task->status->name : '',
|
||||
'user' => $this->userInfo($task->user),
|
||||
'client' => $task->client ? [
|
||||
'name' => $task->client->present()->name(),
|
||||
'balance' => $task->client->balance,
|
||||
'payment_balance' => $task->client->payment_balance,
|
||||
'credit_balance' => $task->client->credit_balance,
|
||||
'vat_number' => $task->client->vat_number ?? '',
|
||||
'currency' => $task->client->currency()->code ?? 'USD',
|
||||
] : [],
|
||||
'client' => $this->getClient($task),
|
||||
];
|
||||
|
||||
|
||||
@ -1015,14 +998,7 @@ class TemplateService
|
||||
'color' => (string) $project->color ?: '',
|
||||
'current_hours' => (int) $project->current_hours ?: 0,
|
||||
'tasks' => ($project->tasks && !$nested) ? $this->processTasks($project->tasks, true) : [], //@phpstan-ignore-line
|
||||
'client' => $project->client ? [
|
||||
'name' => $project->client->present()->name(),
|
||||
'balance' => $project->client->balance,
|
||||
'payment_balance' => $project->client->payment_balance,
|
||||
'credit_balance' => $project->client->credit_balance,
|
||||
'vat_number' => $project->client->vat_number ?? '',
|
||||
'currency' => $project->client->currency()->code ?? 'USD',
|
||||
] : [],
|
||||
'client' => $this->getClient($project),
|
||||
'user' => $this->userInfo($project->user),
|
||||
'invoices' => $this->processInvoices($project->invoices)
|
||||
];
|
||||
@ -1047,16 +1023,7 @@ class TemplateService
|
||||
] : [],
|
||||
'amount' => (float)$purchase_order->amount,
|
||||
'balance' => (float)$purchase_order->balance,
|
||||
'client' => $purchase_order->client ? [
|
||||
'name' => $purchase_order->client->present()->name(),
|
||||
'balance' => $purchase_order->client->balance,
|
||||
'payment_balance' => $purchase_order->client->payment_balance,
|
||||
'credit_balance' => $purchase_order->client->credit_balance,
|
||||
'vat_number' => $purchase_order->client->vat_number ?? '',
|
||||
'address' => $purchase_order->client->present()->address(),
|
||||
'shipping_address' => $purchase_order->client->present()->shipping_address(),
|
||||
'currency' => $purchase_order->client->currency()->code ?? 'USD',
|
||||
] : [],
|
||||
'client' => $this->getClient($purchase_order),
|
||||
'status_id' => (string)($purchase_order->status_id ?: 1),
|
||||
'status' => PurchaseOrder::stringStatus($purchase_order->status_id ?? 1),
|
||||
'is_deleted' => (bool)$purchase_order->is_deleted,
|
||||
|
@ -14,10 +14,12 @@
|
||||
|
||||
@endphp
|
||||
@section('gateway_head')
|
||||
<!-- <meta http-equiv="Content-Security-Policy" content="
|
||||
img-src 'self' https://c.paypal.com https://b.stats.paypal.com;
|
||||
frame-src 'self' https://c.paypal.com;
|
||||
script-src 'self' https://c.paypal.com;"> -->
|
||||
<meta http-equiv="Content-Security-Policy" content="
|
||||
frame-src 'self' https://c.paypal.com https://www.sandbox.paypal.com https://www.paypal.com;
|
||||
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://c.paypal.com https://www.paypalobjects.com https://www.paypal.com https://www.sandbox.paypal.com/;
|
||||
img-src * data: 'self';
|
||||
style-src 'self' 'unsafe-inline';"
|
||||
>
|
||||
@endsection
|
||||
|
||||
@section('gateway_content')
|
||||
@ -86,7 +88,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <script type="text/javascript" src="https://c.paypal.com/da/r/fb.js"></script> -->
|
||||
<script type="text/javascript" src="https://c.paypal.com/da/r/fb.js"></script>
|
||||
|
||||
@if(isset($merchantId))
|
||||
<script src="https://www.paypal.com/sdk/js?client-id={!! $client_id !!}&merchant-id={!! $merchantId !!}&components=card-fields" data-partner-attribution-id="invoiceninja_SP_PPCP"></script>
|
||||
@ -185,8 +187,8 @@
|
||||
// Render each field after checking for eligibility
|
||||
if (cardField.isEligible()) {
|
||||
|
||||
const nameField = cardField.NameField();
|
||||
nameField.render("#card-name-field-container");
|
||||
// const nameField = cardField.NameField();
|
||||
// nameField.render("#card-name-field-container");
|
||||
|
||||
const numberField = cardField.NumberField({
|
||||
inputEvents: {
|
||||
|
@ -19,18 +19,19 @@ use Tests\MockAccountData;
|
||||
use App\DataMapper\InvoiceItem;
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\Factory\CompanyUserFactory;
|
||||
use InvoiceNinja\EInvoice\EInvoice;
|
||||
use InvoiceNinja\EInvoice\Symfony\Encode;
|
||||
use App\Services\EDocument\Standards\Peppol;
|
||||
use App\Services\EDocument\Standards\FatturaPANew;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use InvoiceNinja\EInvoice\Models\Peppol\PaymentMeans;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use InvoiceNinja\EInvoice\Models\FatturaPA\FatturaElettronica;
|
||||
use InvoiceNinja\EInvoice\Models\Peppol\BranchType\FinancialInstitutionBranch;
|
||||
use InvoiceNinja\EInvoice\Models\Peppol\FinancialAccountType\PayeeFinancialAccount;
|
||||
use InvoiceNinja\EInvoice\Models\FatturaPA\FatturaElettronicaBodyType\FatturaElettronicaBody;
|
||||
use InvoiceNinja\EInvoice\Models\FatturaPA\FatturaElettronicaHeaderType\FatturaElettronicaHeader;
|
||||
use InvoiceNinja\EInvoice\Models\Peppol\PaymentMeans;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -92,6 +93,12 @@ class PeppolTest extends TestCase
|
||||
'settings' => $settings,
|
||||
'e_invoice' => $einvoice,
|
||||
]);
|
||||
|
||||
$cu = CompanyUserFactory::create($this->user->id, $company->id, $this->account->id);
|
||||
$cu->is_owner = true;
|
||||
$cu->is_admin = true;
|
||||
$cu->is_locked = false;
|
||||
$cu->save();
|
||||
|
||||
$client_settings = ClientSettings::defaults();
|
||||
$client_settings->currency_id = '3';
|
||||
@ -206,6 +213,12 @@ class PeppolTest extends TestCase
|
||||
'e_invoice' => $einvoice,
|
||||
]);
|
||||
|
||||
$cu = CompanyUserFactory::create($this->user->id, $company->id, $this->account->id);
|
||||
$cu->is_owner = true;
|
||||
$cu->is_admin = true;
|
||||
$cu->is_locked = false;
|
||||
$cu->save();
|
||||
|
||||
$client_settings = ClientSettings::defaults();
|
||||
$client_settings->currency_id = '3';
|
||||
|
||||
@ -301,6 +314,13 @@ class PeppolTest extends TestCase
|
||||
'account_id' => $this->account->id,
|
||||
'settings' => $settings,
|
||||
]);
|
||||
|
||||
|
||||
$cu = CompanyUserFactory::create($this->user->id, $company->id, $this->account->id);
|
||||
$cu->is_owner = true;
|
||||
$cu->is_admin = true;
|
||||
$cu->is_locked = false;
|
||||
$cu->save();
|
||||
|
||||
$client_settings = ClientSettings::defaults();
|
||||
$client_settings->currency_id = '3';
|
||||
|
@ -11,18 +11,25 @@
|
||||
|
||||
namespace Tests\Integration\Einvoice\Storecove;
|
||||
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\Models\Client;
|
||||
use Tests\TestCase;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\Invoice;
|
||||
use Tests\MockAccountData;
|
||||
use App\DataMapper\InvoiceItem;
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\Services\EDocument\Standards\Peppol;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
use InvoiceNinja\EInvoice\Models\Peppol\PaymentMeans;
|
||||
|
||||
class StorecoveTest extends TestCase
|
||||
{
|
||||
use MockAccountData;
|
||||
use DatabaseTransactions;
|
||||
|
||||
private string $routing_id = '';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@ -88,7 +95,7 @@ class StorecoveTest extends TestCase
|
||||
// nlog($r);
|
||||
|
||||
// }
|
||||
|
||||
/*
|
||||
public function testGetLegalEntity()
|
||||
{
|
||||
|
||||
@ -348,7 +355,7 @@ $x = '<?xml version="1.0" encoding="utf-8"?>
|
||||
$sc->sendDocument($x);
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
public function testCreateCHClient()
|
||||
{
|
||||
|
||||
@ -390,4 +397,140 @@ $x = '<?xml version="1.0" encoding="utf-8"?>
|
||||
$this->assertInstanceOf(\App\Models\Client::class, $c);
|
||||
|
||||
}
|
||||
|
||||
private function createDEData()
|
||||
{
|
||||
|
||||
$this->routing_id = '290868';
|
||||
|
||||
$settings = CompanySettings::defaults();
|
||||
$settings->company_logo = 'https://pdf.invoicing.co/favicon-v2.png';
|
||||
$settings->website = 'www.invoiceninja.de';
|
||||
$settings->address1 = 'Musterstraße 1';
|
||||
$settings->address2 = 'Etage 2, Büro 3';
|
||||
$settings->city = 'Berlin';
|
||||
$settings->state = 'Berlin';
|
||||
$settings->postal_code = '10115';
|
||||
$settings->phone = '030 1234567';
|
||||
$settings->email = $this->faker->unique()->safeEmail();
|
||||
$settings->country_id = '276'; // Germany's ISO country code
|
||||
$settings->vat_number = 'DE123456789';
|
||||
$settings->id_number = 'HRB 12345';
|
||||
$settings->use_credits_payment = 'always';
|
||||
$settings->timezone_id = '1'; // CET (Central European Time)
|
||||
$settings->entity_send_time = 0;
|
||||
$settings->e_invoice_type = 'PEPPOL';
|
||||
$settings->currency_id = '3';
|
||||
|
||||
$company = Company::factory()->create([
|
||||
'account_id' => $this->account->id,
|
||||
'settings' => $settings,
|
||||
]);
|
||||
|
||||
$this->user->companies()->attach($company->id, [
|
||||
'account_id' => $this->account->id,
|
||||
'is_owner' => true,
|
||||
'is_admin' => 1,
|
||||
'is_locked' => 0,
|
||||
'permissions' => '',
|
||||
'notifications' => CompanySettings::notificationAdminDefaults(),
|
||||
'settings' => null,
|
||||
]);
|
||||
|
||||
Client::unguard();
|
||||
|
||||
$c =
|
||||
Client::create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $this->user->id,
|
||||
'name' => 'Beispiel Firma GmbH',
|
||||
'website' => 'https://www.beispiel-firma.de',
|
||||
'private_notes' => 'Dies sind private Notizen zum Testkunden.',
|
||||
'balance' => 0,
|
||||
'paid_to_date' => 0,
|
||||
'vat_number' => 'DE654321987',
|
||||
'id_number' => 'HRB 12345', // Typical format for German company registration numbers
|
||||
'custom_value1' => '2024-07-22 10:00:00',
|
||||
'custom_value2' => 'blau',
|
||||
'custom_value3' => 'musterwort',
|
||||
'custom_value4' => 'test@example.com',
|
||||
'address1' => 'Musterstraße 123',
|
||||
'address2' => '2. Etage, Büro 45',
|
||||
'city' => 'München',
|
||||
'state' => 'Bayern',
|
||||
'postal_code' => '80331',
|
||||
'country_id' => '276', // Germany
|
||||
'shipping_address1' => 'Musterstraße 123',
|
||||
'shipping_address2' => '2. Etage, Büro 45',
|
||||
'shipping_city' => 'München',
|
||||
'shipping_state' => 'Bayern',
|
||||
'shipping_postal_code' => '80331',
|
||||
'shipping_country_id' => '276', // Germany
|
||||
'settings' => ClientSettings::Defaults(),
|
||||
'client_hash' => \Illuminate\Support\Str::random(32),
|
||||
'routing_id' => '',
|
||||
]);
|
||||
|
||||
|
||||
$item = new InvoiceItem();
|
||||
$item->product_key = "Product Key";
|
||||
$item->notes = "Product Description";
|
||||
$item->cost = 10;
|
||||
$item->quantity = 10;
|
||||
$item->tax_rate1 = 19;
|
||||
$item->tax_name1 = 'mwst';
|
||||
|
||||
$invoice = Invoice::factory()->create([
|
||||
'company_id' => $company->id,
|
||||
'user_id' => $this->user->id,
|
||||
'client_id' => $c->id,
|
||||
'discount' => 0,
|
||||
'uses_inclusive_taxes' => false,
|
||||
'status_id' => 1,
|
||||
'tax_rate1' => 0,
|
||||
'tax_name1' => '',
|
||||
'tax_rate2' => 0,
|
||||
'tax_rate3' => 0,
|
||||
'tax_name2' => '',
|
||||
'tax_name3' => '',
|
||||
'line_items' => [$item],
|
||||
'number' => 'DE-'.rand(1000, 100000),
|
||||
'date' => now()->format('Y-m-d')
|
||||
]);
|
||||
|
||||
$invoice = $invoice->calc()->getInvoice();
|
||||
$invoice->service()->markSent()->save();
|
||||
|
||||
|
||||
return $invoice;
|
||||
|
||||
}
|
||||
|
||||
public function testDeRules()
|
||||
{
|
||||
$invoice = $this->createDEData();
|
||||
|
||||
$e_invoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice();
|
||||
|
||||
$stub = json_decode('{"Invoice":{"Note":"Nooo","PaymentMeans":[{"ID":{"value":"afdasfasdfasdfas"},"PayeeFinancialAccount":{"Name":"PFA-NAME","ID":{"value":"DE89370400440532013000"},"AliasName":"PFA-Alias","AccountTypeCode":{"value":"CHECKING"},"AccountFormatCode":{"value":"IBAN"},"CurrencyCode":{"value":"EUR"},"FinancialInstitutionBranch":{"ID":{"value":"DEUTDEMMXXX"},"Name":"Deutsche Bank"}}}]}}');
|
||||
foreach($stub as $key => $value)
|
||||
$e_invoice->{$key} = $value;
|
||||
|
||||
$invoice->e_invoice = $e_invoice;
|
||||
$invoice->save();
|
||||
|
||||
$this->assertInstanceOf(Invoice::class, $invoice);
|
||||
$this->assertInstanceof(\InvoiceNinja\EInvoice\Models\Peppol\Invoice::class, $e_invoice);
|
||||
|
||||
$p = new Peppol($invoice);
|
||||
|
||||
$p->run();
|
||||
$xml = $p->toXml();
|
||||
nlog($xml);
|
||||
$sc = new \App\Services\EDocument\Gateway\Storecove\Storecove();
|
||||
$sc->sendDocument($xml);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user