private async Task <EFCommandResponse> SendReceipt(EFIReceipt receipt, bool showRequest) { EFCommandResponse result = null; EnableControls(false); if (showRequest) { DisplayRequest(receipt); } try { //var model = receipt.ToXMLModel(); //var json=model.ToJson(); result = await _fiscalApiService.CreateReceipt(receipt); SaveRequestAndResponseIfRequired(@"Logs\Receipts\", receipt.ToXMLModel(), result, chkSaveToXml.Checked); result.Url.UrlContent = result.Url.ToModel(); DisplayResponse(result); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } EnableControls(true); return(result); }
public static EFIReceipt AddSaleItem(this EFIReceipt receipt, EFISaleItem saleItem) { if (receipt.Sales == null) { receipt.Sales = new List <EFISaleItem>(); } receipt.Sales.Add(saleItem); return(receipt); }
public static EFIReceipt SetUser(this EFIReceipt receipt, string userName, string userCode) { receipt.User = new EFIUser { UserName = userName, UserCode = userCode }; return(receipt); }
public static EFIReceipt SetTotalDiscount(this EFIReceipt receipt, decimal discountPercentage) { if (receipt.Sales == null) { receipt.Sales = new List <EFISaleItem>(); } receipt.Sales.Select(item => item.DiscountPercentage = discountPercentage); return(receipt); }
public static EFIReceipt CalculateTotalAmount(this EFIReceipt receipt, EFIPaymentTypeEnum paymentType) { receipt.Payments = new List <EFIPaymentItem>(); receipt.Payments.Add(new EFIPaymentItem { PaymentType = paymentType.ToDecriptionString(), Amount = receipt.Sales.Sum(item => item.Price * item.Quantity * (1 - item.DiscountPercentage / 100)) }); return(receipt); }
public static EFIReceipt SetSeller(this EFIReceipt receipt, string name, string VATNumber, string address) { receipt.Seller = new EFIClient { Name = name, VATNumber = VATNumber, Address = address }; return(receipt); }
public static EFIReceipt AddIKOFReference(this EFIReceipt receipt, string IKOFReference, DateTime issuedAt) { if (receipt.ConnectedDocuments == null) { receipt.ConnectedDocuments = new List <EFIConnectedDocument>(); } receipt.ConnectedDocuments.Add(new EFIConnectedDocument() { IKOF = IKOFReference, IssuedAt = issuedAt }); return(receipt); }
private async void btnSendReceiptFromRequestField_Click(object sender, EventArgs e) { try { EFIReceipt receipt = JsonConvert.DeserializeObject <EFIReceipt>(txtRequest.Text); await SendReceipt(receipt, false); } catch (Exception ex) { txtResponse.Text = ""; MessageBox.Show(ex.Message, "Error"); } }
public static EFIReceipt AddPayment(this EFIReceipt receipt, EFIPaymentTypeEnum paymentType, decimal amount) { if (receipt.Payments == null) { receipt.Payments = new List <EFIPaymentItem>(); } receipt.Payments.Add(new EFIPaymentItem { PaymentType = paymentType.ToDecriptionString(), Amount = amount, }); return(receipt); }
public static EFIReceipt AddSaleItem(this EFIReceipt receipt, string itemCode, string itemName, decimal quantity, decimal price, decimal taxRate, decimal discountPercentage) { if (receipt.Sales == null) { receipt.Sales = new List <EFISaleItem>(); } receipt.Sales.Add( new EFISaleItem { ItemCode = itemCode, ItemName = itemName, Quantity = quantity, Price = price, TaxRate = taxRate, DiscountPercentage = discountPercentage }); return(receipt); }
public static EFIReceipt SetDates(this EFIReceipt receipt, DateTime receiptTime, DateTime?dueDate) { receipt.ReceiptTime = receiptTime; receipt.DueDate = dueDate; return(receipt); }
public static EFIReceipt SetSummaryInvoice(this EFIReceipt receipt) { receipt.ReceiptType = "" + EFIReceiptTypeEnum.SUMMARY_INVOICE; return(receipt); }
public static EFIReceipt SetCorrectiveInvoice(this EFIReceipt receipt) { receipt.ReceiptType = "" + EFIReceiptTypeEnum.CORRECTIVE_INVOICE; return(receipt); }
public static EFIReceipt SetIsCash(this EFIReceipt receipt, bool isCashReceipt) { receipt.IsCashReceipt = isCashReceipt; return(receipt); }
public static EFIReceipt SetTCRCode(this EFIReceipt receipt, string TCRCode) { receipt.TCRCode = TCRCode; return(receipt); }
public static EFiscalReceiptCommand ToXMLModel(this EFIReceipt receipt) { //set user Func <EFIUser, EFUser> SetUser = user => new EFUser() { UserName = user.UserName, UserCode = user.UserCode }; //set seller, buyer Func <EFIClient, EFClient> SetClient = client => { if (client != null) { return(new EFClient() { Name = client.Name, IDType = "TIN",//SellerIDType.TIN IDValue = client.VATNumber, Address = client.Address }); } return(null); }; //set sales Func <IEnumerable <EFISaleItem>, EFSales> SetSales = sales => { EFSales salesGroup = null; if (sales != null) { salesGroup = new EFSales() { ItemSaleRow = sales.Select(item => new EFItemSaleRow() { ItemCode = item.ItemCode, ItemName = item.ItemName, Price = item.Price, DiscountPercentage = item.DiscountPercentage, Quantity = item.Quantity, TaxRate = item.TaxRate } ).ToList() }; } return(salesGroup); }; //set payments Func <IEnumerable <EFIPaymentItem>, EFPayments> SetPayments = payments => new EFPayments() { PaymentRow = payments.Select(item => new EFPaymentRow() { PaymentType = item.PaymentType, PaymentAmount = item.Amount } ).ToList() }; Func <IEnumerable <EFIConnectedDocument>, EFConnectedDocuments> SetConnectedDocuments = connectedDocs => { if (connectedDocs != null) { var list = new List <EFDocumentRow>(); foreach (var item in connectedDocs) { list.Add(new EFDocumentRow() { Uid = item.IKOF, Type = "CORRECTIVE", IssueDate = item.IssuedAt }); } return(new EFConnectedDocuments() { DocumentRow = list }); } return(null); }; var command = new EFiscalReceiptCommand() { Uid = receipt.ReceiptUniqueIdentifier.ToString(), ENUIdentifier = receipt.TCRCode, Type = "JSON", //EFiscalReceiptCommandType DocumentType = receipt.ReceiptType, //"INVOICE",//EFiscalReceiptCommandDocumentType DocumentNumber = receipt.ReceiptNumber, IsNoCashReceipt = !receipt.IsCashReceipt, DateSend = receipt.ReceiptTime, User = SetUser(receipt.User), ConnectedDocuments = SetConnectedDocuments(receipt.ConnectedDocuments), Seller = SetClient(receipt.Seller), Buyer = SetClient(receipt.Buyer), Sales = SetSales(receipt.Sales), Payments = SetPayments(receipt.Payments) }; return(command); }
public static EFIReceipt AddSaleItem(this EFIReceipt receipt, string itemCode, string itemName, decimal quantity, decimal price, decimal taxRate) { return(AddSaleItem(receipt, itemCode, itemName, quantity, price, taxRate, 0)); }
public static EFIReceipt SetJsonResponse(this EFIReceipt receipt) { receipt.ResponseType = "" + EFIFormatTypeEnum.JSON; return(receipt); }
public static EFIReceipt SetXMLResponse(this EFIReceipt receipt) { receipt.ResponseType = "" + EFIFormatTypeEnum.XML; return(receipt); }
public async Task <EFCommandResponse> CreateReceipt(EFIReceipt command) { return(await CreateReceipt(command.ToXMLModel())); }
private async Task <EFCommandResponse> SendReceipt(EFIReceipt receipt) { return(await SendReceipt(receipt, true)); }