Polska wersja / English version
invoice-gen
Instalacja
invoice-gen = "0.0.3"
Użycie
FA (3)
use ;
use Invoice;
use Decimal;
use FromStr;
let seller = new
.set_address
.build;
let buyer = new
.set_address
.build;
let line = new
.build;
let mut invoice = default;
invoice.subject1 = seller;
invoice.subject2 = buyer;
invoice.invoice_body.invoice_number = "FV/2026/0001".to_string;
invoice.invoice_body.issue_date = now.format.to_string;
invoice.invoice_body.currency_code = new;
invoice.invoice_body.lines = vec!;
let xml = invoice.to_xml.unwrap;
println!;
FA (2)
use ;
use Decimal;
use NaiveDate;
let seller = new.set_address.build;
let buyer = new.set_address.build;
let l1 = new.build;
let inv = new
.set_invoice_number
.set_issue_date
.set_currency
.set_seller
.set_buyer
.add_lines
.build
.unwrap;
let xml = inv.to_xml.unwrap;
println!;
SellerBuilder
new(nip: &str, name: &str) -> SellerBuilder
- nip: NIP sprzedawcy
- name: nazwa sprzedawcy
set_address(self, country_code: &str, street: &str, building_number: &str, flat_number: Option<&str>, city: &str, postal_code: &str) -> SellerBuilder
- country_code: kod kraju (PL)
- street: ulica
- building_number: numer budynku
- flat_number: numer lokalu (opcjonalny)
- city: miasto
- postal_code: kod pocztowy
build(self) -> Subject1 (Obiekt reprezentujący sprzedawcę)
BuyerBuilder
new(nip: &str, name: &str) -> BuyerBuilder
- nip: NIP nabywcy
- name: nazwa nabywcy
set_address(self, country_code: &str, street: &str, building_number: &str, flat_number: Option<&str>, city: &str, postal_code: &str) -> BuyerBuilder
- country_code: kod kraju (PL)
- street: ulica
- building_number: numer budynku
- flat_number: numer lokalu (opcjonalny)
- city: miasto
- postal_code: kod pocztowy
build(self) -> Subject2 (Obiekt reprezentujący nabywcę)
LineBuilder
new(name: &str, measure_unit: &str, quantity: Decimal, net_price: Decimal, tax_rate: &str) -> LineBuilder
- name: nazwa towaru lub usługi
- measure_unit: jednostka miary (np. "szt")
- quantity: ilość
- net_price: cena netto jednostkowa
- tax_rate: stawka VAT (np. "23", "8", "zw")
build(self) -> InvoiceLine (Obiekt reprezentujący wiersz faktury)
InvoiceBuilder
new() -> InvoiceBuilder
set_invoice_number(self, s: &str) -> InvoiceBuilder
- s: numer faktury
set_issue_date(self, date: NaiveDate) -> InvoiceBuilder
- date: data wystawienia
set_sale_date(self, date: NaiveDate) -> InvoiceBuilder
- date: data sprzedaży
set_currency(self, code: &str) -> InvoiceBuilder
- code: kod waluty (np. "PLN")
set_seller(self, seller: Subject1) -> InvoiceBuilder
- seller: obiekt sprzedawcy (z SellerBuilder)
set_buyer(self, buyer: Subject2) -> InvoiceBuilder
- buyer: obiekt nabywcy (z BuyerBuilder)
add_line(self, line: InvoiceLine) -> InvoiceBuilder
- line: wiersz faktury (z LineBuilder)
add_lines(self, lines: Vec<InvoiceLine>) -> InvoiceBuilder
- lines: wektor wierszy faktury
set_exemption(self, exempt_delivery: u8, exempt_delivery_none: Option<u8>, basis_text: Option<&str>, _legacy_basis: Option<&str>, basis_directive: Option<&str>) -> InvoiceBuilder
- exempt_delivery: znacznik zwolnienia (1 - zwolnienie, 0 - brak)
- exempt_delivery_none: opcja (zazwyczaj None jeśli jest zwolnienie)
- basis_text: podstawa prawna zwolnienia
- basis_directive: dyrektywa unijna
- _legacy_basis: parametr przestarzały (nieużywany)
set_new_transport(self, is_new_transport: u8, is_new_transport_intra_community: Option<u8>) -> InvoiceBuilder
- is_new_transport: czy jest to nowy środek transportu
- is_new_transport_intra_community: WDT nowego środka transportu
set_margin_procedures(self, tourism_services: Option<u8>, used_goods: Option<u8>, works_of_art: Option<u8>, collector_items: Option<u8>, antiques: Option<u8>) -> InvoiceBuilder
- tourism_services: procedura marży dla biur podróży
- used_goods: procedura marży - towary używane
- works_of_art: procedura marży - dzieła sztuki
- collector_items: procedura marży - przedmioty kolekcjonerskie
- antiques: procedura marży - antyki
build(self) -> Result<Invoice, String>
PEF (UBL)
use ;
let address = new
.city_name
.country
.build;
let supplier = new
.party_legal_entity
.postal_address
.party_tax_scheme
.build;
let customer = new
.party_legal_entity
.postal_address
.build;
let total = new
.line_extension_amount
.tax_exclusive_amount
.tax_inclusive_amount
.payable_amount
.build;
let tax_total = new
.tax_amount
.add_subtotal
.build;
let line = new
.invoiced_quantity
.line_extension_amount
.item
.price_amount
.tax_category
.build;
let invoice = new
.due_date
.add_tax_total
.build;
let xml = invoice.to_xml.unwrap;
println!;
InvoiceBuilder (PEF)
new(id: impl Into<String>, issue_date: impl Into<String>, accounting_supplier_party: PartyType, accounting_customer_party: PartyType, legal_monetary_total: MonetaryTotal, invoice_line: Vec<InvoiceLine>) -> InvoiceBuilder
due_date(self, date: impl Into<String>) -> InvoiceBuilder
- date: data płatności
add_tax_total(self, total: TaxTotal) -> InvoiceBuilder
- total: suma podatkowa (z TaxTotalBuilder)
build(self) -> Invoice
PartyBuilder
new() -> PartyBuilder
party_legal_entity(self, registration_name: impl Into<String>, company_id: Option<Identifier>) -> PartyBuilder
- registration_name: nazwa prawna (wymagane dla BR-06/BR-07)
party_name(self, name: impl Into<String>) -> PartyBuilder
- name: nazwa handlowa
postal_address(self, address: PostalAddress) -> PartyBuilder
- address: adres (z PostalAddressBuilder)
party_tax_scheme(self, company_id: impl Into<String>, tax_scheme_id: impl Into<String>) -> PartyBuilder
- company_id: numer podatkowy (np. NIP)
- tax_scheme_id: identyfikator schematu (np. VAT)
build(self) -> PartyType
MonetaryTotalBuilder
new() -> MonetaryTotalBuilder
line_extension_amount(self, currency: impl Into<String>, value: impl Into<String>) -> MonetaryTotalBuilder
- Suma wartości netto linii
tax_exclusive_amount(self, currency: impl Into<String>, value: impl Into<String>) -> MonetaryTotalBuilder
- Suma netto faktury
tax_inclusive_amount(self, currency: impl Into<String>, value: impl Into<String>) -> MonetaryTotalBuilder
- Suma brutto faktury
payable_amount(self, currency: impl Into<String>, value: impl Into<String>) -> MonetaryTotalBuilder
- Kwota do zapłaty
build(self) -> MonetaryTotal
InvoiceLineBuilder
new(id: impl Into<String>) -> InvoiceLineBuilder
invoiced_quantity(self, unit_code: impl Into<String>, value: impl Into<String>) -> InvoiceLineBuilder
- Ilość zafakturowana
line_extension_amount(self, currency: impl Into<String>, value: impl Into<String>) -> InvoiceLineBuilder
- Wartość netto linii
item(self, name: impl Into<String>) -> InvoiceLineBuilder
- Nazwa towaru/usługi
price_amount(self, currency: impl Into<String>, value: impl Into<String>) -> InvoiceLineBuilder
- Cena jednostkowa netto
tax_category(self, id: impl Into<String>, percent: impl Into<String>, tax_scheme_id: impl Into<String>) -> InvoiceLineBuilder
- Kategoria podatkowa (np. S, 23, VAT)
build(self) -> InvoiceLine