peppol
This commit is contained in:
parent
6b578c436c
commit
5790e71e73
|
|
@ -36,10 +36,10 @@ class CheckSmtpRequest extends Request
|
|||
public function rules()
|
||||
{
|
||||
return [
|
||||
'smtp_host' => 'sometimes|nullable|string|min:3',
|
||||
'smtp_port' => 'sometimes|nullable|integer',
|
||||
'smtp_username' => 'sometimes|nullable|string|min:3',
|
||||
'smtp_password' => 'sometimes|nullable|string|min:3',
|
||||
'smtp_host' => 'required|string|min:3',
|
||||
'smtp_port' => 'required|integer',
|
||||
'smtp_username' => 'required|min:3',
|
||||
'smtp_password' => 'required|min:3',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -53,12 +53,11 @@ class CheckSmtpRequest extends Request
|
|||
$input = $this->input();
|
||||
|
||||
if(isset($input['smtp_username']) && $input['smtp_username'] == '********') {
|
||||
// unset($input['smtp_username']);
|
||||
|
||||
$input['smtp_username'] = $company->smtp_username;
|
||||
}
|
||||
|
||||
if(isset($input['smtp_password']) && $input['smtp_password'] == '********') {
|
||||
// unset($input['smtp_password']);
|
||||
$input['smtp_password'] = $company->smtp_password;
|
||||
}
|
||||
|
||||
|
|
@ -68,14 +67,10 @@ class CheckSmtpRequest extends Request
|
|||
$input['smtp_host'] = $company->smtp_host;
|
||||
}
|
||||
|
||||
|
||||
if(isset($input['smtp_port']) && strlen($input['smtp_port']) >= 3) {
|
||||
|
||||
} else {
|
||||
$input['smtp_port'] = $company->smtp_port;
|
||||
if (!isset($input['smtp_port']) || !is_numeric($input['smtp_port'])) {
|
||||
$input['smtp_port'] = $company->smtp_port ?? 0;
|
||||
}
|
||||
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,6 +163,12 @@ return $this;
|
|||
|
||||
}
|
||||
|
||||
public function addPaymentMeans($paymentMeans): self
|
||||
{
|
||||
$this->paymentMeans[] = $paymentMeans;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTaxTotal( $taxTotal): self
|
||||
{
|
||||
$this->taxTotal = $taxTotal;
|
||||
|
|
|
|||
|
|
@ -21,11 +21,12 @@ class InvoiceLines
|
|||
|
||||
public string $description = '';
|
||||
|
||||
public Tax $tax;
|
||||
public Tax $taxesDutiesFees;
|
||||
|
||||
public array $allowanceCharges = []; //line item discounts
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->tax = new Tax();
|
||||
}
|
||||
|
||||
// Getters and setters
|
||||
|
|
@ -101,12 +102,29 @@ class InvoiceLines
|
|||
|
||||
public function getTax(): Tax
|
||||
{
|
||||
return $this->tax;
|
||||
return $this->taxesDutiesFees;
|
||||
}
|
||||
|
||||
public function setTax(Tax $tax): void
|
||||
{
|
||||
$this->tax = $tax;
|
||||
$this->taxesDutiesFees = $tax;
|
||||
}
|
||||
|
||||
public function getAllowanceCharges(): array
|
||||
{
|
||||
return $this->allowanceCharges;
|
||||
}
|
||||
|
||||
public function setAllowanceCharges(array $allowanceCharges): self
|
||||
{
|
||||
$this->allowanceCharges = $allowanceCharges;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addAllowanceCharge($allowanceCharge): self
|
||||
{
|
||||
$this->allowanceCharges[] = $allowanceCharge;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Party
|
|||
{
|
||||
public function __construct(
|
||||
public Contact $contact,
|
||||
?public string $companyName = null,
|
||||
?public Address $address = null,
|
||||
public ?string $companyName = null,
|
||||
public ?Address $address = null
|
||||
) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Services\EDocument\Gateway\Storecove\Models;
|
||||
|
||||
class PaymentMeans
|
||||
{
|
||||
|
||||
private array $code_keys = [
|
||||
'10' => 'cash', // In cash
|
||||
'20' => 'bank_cheque', // Cheque
|
||||
'25' => 'cashiers_cheque', // Certified cheque
|
||||
'30' => 'credit_transfer', // Credit transfer
|
||||
'31' => 'debit_transfer', // Debit transfer
|
||||
'48' => 'card', // Bank card (also used by sg_card)
|
||||
'49' => 'direct_debit', // Direct debit
|
||||
'50' => 'se_plusgiro', // Payment by postgiro
|
||||
'54' => 'card', // Credit card
|
||||
'55' => 'card', // Debit card
|
||||
'56' => 'se_bankgiro', // Bankgiro
|
||||
'58' => 'sepa_credit_transfer', // SEPA credit transfer
|
||||
'59' => 'sepa_direct_debit', // SEPA direct debit
|
||||
'68' => 'online_payment_service', // Online payment service
|
||||
'93' => 'sg_giro', // Reference giro
|
||||
];
|
||||
|
||||
|
||||
private array $codes = [
|
||||
'cash' => ['description' => 'The invoice was/is paid in cash'],
|
||||
'bank_cheque' => ['description' => 'The invoice was/is paid in cash'],
|
||||
'cashiers_cheque' => ['description' => 'The invoice was/is paid in cash'],
|
||||
'credit_transfer' => [
|
||||
'description' => 'The amount is to be transfered into a bank account',
|
||||
'required' => ['account'], // Account Number
|
||||
'optional' => ['branche_code', 'holder'], //BIC - BSB, The account holder name
|
||||
],
|
||||
'sepa_credit_transfer' => [
|
||||
'description' => 'The amount is to be transfered into a bank account',
|
||||
'required' => ['account'], // Account Number
|
||||
'optional' => ['branche_code', 'holder'], //BIC - BSB, The account holder name
|
||||
],
|
||||
'debit_transfer' => [
|
||||
'description' => 'Used for CreditNotes. The amount is to be transfered by the sender of the document into the bank account of the receiver of the document. Relevant additional fields',
|
||||
'required' => ['account'], // Account Number
|
||||
'optional' => ['branche_code', 'holder'], //BIC - BSB, The account holder name
|
||||
],
|
||||
'direct_debit' => [
|
||||
'description' => 'Direct debit. Relevant additional fields:',
|
||||
'required' => ['account','mandate'], // Account Number
|
||||
'optional' => ['holder','network'], //The account holder name - VISA,SEPA,MASTERCARD,
|
||||
],
|
||||
'sepa_direct_debit' => [
|
||||
'description' => 'Direct debit. Relevant additional fields:',
|
||||
'required' => ['account'], // last 4 only of card
|
||||
'optional' => ['holder'], //The account holder name
|
||||
],
|
||||
'card' => [
|
||||
'description' => 'E.g. credit or debit card. Relevant additional fields:',
|
||||
'required' => ['account',], // Account Number
|
||||
'optional' => ['holder','network'], //The account holder name, VISA,SEPA,MASTERCARD,
|
||||
],
|
||||
'online_payment_service' => [
|
||||
'description' => 'An online payment service has been or will be used. Relevant additional fields:',
|
||||
'required' => ['network'], //ie PayPal
|
||||
'optional' => ['url'], //The URL to execute the paymetn
|
||||
],
|
||||
'aunz_npp_payid' => [
|
||||
'description' => 'Australia/New Zealand New Payments Platform. Relevant additional fields:',
|
||||
'required' => ['account'], //PayID - email, abn, phone number
|
||||
'optional' => [],
|
||||
],
|
||||
'aunz_npp' => [
|
||||
'description' => 'Australia/New Zealand New Payments Platform. Relevant additional fields:',
|
||||
'required' => ['account'], //PayID - email, abn, phone number
|
||||
'optional' => [],
|
||||
],
|
||||
'aunz_npp_payto' => [
|
||||
'description' => 'Australia/New Zealand New Payments Platform. Relevant additional',
|
||||
'required' => ['account','mandate'], //PayID - email, abn, phone number
|
||||
'optional' => [],
|
||||
],
|
||||
'se_bankgiro' => [
|
||||
'description' => 'Swedish Bankgiro. Relevant additional fields:',
|
||||
'required' => ['account'],
|
||||
'optional' => ['holder'],
|
||||
],
|
||||
'se_plusgiro' => [
|
||||
'description' => 'Swedish Plusgiro. Relevant additional fields:',
|
||||
'required' => ['account'], //2-8 digits
|
||||
'optional' => ['holder'],
|
||||
],
|
||||
'sg_giro' => [
|
||||
'description' => 'Singapore GIRO-system (direct debit). Relevant additional fields: none.',
|
||||
'required' => [],
|
||||
'optional' => [],
|
||||
],
|
||||
'sg_card' => [
|
||||
'description' => 'Singapore CreditCard payment. Relevant additional fields: none.',
|
||||
'required' => [],
|
||||
'optional' => [],
|
||||
],
|
||||
'sg_paynow' => [
|
||||
'description' => 'Singapore PayNow Corporate. Relevant additional fields:',
|
||||
'required' => ['account'],
|
||||
'optional' => [],
|
||||
],
|
||||
'it_mav' => [
|
||||
'description' => '',
|
||||
'required' => [],
|
||||
'optional' => [],
|
||||
],
|
||||
'it_pagopa' => [
|
||||
'description' => '',
|
||||
'required' => [],
|
||||
'optional' => [],
|
||||
],
|
||||
'undefined' => [
|
||||
'description' => '',
|
||||
'required' => [],
|
||||
'optional' => [],
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
public ?string $code = null, //payment means code
|
||||
public ?string $account = null, //account number
|
||||
public ?string $paymentId = null, //matching reference (invoice #)
|
||||
public ?string $branche_code = null, //bic
|
||||
public ?string $holder = null, //account holder name
|
||||
public ?string $network = null, // payment network, ie VISA, SEPA, MASTERCARD
|
||||
public ?string $mandate = null // mandate
|
||||
){}
|
||||
|
||||
|
||||
public function setCodeProps($ubl_payment_means):self
|
||||
{
|
||||
|
||||
$ubl_code = $ubl_payment_means->PaymentMeansCode;
|
||||
|
||||
if (isset($this->code_keys[$ubl_code])) {
|
||||
$this->code = $this->code_keys[$ubl_code];
|
||||
}
|
||||
|
||||
if (isset($this->codes[$ubl_code])) {
|
||||
$this->code = $ubl_code;
|
||||
}
|
||||
|
||||
if($ubl_payment_means->CardAccount ?? false) {
|
||||
// If it is a card payment, the last 4 numbers may not be known?
|
||||
$this->account = '9999';
|
||||
$this->holder = strlen($ubl_payment_means->CardAccount->HolderName) > 1 ? $ubl_payment_means->CardAccount->HolderName : null;
|
||||
$this->network = $ubl_payment_means->CardAccount->CardTypeCode;
|
||||
}
|
||||
|
||||
if($ubl_payment_means->PayeeFinancialAccount ?? false){
|
||||
|
||||
$this->account = $ubl_payment_means->PayeeFinancialAccount->ID;
|
||||
$this->branche_code = $ubl_payment_means->FinancialInstitutionBranch->ID;
|
||||
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,10 +14,5 @@ namespace App\Services\EDocument\Gateway\Storecove\Models;
|
|||
|
||||
class PaymentTerms
|
||||
{
|
||||
public string $note;
|
||||
|
||||
public function __construct(string $note)
|
||||
{
|
||||
$this->note = $note;
|
||||
}
|
||||
public function __construct(public string $note){}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,56 +16,9 @@ use Symfony\Component\Serializer\Annotation\SerializedName;
|
|||
|
||||
class Tax
|
||||
{
|
||||
#[SerializedName('Item.ClassifiedTaxCategory.0.Percent')]
|
||||
public float $taxPercentage = 0.0;
|
||||
public function __construct(
|
||||
public float $percentage,
|
||||
public string $country
|
||||
){}
|
||||
|
||||
#[SerializedName('LineExtensionAmount.amount')]
|
||||
public float $taxableAmount = 0.0;
|
||||
|
||||
#[SerializedName('TaxTotal.0.TaxAmount.amount')]
|
||||
public float $taxAmount = 0.0;
|
||||
|
||||
#[SerializedName('Item.ClassifiedTaxCategory.0.ID.value')]
|
||||
public string $taxCategory = '';
|
||||
|
||||
// Getters and setters
|
||||
public function getTaxPercentage(): float
|
||||
{
|
||||
return $this->taxPercentage;
|
||||
}
|
||||
|
||||
public function setTaxPercentage(float $taxPercentage): void
|
||||
{
|
||||
$this->taxPercentage = $taxPercentage;
|
||||
}
|
||||
|
||||
public function getTaxableAmount(): float
|
||||
{
|
||||
return $this->taxableAmount;
|
||||
}
|
||||
|
||||
public function setTaxableAmount(float $taxableAmount): void
|
||||
{
|
||||
$this->taxableAmount = $taxableAmount;
|
||||
}
|
||||
|
||||
public function getTaxAmount(): float
|
||||
{
|
||||
return $this->taxAmount;
|
||||
}
|
||||
|
||||
public function setTaxAmount(float $taxAmount): void
|
||||
{
|
||||
$this->taxAmount = $taxAmount;
|
||||
}
|
||||
|
||||
public function getTaxCategory(): string
|
||||
{
|
||||
return $this->taxCategory;
|
||||
}
|
||||
|
||||
public function setTaxCategory(string $taxCategory): void
|
||||
{
|
||||
$this->taxCategory = $taxCategory;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ use App\Services\EDocument\Gateway\Storecove\Models\AccountingSupplierParty;
|
|||
use App\Services\EDocument\Gateway\Storecove\Models\Address;
|
||||
use App\Services\EDocument\Gateway\Storecove\Models\Contact;
|
||||
use App\Services\EDocument\Gateway\Storecove\Models\Invoice as StorecoveInvoice;
|
||||
use App\Services\EDocument\Gateway\Storecove\Models\InvoiceLines;
|
||||
use App\Services\EDocument\Gateway\Storecove\Models\Party;
|
||||
use App\Services\EDocument\Gateway\Storecove\Models\PaymentMeans;
|
||||
use App\Services\EDocument\Gateway\Storecove\Models\References;
|
||||
|
||||
class StorecoveTransformer implements TransformerInterface
|
||||
|
|
@ -47,7 +49,6 @@ class StorecoveTransformer implements TransformerInterface
|
|||
$this->s_invoice->setAccountingCost($peppolInvoice->AccountingCostCode);
|
||||
}
|
||||
|
||||
|
||||
$customer_company_name = $peppolInvoice->AccountingCustomerParty->Party->PartyName[0]->Name ?? '';
|
||||
|
||||
$address = new Address(
|
||||
|
|
@ -70,39 +71,29 @@ class StorecoveTransformer implements TransformerInterface
|
|||
$acp = new AccountingCustomerParty($party_identifiers, $customer_party);
|
||||
$this->s_invoice->setAccountingCustomerParty($acp);
|
||||
|
||||
$supplier_part = new Party()
|
||||
// $asp = new AccountingSupplierParty($party);
|
||||
|
||||
$supplier_contact = new Contact(
|
||||
email: $peppolInvoice->AccountingSupplierParty->Party->Contact->ElectronicMail,
|
||||
firstName: $peppolInvoice->AccountingSupplierParty->Party->Contact->Name ?? null,
|
||||
phone: $peppolInvoice->AccountingSupplierParty->Party->Contact->Telephone ?? null,
|
||||
);
|
||||
|
||||
if (isset($peppolInvoice->AccountingSupplierParty->Party)) {
|
||||
$supplier = $peppolInvoice->AccountingSupplierParty->Party;
|
||||
$this->s_invoice->setAccountingSupplierParty([
|
||||
'name' => $supplier->PartyName[0]->Name ?? '',
|
||||
'vatNumber' => $supplier->PartyIdentification[0]->ID->value ?? '',
|
||||
'streetName' => $supplier->PostalAddress->StreetName ?? '',
|
||||
'cityName' => $supplier->PostalAddress->CityName ?? '',
|
||||
'postalZone' => $supplier->PostalAddress->PostalZone ?? '',
|
||||
'countryCode' => $supplier->PostalAddress->Country->IdentificationCode->value ?? '',
|
||||
]);
|
||||
}
|
||||
$supplier_party = new Party(contact: $supplier_contact);
|
||||
$asp = new AccountingSupplierParty($supplier_party);
|
||||
$this->s_invoice->setAccountingSupplierParty($asp);
|
||||
|
||||
// if (isset($peppolInvoice->AccountingCustomerParty->Party)) {
|
||||
// $customer = $peppolInvoice->AccountingCustomerParty->Party;
|
||||
// $this->s_invoice->setAccountingCustomerParty([
|
||||
// 'name' => $customer->PartyName[0]->Name ?? '',
|
||||
// 'vatNumber' => $customer->PartyIdentification[0]->ID->value ?? '',
|
||||
// 'streetName' => $customer->PostalAddress->StreetName ?? '',
|
||||
// 'cityName' => $customer->PostalAddress->CityName ?? '',
|
||||
// 'postalZone' => $customer->PostalAddress->PostalZone ?? '',
|
||||
// 'countryCode' => $customer->PostalAddress->Country->IdentificationCode->value ?? '',
|
||||
// ]);
|
||||
// }
|
||||
if (isset($peppolInvoice->PaymentMeans[0])) {
|
||||
|
||||
// if (isset($peppolInvoice->PaymentMeans[0])) {
|
||||
// $this->s_invoice->setPaymentMeans([
|
||||
// 'paymentID' => $peppolInvoice->PaymentMeans[0]->PayeeFinancialAccount->ID->value ?? '',
|
||||
// ]);
|
||||
// }
|
||||
$payment_means = new PaymentMeans();
|
||||
$payment_means->setCodeProps($peppolInvoice->PaymentMeans[0]);
|
||||
|
||||
$this->s_invoice->addPaymentMeans($payment_means);
|
||||
}
|
||||
|
||||
foreach($peppolInvoice->InvoiceLine as $invoiceLine)
|
||||
{
|
||||
$line = new InvoiceLines();
|
||||
}
|
||||
|
||||
// // Map tax total at invoice level
|
||||
// $taxTotal = [];
|
||||
|
|
|
|||
|
|
@ -915,7 +915,6 @@ class Peppol extends AbstractService
|
|||
|
||||
}
|
||||
|
||||
|
||||
$address = new Address();
|
||||
$address->CityName = $this->invoice->company->settings->city;
|
||||
$address->StreetName = $this->invoice->company->settings->address1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue