예제 #1
0
        private static Receipt ParseReceipt(string value, byte[] key, CultureInfo culture, TimeZoneInfo timeZone)
        {
            const int expectedValueCount = 12;
            var       values             = value.Trim('_').Split('_');

            if (values.Length < expectedValueCount)
            {
                throw new ArgumentException("Value does not contain valid QR data.");
            }

            return(new Receipt(
                       registerIdentifier: new RegisterIdentifier(values[1]),
                       number: new ReceiptNumber(values[2]),
                       created: LocalDateTime.Parse(values[3], timeZone),
                       taxData: new TaxData(
                           CurrencyValue.Parse(values[4], culture),
                           CurrencyValue.Parse(values[5], culture),
                           CurrencyValue.Parse(values[6], culture),
                           CurrencyValue.Parse(values[7], culture),
                           CurrencyValue.Parse(values[8], culture)
                           ),
                       encryptedTurnover: new EncryptedTurnover(values[9]),
                       certificateSerialNumber: new CertificateSerialNumber(values[10]),
                       chainValue: new ChainValue(values[11]),
                       key: key
                       ));
        }
예제 #2
0
 public Receipt(
     ReceiptNumber number,
     RegisterIdentifier registerIdentifier,
     TaxData taxData,
     CurrencyValue turnover,
     CertificateSerialNumber certificateSerialNumber,
     JwsRepresentation previousJwsRepresentation,
     byte[] key,
     LocalDateTime created = null)
     : this(number, registerIdentifier, taxData, certificateSerialNumber, key, created)
 {
     PreviousJwsRepresentation = previousJwsRepresentation;
     ChainValue        = ComputeChainValue();
     Turnover          = turnover ?? throw new ArgumentException("The turnover has to be specified.");
     EncryptedTurnover = EncryptTurnover();
 }