Example #1
0
        public IActionResult Check([FromRoute] string code, [FromRoute] string total)
        {
            Voucher voucher = _context.Vouchers.Where(p => p.code == code && p.count > 0 && p.date_end > DateTime.Now).FirstOrDefault();

            if (voucher == null)
            {
                return(NotFound());
            }
            if (voucher.kind == 1)
            {
                VoucherProcess vc = new VoucherProcess
                {
                    id_voucher = voucher.id,
                    discount   = Convert.ToDouble(total) * voucher.value,
                };
                return(Ok(vc));
            }
            else
            {
                VoucherProcess vc = new VoucherProcess
                {
                    id_voucher = voucher.id,
                    discount   = voucher.value,
                };
                return(Ok(vc));
            }
        }
Example #2
0
        private VoucherInformation GetTestData_VoucherInfo()
        {
            var voucher = new Voucher
            {
                documentReferenceNumber = "04114",
                bsbNumber       = "082401",
                auxDom          = string.Empty,
                accountNumber   = "813208132",
                amount          = "419.38",
                documentType    = DocumentTypeEnum.Dr,
                transactionCode = "01",
                processingDate  = new DateTime(2015, 01, 01)
            };

            var voucherProcess = new VoucherProcess
            {
                adjustedFlag          = true,
                adjustmentDescription = "test description",
                adjustmentReasonCode  = 00,
                transactionLinkNumber = "9000001"
            };

            var voucherBatch = new VoucherBatch
            {
                scannedBatchNumber = "67500125",
                collectingBank     = "082401"
            };

            var voucherInfo = new VoucherInformation
            {
                voucher        = voucher,
                voucherProcess = voucherProcess,
                voucherBatch   = voucherBatch
            };

            return(voucherInfo);
        }