paymentlib/nswcpp/jsonb/
payment_components.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use chrono::NaiveDateTime;

use serde::{Deserialize, Serialize};

use crate::nswcpp::enums::card_type::CardType;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct PaymentComponents {
    pub card_type: Vec<CardType>,
    pub expiry_date: Option<String>,
    pub start_digits: Option<String>,
    pub end_digits: Option<String>,
    pub receipt_text: Option<String>,
    pub amount: f64,
    pub total_surcharge: f64,
    pub component_type: Option<String>,
    pub settlement_date: NaiveDateTime,
    pub amount_tendered: Option<i32>,
    pub change_returned: Option<i32>,
    pub bsb: Option<String>,
    pub account: Option<String>,
    pub cheque_number: Option<String>,
    pub cheque_type: Option<String>,
    pub order_number: Option<String>,
    pub institution: Option<String>,
    pub issue_date: Option<NaiveDateTime>,
    pub supervisor_csr_id: Option<String>,
    pub card_number: Option<String>,
    pub expiry_date_month: Option<String>,
    pub expiry_date_year: Option<String>,
    pub cardholder_name: Option<String>,
    pub bank_reference: Option<String>,
}

impl PaymentComponents {
    pub fn normalize(&self) -> PaymentComponents {
        PaymentComponents {
            settlement_date: self.settlement_date,
            card_type: self.card_type.clone(),
            expiry_date: self.expiry_date.clone(),
            start_digits: self.start_digits.clone(),
            end_digits: self.end_digits.clone(),
            receipt_text: self.receipt_text.clone(),
            component_type: self.component_type.clone(),
            amount: self.amount,
            total_surcharge: self.total_surcharge,
            amount_tendered: self.amount_tendered,
            change_returned: self.change_returned,
            bsb: self.bsb.clone(),
            account: self.account.clone(),
            cheque_number: self.cheque_number.clone(),
            cheque_type: self.cheque_type.clone(),
            order_number: self.order_number.clone(),
            institution: self.institution.clone(),
            issue_date: self.issue_date,
            supervisor_csr_id: self.supervisor_csr_id.clone(),
            card_number: self.card_number.clone(),
            expiry_date_month: self.expiry_date_month.clone(),
            expiry_date_year: self.expiry_date_year.clone(),
            cardholder_name: self.cardholder_name.clone(),
            bank_reference: self.bank_reference.clone(),
        }
    }
}