ismailua/ubltr-invoice 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ismailua/ubltr-invoice

最新稳定版本:v1.0.0

Composer 安装命令:

composer require ismailua/ubltr-invoice

包简介

A Laravel package for generating UBL-TR compliant XML invoices

README 文档

README

A Laravel package for generating UBL-TR compliant XML invoices

Installation

  1. Install the package via Composer:
composer require ismailua/ubltr-invoice
  1. Publish the configuration file:
php artisan vendor:publish --tag=config

Usage

use Ismailua\UblTrInvoice\Facades\UBLInvoice;
use Ismailua\UblTrInvoice\Models\UblInvoice\Invoice;
use Ismailua\UblTrInvoice\Models\UblInvoice\Party;
use Ismailua\UblTrInvoice\Models\UblInvoice\Address;
use Ismailua\UblTrInvoice\Models\UblInvoice\PartyIdentification;
use Ismailua\UblTrInvoice\Models\UblInvoice\PartyTaxScheme;
use Ismailua\UblTrInvoice\Models\UblInvoice\Contact;
use Ismailua\UblTrInvoice\Models\UblInvoice\Tax;
use Ismailua\UblTrInvoice\Models\UblInvoice\TaxSubtotal;
use Ismailua\UblTrInvoice\Models\UblInvoice\TaxScheme;
use Ismailua\UblTrInvoice\Models\UblInvoice\LegalMonetaryTotal;
use Ismailua\UblTrInvoice\Models\UblInvoice\InvoiceLine;
use Ismailua\UblTrInvoice\Models\UblInvoice\Item;
use Ismailua\UblTrInvoice\Models\UblInvoice\Price;

$invoice = new Invoice();
$invoice->id = 'TST2021000000002';
$invoice->issueDate = '2021-02-10';
$invoice->issueTime = '11:11:24';
$invoice->note = 'Yalnız Bir TL OnSekiz kuruş';
$invoice->lineCountNumeric = 1;

// Supplier Party
$supplier = new Party();
$supplier->addPartyIdentification((new PartyIdentification())->setId('1923001923')->setSchemeID('VKN'));
$supplier->addPartyIdentification((new PartyIdentification())->setId('1111111111111111')->setSchemeID('MERSISNO'));
$supplier->setPartyName('İsmail ÇAKIR');
$supplier->setPostalAddress((new Address())
    ->setRoom('19')
    ->setBuildingName('Test Binası')
    ->setBuildingNumber('23')
    ->setCitySubdivisionName('Kartal')
    ->setCityName('İstanbul')
    ->setCountryCode('TR')
    ->setCountryName('Türkiye'));
$supplier->setPartyTaxScheme((new PartyTaxScheme())->setName('Kartal Vergi Dairesi'));
$invoice->accountingSupplierParty = $supplier;

// Customer Party
$customer = new Party();
$customer->addPartyIdentification((new PartyIdentification())->setId('6090408038')->setSchemeID('VKN'));
$customer->setPartyName('FIRMA ELEKTRONİK TİCARET HİZMETLERİ ANONİM ŞİRKETİ');
$customer->setPostalAddress((new Address())
    ->setStreetName('Test')
    ->setCitySubdivisionName('Test')
    ->setCityName('Test')
    ->setCountryCode('TR')
    ->setCountryName('Türkiye'));
$customer->setPartyTaxScheme((new PartyTaxScheme())->setName('test vergi dairesi'));
$customer->setContact((new Contact())->setElectronicMail('test@test.com'));
$invoice->accountingCustomerParty = $customer;

// Tax Total
$tax = new Tax();
$tax->setTaxAmount(0.18);
$tax->addTaxSubtotal((new TaxSubtotal())
    ->setTaxableAmount(1)
    ->setTaxAmount(0.18)
    ->setPercent(18)
    ->setTaxScheme((new TaxScheme())->setName('KDV GERCEK')->setTaxTypeCode('0015')));
$invoice->taxTotal = $tax;

// Legal Monetary Total
$legalMonetaryTotal = new LegalMonetaryTotal();
$legalMonetaryTotal->setLineExtensionAmount(1);
$legalMonetaryTotal->setTaxExclusiveAmount(1);
$legalMonetaryTotal->setTaxInclusiveAmount(1.18);
$legalMonetaryTotal->setPayableAmount(1.18);
$invoice->legalMonetaryTotal = $legalMonetaryTotal;

// Invoice Line
$invoiceLine = new InvoiceLine();
$invoiceLine->setId('1');
$invoiceLine->setInvoicedQuantity(1);
$invoiceLine->setLineExtensionAmount(1);
$invoiceLine->setTaxTotal((new Tax())
    ->setTaxAmount(0.18)
    ->addTaxSubtotal((new TaxSubtotal())
        ->setTaxableAmount(1)
        ->setTaxAmount(0.18)
        ->setPercent(18)
        ->setTaxScheme((new TaxScheme())->setName('KDV GERCEK')->setTaxTypeCode('0015'))));
$invoiceLine->setItem((new Item())
    ->setDescription('test')
    ->setName('test')
    ->setSellersItemIdentification('test'));
$invoiceLine->setPrice((new Price())->setPriceAmount(1));
$invoice->invoiceLines = [$invoiceLine];

$xml = UBLInvoice::generate($invoice);
file_put_contents('invoice.xml', $xml);

Configuration

The configuration file is located at config/ubl-invoice.php. You can modify default values such as currency and invoice type.

Testing

Run the tests using:

vendor/bin/phpunit

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This package is open-sourced software licensed under the MIT license.

Support

ismailua@gmail.com

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-30