ag84ark / smartbill

适用于Laravel的SmartBill.ro API封装

v1.1.4 2024-02-06 11:59 UTC

This package is auto-updated.

Last update: 2024-09-10 16:00:01 UTC


README

Latest Version on Packagist Total Downloads

SmartBill.ro API集成于Laravel。
这个项目最初是从necenzurat/smartbill分叉出来的,现在是一个独立的包。

安装

您可以通过composer安装此包

composer require ag84ark/smartbill

您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="Ag84ark\SmartBill\SmartBillServiceProvider" --tag="laravel-smartbill-config"

文档

制作中

用法

发票

使用资源

use Ag84ark\SmartBill\SmartBill;
use Ag84ark\SmartBill\Resources\Invoice;
use Ag84ark\SmartBill\Resources\Client;
use Ag84ark\SmartBill\Resources\InvoiceProduct;

$invoice = Invoice::make();
$invoice->setIsDraft(true);

$invoice->setClient(
  Client::make()
    ->setName("ACME CO")
    ->setVatCode("RO12345678")
    ->setRegCom("")
    ->setAddress("Main street, no 10")
    ->setIsTaxPayer(false)
    ->setCity("Bucharest")
    ->setCounty("Bucharest")
    ->setCountry("Romania")
    ->setEmail("acme@example.com")
);

$invoice->addProduct(
  InvoiceProduct::make()
    ->setName("Produs 1")
    ->setCode("ccd1")
    ->setMeasuringUnitName("buc")
    ->setCurrency("RON")
    ->setQuantity(2)
    ->setPrice(10)
    ->setIsTaxIncluded(true)
    ->setTaxName("Redusa")
    ->setTaxPercentage(9)
);

$invoice->addProduct(InvoiceProduct::makeValoricDiscountItem("Discount", 5));

$invoice->setPayment(
  InvoicePayment::make()
    ->setIsCash(true)
    ->setType(Ag84ark\SmartBill\Enums\PaymentType::OrdinPlata)
    ->setValue(15)
);

echo 'Emitere factura simpla: ';
try {
    $smartbill = new SmartBill();
    $output = $smartbill->invoiceEndpoint->createInvoice($invoice);
    $invoiceNumber = $output->getNumber();
    $invoiceSeries = $output->getSeries();
    echo $invoiceSeries . $invoiceNumber;
} catch (\Exception $ex) {
    echo $ex->getMessage();
}

使用数组数据

$invoice = [
    'companyVatCode' => config('smartbill.vatCode'),
    'client' 		=> [
        'name' 			=> "ACME CO",
        'vatCode' 		=> "RO12345678",
        'regCom' 		=> "",
        'address' 		=> "Main street, no 10",
        'isTaxPayer' 	=> false,
        'city' 			=> "Bucharest",
        'country' 		=> "Romania",
        'email' 		=> "acme@example.com",
    ],
    'issueDate'      => date('Y-m-d'),
    'seriesName'     => config('smartbill.invoiceSeries'),
    'isDraft'        => false,
    'dueDate'		=> date('Y-m-d', time() + 3600 * 24 * 30),
    'mentions'		=> '',
    'observations'   => '',
    'deliveryDate'   => date('Y-m-d', time() + 3600 * 24 * 10),
    'precision'      => 2,
    'products'		=> [
        [
            'name' 				=> "Produs 1",
            'code' 				=> "ccd1",
            'isDiscount' 		=> false,
            'measuringUnitName' => "buc",
            'currency' 			=> "RON",
            'quantity' 			=> 2,
            'price' 			=> 10,
            'isTaxIncluded' 	=> true,
            'taxName' 			=> "Redusa",
            'taxPercentage' 	=> 9,
            'isService'         => false,
            'saveToDb'          => false,
        ],
    ],
];

echo 'Emitere factura simpla: ';
try {
    $smartbill = new SmartBill();
    $output = $smartbill->invoiceEndpoint->createInvoiceFromArray($invoice);
    $invoiceNumber = $output->getNumber();
    $invoiceSeries = $output->getSeries();
    echo $invoiceSeries . $invoiceNumber;
} catch (\Exception $ex) {
    echo $ex->getMessage();
}

测试

Partially tested

变更日志

请参阅CHANGELOG以获取更多信息,了解最近有哪些变化。

贡献

请参阅CONTRIBUTING以获取详细信息。

安全

如果您发现任何安全相关的问题,请使用问题跟踪器。

许可证

WTFPL。请参阅许可证文件以获取更多信息。