承接 i3or1s/efakture 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

i3or1s/efakture

Composer 安装命令:

composer require i3or1s/efakture

包简介

Library for e-fakture SEF

README 文档

README

List of services that make use of SEF API to send invoices.

Installation

  • Install library with Composer
  • This library is in beta. Versioning is yet to be supported

Contributing

EFakture is an Open Source library that will remain free. You are most welcomed to create issues and pull requests on github.

Licence

At this moment there is no special licence attached to this product. This will be addressed in the future. There is no intention to limit or in any way disrupt the usage of the library.

Code organization

System depends on the UBL standard to create the objects that are to be sent to SEF.
UBL implementation that library depends on.
All responses from the SEF are built as objects in the Model directory. Storing response results from the SEF is currently done in file system. Support for other types of storage is covered through the use of StorageInterface
Cache folder is by default in location /tmp/sefStorage.
Some of SEF responses are large so API can take some time to cache.

UBL directory contains adapters over standard UBL formats for the purpose of constructing the UBL for SEF and removing the complexity of class instantiation.

Example usage

Initial setup before every API call

$browser = new \React\Http\Browser(); // Used for all the API calls
$apiKey = '*****'; // Obtain key from SEF
$apiService = new \i3or1s\EFakture\Util\EFaktureApi($browser, $apiKey); // Set of available API calls

Retrieve available units

$UnitMeasures = new \i3or1s\EFakture\Service\UnitMeasures();
$measures = $UnitMeasures->retrieve($apiService);
print_r($measures);

Retrieve available companies

$storageManager = new \i3or1s\EFakture\Storage\StorageManager(new \i3or1s\EFakture\Storage\FileSystemStorage(__DIR__.'/cache'));
$companies = new \i3or1s\EFakture\Service\Companies();
$companiesResourceStream = new \i3or1s\EFakture\ResourceStream\FileSystemResourceStream($storageManager->storage, EFakturaAPIRoutes::GET_ALL_COMPANIES->SEFObject());

$listOfCompanies = $companies->retrieve($apiService, $companiesResourceStream, 0,3);
print_r($listOfCompanies);

Find company

For this call to work you should have generated list of companies in the cache.

$storageManager = new \i3or1s\EFakture\Storage\StorageManager(new \i3or1s\EFakture\Storage\FileSystemStorage(__DIR__.'/cache', true));
$companies = new \i3or1s\EFakture\Service\Companies();
$companiesResourceStream = new \i3or1s\EFakture\ResourceStream\FileSystemResourceStream($storageManager->storage, EFakturaAPIRoutes::GET_ALL_COMPANIES->SEFObject());

$listOfCompanies = $companiesResourceStream->getStorageInterface()->seek(EFakturaAPIRoutes::GET_ALL_COMPANIES->SEFObject(), [
    "registrationCode" => "08804516"
]);
print_r($listOfCompanies);

Retrieve TAX exemption reasons

For this call to work you should have generated list of companies in the cache.

$storageManager = new \i3or1s\EFakture\Storage\StorageManager(new \i3or1s\EFakture\Storage\FileSystemStorage(__DIR__.'/cache'));
$taxExemptionListService = new \i3or1s\EFakture\Service\ValueAddedTaxExemptionReasonList();
$taxExemptionResourceStream = new \i3or1s\EFakture\ResourceStream\FileSystemResourceStream($storageManager->storage, EFakturaAPIRoutes::VALUE_ADDED_TAX_EXEMPTION_LIST->SEFObject());
$taxExemptionList = $taxExemptionListService->retrieve($apiService, $taxExemptionResourceStream, 0,1);
print_r($taxExemptionList);

Create and send invoice

Note: Company data should be valid in SEF in order for this to work

$invoice = new \i3or1s\EFakture\UBL\Invoice(
    new \i3or1s\EFakture\UBL\InvoiceDetails(
        'invoice number (01/2022)', new DateTimeImmutable(), new DateTimeImmutable('+ 7days'), new \i3or1s\EFakture\UBL\CBC\InvoiceTypeCode(\i3or1s\EFakture\UBL\CBC\InvoiceTypeCode::COMMERCIAL_INVOICE),
        'RSD', new \i3or1s\EFakture\UBL\CAC\InvoicePeriod(\i3or1s\EFakture\UBL\CAC\InvoicePeriod::DELIVERY_ACTUAL_DATE),
        '123456', new DateTimeImmutable('+ 7days')

    ),
    new \i3or1s\EFakture\UBL\Party(
        'company PIB', null, 'company name', null, 'city', 'RS',
        'company Identification', 'e-mail address', true
    ),
    new \i3or1s\EFakture\UBL\Party(
        'company PIB', null, 'company name', 'address', 'city',
        'RS','company Identification', 'e-mail address', true
    ),
    new \i3or1s\EFakture\UBL\PaymentMeans(
        '30', '(mod97) 123456/2022', 'Tekući račun pravnog lica'
    ),
    [
        new \i3or1s\EFakture\UBL\TaxSubtotal(2801.15, 20),
        new \i3or1s\EFakture\UBL\TaxSubtotal(1825.28, 10),
        new \i3or1s\EFakture\UBL\TaxSubtotal(1560, 0, null, 'PDV-RS-11-1-4'),
    ],
    6186.43, 6186.43, 6929.19, 0, 0, 6929.19,
    [
        new \i3or1s\EFakture\UBL\InvoiceLine(5, $unitMeasures['MTR'], 560.23, 'test item 1', 20, 1),
        new \i3or1s\EFakture\UBL\InvoiceLine(4, $unitMeasures['KMT'], 456.32, 'test item 2', 10, 2),
        new \i3or1s\EFakture\UBL\InvoiceLine(1, $unitMeasures['H87'], 1560, 'test item 3', 0, 3),
    ]
);

$invoiceService = new \i3or1s\EFakture\Service\Invoice();
$sefResponse = $invoiceService->send($apiService, $invoice);
print_r($sefResponse);

i3or1s/efakture 适用场景与选型建议

i3or1s/efakture 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「sef」 「EFakture」 「e-fakture」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 i3or1s/efakture 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 i3or1s/efakture 我们能提供哪些服务?
定制开发 / 二次开发

基于 i3or1s/efakture 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-13