baselinker/requests/orders/
get_receipt.rs

1use crate::common::RequestTrait;
2use chrono::serde::ts_seconds;
3use chrono::{DateTime, Utc};
4use rust_decimal::Decimal;
5use serde::{Deserialize, Serialize};
6
7#[derive(Serialize, Deserialize, Debug)]
8pub struct ReceiptItem {
9    pub name: String,
10    pub price_brutto: Decimal,
11    pub tax_rate: Decimal,
12    pub quantity: i64,
13    pub sku: String,
14    pub ean: String,
15}
16
17#[derive(Serialize, Deserialize, Debug)]
18pub struct GetReceiptResponse {
19    pub receipt_id: i64,
20    pub series_id: i64,
21    pub receipt_full_nr: String,
22    pub year: i64,
23    pub month: i64,
24    pub sub_id: i64,
25    pub order_id: i64,
26    #[serde(with = "ts_seconds")]
27    pub date_add: DateTime<Utc>,
28    pub payment_method: String,
29    pub nip: String,
30    pub currency: String,
31    pub total_price_brutto: Decimal,
32    pub external_receipt_number: String,
33    pub exchange_currency: String,
34    pub exchange_rate: Decimal,
35    pub exchange_date: String,
36    pub exchange_info: String,
37    pub items: Vec<ReceiptItem>,
38}
39
40/// The method allows you to retrieve a single receipt from the BaseLinker order manager.
41///
42/// To retrieve a list of new receipts (when integrating a fiscal printer), use the getNewReceipts method.
43#[derive(Serialize, Deserialize, Debug)]
44pub struct GetReceipt {
45    // TODO: union/enum?
46    /// Receipt ID. Not required if order_id is provided.
47    pub receipt_id: Option<i64>,
48    /// Order ID. Not required if receipt_id is provided.
49    pub order_id: Option<i64>,
50}
51
52impl RequestTrait<GetReceiptResponse> for GetReceipt {
53    const METHOD: &'static str = "getReceipt";
54}