pub fn new(options: QRBillOptions) -> Result<Self, Error> {
        if !IBAN_ALLOWED_COUNTRIES.contains(&&options.account.country_code()) {
            return Err(Error::InvalidIban);
        }
        let iban_iid = options.account.electronic_str()[4..9]
            .parse()
            .expect("This is a bug. Please report it.");
        let _account_is_qriban = QR_IID_START <= iban_iid && iban_iid <= QR_IID_END;

        // TODO validate ESR reference number

        // TODO: validate QR IBAN / QRID matches.

        if let Some(extra_infos) = options.extra_infos.as_ref() {
            if extra_infos.len() > 120 {
                return Err(Error::ExtraInfos);
            }
        }

        if options.alternative_processes.len() > 2 {
            return Err(Error::AlternativeProcedure);
        }
        if options.alternative_processes.iter().any(|v| v.len() > 100) {
            return Err(Error::AlternativeProcedure);
        }

        Ok(Self {
            account: options.account,
            creditor: options.creditor,
            amount: options.amount,
            currency: options.currency,
            due_date: options.due_date,
            debtor: options.debtor,
            reference: options.reference,
            extra_infos: options.extra_infos,
            alternative_processes: options.alternative_processes,
            language: options.language,
            top_line: options.top_line,
            payment_line: options.payment_line,
        })
    }
/// Creates a new QR-Bill which can be rendered onto an SVG.
Creates a new QR-Bill which can be rendered onto an SVG.
Creates a new QR - Bill which can be rendered onto an SVG .
pub fn new(options: QRBillOptions) -> Result<Self, Error> {
        if !IBAN_ALLOWED_COUNTRIES.contains(&&options.account.country_code()) {
            return Err(Error::InvalidIban);
        }
        let iban_iid = options.account.electronic_str()[4..9]
            .parse()
            .expect("This is a bug. Please report it.");
        let _account_is_qriban = QR_IID_START <= iban_iid && iban_iid <= QR_IID_END;
        // TODO validate ESR reference number
        // TODO: validate QR IBAN / QRID matches.
        if let Some(extra_infos) = options.extra_infos.as_ref() {
            if extra_infos.len() > 120 {
                return Err(Error::ExtraInfos);
            }
        }
        if options.alternative_processes.len() > 2 {
            return Err(Error::AlternativeProcedure);
        }
        if options.alternative_processes.iter().any(|v| v.len() > 100) {
            return Err(Error::AlternativeProcedure);
        }
        Ok(Self {
            account: options.account,
            creditor: options.creditor,
            amount: options.amount,
            currency: options.currency,
            due_date: options.due_date,
            debtor: options.debtor,
            reference: options.reference,
            extra_infos: options.extra_infos,
            alternative_processes: options.alternative_processes,
            language: options.language,
            top_line: options.top_line,
            payment_line: options.payment_line,
        })
    }
pub fn new ( options : QRBillOptions ) -> Result < Self , Error > { if ! IBAN_ALLOWED_COUNTRIES . contains ( & & options . account . country_code ( ) ) { return Err ( Error :: InvalidIban ) ; } let iban_iid = options . account . electronic_str ( ) [ 4 .. 9 ] . parse ( ) . expect ( " " ) ; let _account_is_qriban = QR_IID_START <= iban_iid && iban_iid <= QR_IID_END ; // TODO validate ESR reference number // TODO: validate QR IBAN / QRID matches. if let Some ( extra_infos ) = options . extra_infos . as_ref ( ) { if extra_infos . len ( ) > 120 { return Err ( Error :: ExtraInfos ) ; } } if options . alternative_processes . len ( ) > 2 { return Err ( Error :: AlternativeProcedure ) ; } if options . alternative_processes . iter ( ) . any ( | v | v . len ( ) > 100 ) { return Err ( Error :: AlternativeProcedure ) ; } Ok ( Self { account : options . account , creditor : options . creditor , amount : options . amount , currency : options . currency , due_date : options . due_date , debtor : options . debtor , reference : options . reference , extra_infos : options . extra_infos , alternative_processes : options . alternative_processes , language : options . language , top_line : options . top_line , payment_line : options . payment_line , } ) }
Creates a new QR-Bill which can be rendered onto an SVG.
Creates a new QR - Bill which can be rendered onto an SVG .
options
QRBillOptions
options
QRBillOptions