1. Go to this page and download the library: Download ahmeti/sovos library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$service = new Ahmeti\Sovos\Api\ArchiveService(
username: 'EARSIV_WS_Kullanici',
password: 'EARSIV_WS_Sifre',
test: true
);
// Son parametre, TEST ortamında ise true yapabilirsiniz veya boş bırakabilirsiniz.
$getDocument = new Ahmeti\Sovos\Archive\GetUserList(
vknTckn: 'GONDERICI_VKN_TCKN',
);
$result = $service->GetUserListRequest($getDocument);
$invoice = new Ahmeti\Ubl\Invoice(
UBLVersionID: '2.1', // Uluslararası fatura standardı 2.1
CustomizationID: 'TR1.2', // GİB UBLTR olarak isimlendirdiği Türkiye'ye özgü 1.2 efatura formatını kullanıyor.
ProfileID: 'EARSIVFATURA',
ID: 'FA02017000000021', // Eğer fatura ID FIT tarafından oluşacak ise, ID alanı boş, CUST_INV_ID alanı dolu gelmelidir. Eğer kullanıcı firma tarafından oluşacak ise, ID alanı dolu CUST_INV_ID alanı boş olarak gönderilmeli.
CopyIndicator: false, // Kopyası mı, asıl süret mi olduğu belirlenir
UUID: '1d8e1b1b-4b3b-4e3f-8b1f-0e2f1b1b2c1d', // Fatura UUID
IssueDate: '2021-09-01', // Fatura tarihi
IssueTime: '10:00:00', // Fatura saati
InvoiceTypeCode: 'SATIS', // Gönderilecek fatura çeşidi, satış, iade vs.
DocumentCurrencyCode: 'TRY', // E-fatura para birimi
LineCountNumeric: 1, // Fatura kalemlerinin sayısı
Note: ['Test not'], // İsteğe bağlı not alanı
AdditionalDocumentReference: [
// Fatura ID otomatik oluşacak ise bu alanı göndermelisiniz.
new Ahmeti\Ubl\DocumentReference(
ID: '000000000000001', // ERP Fatura ID
IssueDate: '2021-09-01', // Fatura tarihi Y-m-d
DocumentTypeCode: 'CUST_INV_ID' // Fatura tipi
),
new Ahmeti\Ubl\DocumentReference(
ID: '0100',
IssueDate: '2021-09-01',
DocumentTypeCode: 'OUTPUT_TYPE'
),
new Ahmeti\Ubl\DocumentReference(
ID: 'KAGIT',
IssueDate: '2021-09-01',
DocumentTypeCode: 'EREPSENDT'
),
],
Signature: new Ahmeti\Ubl\Signature(
ID: ['val' => 'ALICI_VKN_TCKN', 'attrs' => ['schemeID = "VKN_TCKN"']],
SignatoryParty: new Ahmeti\Ubl\SignatoryParty(
PartyIdentification: new Ahmeti\Ubl\PartyIdentification(
ID: ['val' => 'ALICI_VKN_TCKN', 'attrs' => ['schemeID = "VKN"']]
),
PostalAddress: new Ahmeti\Ubl\PostalAddress(
StreetName: 'deneme cad',
BuildingName: '01',
CitySubdivisionName: 'ilce',
CityName: 'il',
PostalZone: '34000',
Country: new Ahmeti\Ubl\Country(
Name: 'TÜRKİYE'
)
)
),
DigitalSignatureAttachment: new Ahmeti\Ubl\DigitalSignatureAttachment(
ExternalReference: new Ahmeti\Ubl\ExternalReference(
URI: '#Signature'
)
)
),
AccountingSupplierParty: new Ahmeti\Ubl\AccountingSupplierParty(
Party: new Ahmeti\Ubl\Party(
WebsiteURI: 'https://ahmeti.com.tr',
PartyIdentification: new Ahmeti\Ubl\PartyIdentification(
ID: ['val' => 'GONDERICI_VKN_TCKN', 'attrs' => ['schemeID="TCKN"']]
),
PartyName: new Ahmeti\Ubl\PartyName(
Name: 'Ahmet İmamoğlu'
),
Person: new Ahmeti\Ubl\Person(
FirstName: 'Ahmet',
FamilyName: 'İmamoğlu'
),
PostalAddress: new Ahmeti\Ubl\PostalAddress(
Room: 'kapi no',
StreetName: 'cadde',
BuildingName: 'bina',
BuildingNumber: 'bina no',
CitySubdivisionName: 'mahalle',
CityName: 'şehir',
PostalZone: 'posta kodu',
Region: 'asd',
Country: new Ahmeti\Ubl\Country(
Name: 'Türkiye'
)
),
PartyTaxScheme: new Ahmeti\Ubl\PartyTaxScheme(
TaxScheme: new Ahmeti\Ubl\TaxScheme(
Name: 'Nilüfer'
)
),
Contact: new Ahmeti\Ubl\Contact(
Telephone: 'telefon',
Telefax: 'faks',
ElectronicMail: 'mail adresi'
)
)
),
AccountingCustomerParty: new Ahmeti\Ubl\AccountingCustomerParty(
Party: new Ahmeti\Ubl\Party(
WebsiteURI: 'http://unlembilisim.com',
PartyIdentification: new Ahmeti\Ubl\PartyIdentification(
ID: ['val' => 'ALICI_VKN_TCKN', 'attrs' => ['schemeID="TCKN"']]
),
PartyName: new Ahmeti\Ubl\PartyName(
Name: 'ALICI UNVANI'
),
Person: new Ahmeti\Ubl\Person(
FirstName: 'ALICI ADI',
FamilyName: 'ALICI SOYADI'
),
PostalAddress: new Ahmeti\Ubl\PostalAddress(
Room: 'kapi no',
StreetName: 'cadde',
BuildingName: 'bina',
BuildingNumber: 'bina no',
CitySubdivisionName: 'mahalle',
CityName: 'şehir',
PostalZone: 'posta kodu',
Region: 'asd',
Country: new Ahmeti\Ubl\Country(
Name: 'Türkiye'
)
),
PartyTaxScheme: new Ahmeti\Ubl\PartyTaxScheme(
TaxScheme: new Ahmeti\Ubl\TaxScheme(
Name: 'Nilüfer'
)
),
Contact: new Ahmeti\Ubl\Contact(
Telephone: 'telefon',
Telefax: 'faks',
ElectronicMail: 'mail adresi'
)
)
),
TaxTotal: new Ahmeti\Ubl\TaxTotal(
TaxAmount: ['val' => '0.01', 'attrs' => ['currencyID="TRY"']],
TaxSubtotal: new Ahmeti\Ubl\TaxSubtotal(
TaxableAmount: ['val' => '0.99', 'attrs' => ['currencyID="TRY"']],
TaxAmount: ['val' => '0.01', 'attrs' => ['currencyID="TRY"']],
TaxCategory: new Ahmeti\Ubl\TaxCategory(
TaxScheme: new Ahmeti\Ubl\TaxScheme(
Name: 'KDV',
TaxTypeCode: '0015'
)
)
)
),
LegalMonetaryTotal: new Ahmeti\Ubl\LegalMonetaryTotal(
LineExtensionAmount: ['val' => '1', 'attrs' => ['currencyID="TRY"']],
TaxExclusiveAmount: ['val' => '0.99', 'attrs' => ['currencyID="TRY"']],
TaxInclusiveAmount: ['val' => '1', 'attrs' => ['currencyID="TRY"']],
PayableAmount: ['val' => '1', 'attrs' => ['currencyID="TRY"']]
),
InvoiceLine: [
new Ahmeti\Ubl\InvoiceLine(
ID: '1',
InvoicedQuantity: ['val' => '1', 'attrs' => ['unitCode="CMT"']],
LineExtensionAmount: ['val' => '0.99', 'attrs' => ['currencyID="TRY"']],
Item: new Ahmeti\Ubl\Item(
Name: 'Test Ürün'
),
Price: new Ahmeti\Ubl\Price(
PriceAmount: ['val' => '1', 'attrs' => ['currencyID="TRY"']]
)
),
]
);
$xml = (new Ahmeti\Ubl\Utils\UblInvoice($invoice))->getXML();