/// <summary> /// Điều chỉnh tăng hoặc giảm cho hóa đơn /// </summary> /// <param name="authentication"></param> /// <param name="model"></param> /// <returns></returns> public MessageResult Adjustment(Authentication authentication, InvoiceAdjustmentModel model) { MessageResult result = new MessageResult(); try { var token = GetToken(authentication); if (!string.IsNullOrEmpty(token)) { string apiLink = $"{authentication.DomainName}/api/invoices/adjustment-detail/{model.Id}"; InvoiceAdjustmentRequest request = new InvoiceAdjustmentRequest(model); List <InvoiceAdjustmentDetail> invoiceDetails = new List <InvoiceAdjustmentDetail>(); if (model.Details != null) { invoiceDetails.AddRange(model.Details.Select(c => new InvoiceAdjustmentDetail(c))); } request.Details = invoiceDetails; List <InvoiceAdjustmentTaxBreakdown> taxBreakdowns = new List <InvoiceAdjustmentTaxBreakdown>(); if (model.TaxBreakdowns != null) { taxBreakdowns.AddRange(model.TaxBreakdowns.Select(c => new InvoiceAdjustmentTaxBreakdown(c))); } request.TaxBreakdowns = taxBreakdowns; var rawResponse = AppUtil.CreateRequest(apiLink, request.ToJson(), token); var response = rawResponse.ToObject <BaseResponse <InvoiceAdjustmentResponse> >(); if (response != null) { result.Code = response.Code; result.Succeeded = response.Succeeded; result.Data = response.Data; } } else { result.CannotLogin(); } } catch (Exception) { result.ErrorApi(); } return(result); }
public InvoiceAdjustmentRequest(InvoiceAdjustmentModel model) : this() { if (!string.IsNullOrEmpty(model.Id)) { Id = model.Id; } Username = model.Username; BuyerId = model.BuyerId; BuyerGroupCode = model.BuyerGroupCode; BuyerGroupName = model.BuyerGroupName; RecordNo = model.RecordNo; RecordDate = model.RecordDate.ConvertToString(); Reason = model.Reason; FileNameOfRecord = model.FileNameOfRecord; FileOfRecord = model.FileOfRecord; TotalAmount = model.TotalAmount; TotalVatAmount = model.TotalVatAmount; TotalDiscountAmountBeforeTax = model.TotalDiscountAmountBeforeTax; TotalDiscountPercentAfterTax = model.TotalDiscountPercentAfterTax; TotalDiscountAmountAfterTax = model.TotalDiscountAmountAfterTax; TotalPaymentAmount = model.TotalPaymentAmount; OriginTotalAmount = model.OriginTotalAmount; TotalAmountAfterAdjustment = model.TotalAmountAfterAdjustment; OriginTotalVatAmount = model.OriginTotalVatAmount; TotalVatAmountAfterAdjustment = model.TotalVatAmountAfterAdjustment; OriginTotalDiscountAmountBeforeTax = model.OriginTotalDiscountAmountBeforeTax; OriginTotalDiscountPercentAfterTax = model.OriginTotalDiscountPercentAfterTax; OriginTotalDiscountAmountAfterTax = model.OriginTotalDiscountAmountAfterTax; TotalDiscountAmountBeforeTaxAfterAdj = model.TotalDiscountAmountBeforeTaxAfterAdj; TotalDiscountPercentAfterTaxAfterAdj = model.TotalDiscountPercentAfterTaxAfterAdj; TotalDiscountAmountAfterTaxAfterAdj = model.TotalDiscountAmountAfterTaxAfterAdj; OriginTotalPaymentAmount = model.OriginTotalPaymentAmount; TotalPaymentAmountAfterAdjustment = model.TotalPaymentAmountAfterAdjustment; Details = new List <InvoiceAdjustmentDetail>(); TaxBreakdowns = new List <InvoiceAdjustmentTaxBreakdown>(); }