示例#1
0
        /// <summary>
        /// Scenario description:
        /// 1. Create Invoice
        /// 2. Correct invoice with Credit Note
        /// 3. Create new Invoice
        /// </summary>
        private static void CreateSimpleInvoice_Scenario_01(Magni.APIClient.V2.Invoicing api)
        {
            var client = new APIClient.V2.Models.Client()
            {
                Address     = "Av. Sidónio Pais",
                City        = "Lisboa",
                CountryCode = "PT",
                Name        = "Consumidor Final",
                NIF         = "999999990",
                PhoneNumber = "111111112",
                PostCode    = "1500-244"
            };

            var invoice = new APIClient.V2.Models.SimplifiedInvoice()
            {
                Currency               = "EUR",
                Date                   = DateTime.Now,
                Description            = "API Client Test",
                DueDate                = DateTime.Now.AddDays(30),
                EuroRate               = 0,
                ExternalId             = null,
                Id                     = 0,
                Retention              = 0,
                Series                 = null,
                TaxExemptionReasonCode = null
            };

            invoice.Lines.Add(new APIClient.V2.Models.APIInvoicingProduct()
            {
                Code            = "999",
                CostCenter      = null,
                Description     = "General Expense",
                ProductDiscount = 0,
                Quantity        = 1,
                TaxValue        = 23,
                Type            = APIClient.V2.Models.ProductType.S,
                Unit            = "API Activation",
                UnitPrice       = 10
            });

            var response = api.InvoiceSimplifiedCreate(client, invoice, isToClose: false, sentTo: sentToEmail);


            if (response.Type == APIClient.V2.Models.ResponseType.Success)
            {
                var creditNote = new APIClient.V2.Models.CreditNote()
                {
                    Currency               = "EUR",
                    Date                   = DateTime.Now,
                    Description            = "API Client Test",
                    DueDate                = DateTime.Now.AddDays(30),
                    EuroRate               = 0,
                    ExternalId             = null,
                    Id                     = response.Document.DocumentId,
                    Retention              = 0,
                    Series                 = null,
                    TaxExemptionReasonCode = null
                };

                creditNote.Lines.Add(invoice.Lines.First());

                var creditNoteResponse = api.CreditNoteCreate(client, creditNote, isToClose: false, sentTo: sentToEmail);

                if (creditNoteResponse.Type == APIClient.V2.Models.ResponseType.Success)
                {
                    invoice.Lines.First().UnitPrice = 8;
                    response = api.InvoiceSimplifiedCreate(client, invoice, isToClose: false, sentTo: sentToEmail);

                    if (response.Type == APIClient.V2.Models.ResponseType.Success)
                    {
                        var documentFile = api.DocumentGet(response.Document.DocumentId);
                    }
                }
            }
        }
示例#2
0
 private static void GetDocument(Magni.APIClient.V2.Invoicing api)
 {
     var response = api.DocumentGet(1);
 }