fakturownia-sdk v0.3.2
fakturowniaAPI4NodeJS
Nieoficjalna Bibliteka umożliwiająca korzystanie z systemu Fakturownia www.fakturownia.pl.
Instalacja
npm install fakturownia_sdk
Przykłady użycia
import { fakturownia} from 'fakturownia-sdk';
const api = fakturownia("http://nazwaTwojejfirmy.fakturownia.pl", "TwojKluczAPI", {verbose: true})
const invoiceId = 12345
const invoice = api.invoiceGet(invoiceId)
const invoices1 = api.invoiceList().forThisMonth()
const invoices2 = api.invoiceList().forPeriod(new Date(), new Date())
Wspierane funkcje
Invoice
invoiceIncomeList
List all income invoices.
const incomeInvoices = api.invoiceIncomeList().forThisMonth();
invoiceCostList
List all cost invoices with an optional filter parameter currency="PLN".
const costInvoices = api.invoiceCostList("currency='PLN'").forThisMonth();
invoiceGet
Get a specific invoice by its ID.
const invoiceId = 12345;
const invoice = api.invoiceGet(invoiceId);
invoiceAddFile
Add a file to a specific invoice.
import { readFileSync } from 'fs';
import path from 'path';
const invoiceId = 12345;
const filePath = 'C:\\Users\\xxxx\\tmp\\20241024_124112.jpg';
const fileContent = readFileSync(filePath);
const fileName = path.basename(filePath);
const updatedInvoice = api.invoiceAddFile(invoiceId, fileContent, filename);
invoiceGetByNumber
Get a specific invoice by its number.
const invoiceNumber = "INV-2023-001";
const invoice = api.invoiceGetByNumber(invoiceNumber, true);
invoiceCreate
Create a new invoice.
import { Invoice } from 'fakturownia-sdk'
const newInvoice = {
// invoice details
} as Invoice;
const createdInvoice = api.invoiceCreate(newInvoice);
invoiceUpdate
Update an existing invoice.
//first get the invoice using the API
const invoice = api.invoiceGet(invoiceId);
invoice.sell_date = new Date()
invoice.number = "new number"
const fieldsToUpdate = ["sell_date", "number"];
const updatedInvoice = api.invoiceUpdate(invoiceToUpdate, fieldsToUpdate);
Payment
paymentList
List all payments with an optional filter parameter.
const payments = api.paymentList("status='paid'").forPeriod();
paymentIncomeList
List all income payments with a required filter parameter.
const incomePayments = api.paymentIncomeList("currency='PLN'").forThisMonth();
paymentExpenseList
List all expense payments with an optional filter parameter.
const expensePayments = api.paymentExpenseList("category='office'").forThisMonth();
paymentGet
Get a specific payment by its ID.
const paymentId = 67890;
const payment = api.paymentGet(paymentId);
paymentDelete
Delete a specific payment by its ID.
const paymentId = 67890;
await api.paymentDelete(paymentId);
paymentCreate
Create a new payment.
import { Payment } from 'fakturownia-sdk'
const newPayment = {
// payment details
} as Payment;
const createdPayment = await api.paymentCreate(newPayment);
paymentUpdate
Update an existing payment.
const payment = await api.paymentGet(paymentId);
payment.amount = 1500;
const fieldsToUpdate = ["amount"];
const updatedPayment = await api.paymentUpdate(payment, fieldsToUpdate);
paymentAssignToInvoices
Assign a payment to multiple invoices.
const payment = await api.paymentGet(paymentId);
const invoiceIds = [12345, 67890];
const updatedPayment = await api.paymentAssignToInvoices(payment, invoiceIds);
paymentAssignToPayment
Assign a payment to another payment.
const payment = await api.paymentGet(paymentId);
const targetPaymentId = 67891;
const updatedPayment = await api.paymentAssignToPayment(payment, targetPaymentId);
paymentListNotAttached
List all payments that are not attached to any invoice with an optional filter parameter.
const unattachedPayments = api.paymentListNotAttached("status='unpaid'").forThisMonth();
Category
categoryList
List all categories with an optional filter parameter.
const categories = api.categoryList("type='expense'").forThisMonth();
categoryDelete
Delete a specific category by its ID.
const categoryId = 123;
await api.categoryDelete(categoryId);
categoryCreate
Create a new category.
const categoryName = "New Category";
const categoryDescription = "Description of the new category";
const createdCategory = await api.categoryCreate(categoryName, categoryDescription);
Department
List all departments.
const departments = await api.departmentList().getAll()
Uwagi
Jeśli potrzebujesz rozwiązań integracyjnych dla platfromy Fakturownia zapraszam do kontaktu. Posiadam gotowe skanery AI do faktur oraz wysokiej jakości rozwiazania do zbiorczego wczytywania przelewów. Zapraszam!