Ejemplo n.º 1
0
        public async Task CreateInvoice_NewInvoice_Success()
        {
            var uniqueId = Guid.NewGuid().ToString().Substring(0, 4);
            var now      = DateTime.UtcNow;
            var invoice  = new Invoice
            {
                SupplierNumber      = "2005363",
                SupplierSiteNumber  = "001",
                InvoiceNumber       = $"era_unittest_{uniqueId}",
                InvoiceBatchName    = "era_unittest",
                PayGroup            = "EMB INC",
                DateInvoiceReceived = now,
                InvoiceDate         = now,
                GlDate             = now,
                InvoiceAmount      = 100m,
                InvoiceLineDetails = new[]
                {
                    new InvoiceLineDetail
                    {
                        DefaultDistributionAccount = "105.15006.10120.5185.1500000.000000.0000",
                        InvoiceLineAmount          = 100m,
                        InvoiceLineNumber          = 1
                    }
                },
                InteracEmail             = $"{uniqueId}[email protected]",
                InteracMobileCountryCode = "1",
                InteracMobileNumber      = "6040000000",
                RemittanceMessage1       = "security question",
                RemittanceMessage2       = "answer"
            };
            var response = await client.CreateInvoiceAsync(invoice, CancellationToken.None);

            response.ShouldNotBeNull().IsSuccess().ShouldBeTrue();
            response.InvoiceNumber.ShouldNotBeNull().ShouldBe(invoice.InvoiceNumber);
        }
Ejemplo n.º 2
0
        public async Task <string> CreateInvoice(string batchName, era_etransfertransaction payment, CancellationToken ct)
        {
            var config = await casSystemConfigurationProvider.Get(ct);

            var invoice = new Invoice
            {
                PayGroup                 = config.PayGroup,
                CurrencyCode             = config.CurrencyCode,
                Terms                    = config.InvoiceTerms,
                InvoiceType              = config.InvoiceType,
                RemittanceCode           = config.InvoiceRemittanceCode,
                SpecialHandling          = config.InvoiceSpecialHandling,
                InvoiceBatchName         = batchName,
                SupplierNumber           = payment.era_suppliernumber,
                SupplierSiteNumber       = payment.era_sitesuppliernumber,
                InvoiceNumber            = payment.era_name,
                DateInvoiceReceived      = payment.era_dateinvoicereceived.Value.UtcDateTime,
                GlDate                   = payment.era_gldate.Value.UtcDateTime,
                InvoiceDate              = payment.era_invoicedate.Value.UtcDateTime,
                InvoiceAmount            = payment.era_totalamount.Value,
                InteracEmail             = payment.era_emailaddress,
                InteracMobileCountryCode = payment.era_phonenumber == null ? null : "1",
                InteracMobileNumber      = payment.era_phonenumber?.ToCasTelephoneNumber(),
                RemittanceMessage1       = payment.era_securityquestion?.TrimTo(40),
                RemittanceMessage2       = payment.era_securityanswer?.TrimTo(64),
                InvoiceLineDetails       = new[]
                {
                    new InvoiceLineDetail
                    {
                        InvoiceLineNumber          = 1,
                        DefaultDistributionAccount = config.DefaultDistributionAccount,
                        InvoiceLineAmount          = payment.era_totalamount.Value,
                        LineCode        = config.InvoiceLineCode,
                        InvoiceLineType = config.InvoiceLineType
                    }
                }
            };

            var response = await casWebProxy.CreateInvoiceAsync(invoice, ct);

            if (!response.IsSuccess())
            {
                throw new CasException($"{response.CASReturnedMessages}");
            }

            return(response.InvoiceNumber);
        }