public int InsertSalesInvoiceItem(SalesInvoiceItem objSalesInvoiceItem, IDbConnection connection, IDbTransaction trn) { try { string sql; if (!objSalesInvoiceItem.isAccessory) { sql = @"INSERT INTO SalesInvoiceItem(SalesInvoiceId,SaleOrderItemId,JobCardId,Quantity,Rate,Discount,Amount) VALUES (@SalesInvoiceId,@SaleOrderItemId,@JobCardId,@QuantityTxt,@Rate,@Discount,@Amount); SELECT CAST(SCOPE_IDENTITY() as int) "; } else { sql = @"INSERT INTO SalesInvoiceAccessory (SalesInvoiceId, ItemId, Quantity, Rate, Discount, Amount) VALUES (@SalesInvoiceId, @ItemId, @QuantityTxt, @Rate, @Discount, @Amount); SELECT CAST(SCOPE_IDENTITY() AS INT)"; } var id = connection.Query <int>(sql, objSalesInvoiceItem, trn).Single(); return(id); } catch (Exception) { throw; } }
protected string GetLineDescription(SalesInvoiceItem line) { var text = line.PartNumber; text += String.IsNullOrEmpty(line.PartNumber2) ? "" : $", RPN:{line.PartNumber2}"; text += String.IsNullOrEmpty(line.Manufacturer) ? "" : $", MFR:{line.Manufacturer}"; text += String.IsNullOrEmpty(line.DateCode) ? "" : $", D/C:{line.DateCode}"; text += String.IsNullOrEmpty(line.Msl) ? "" : $", MSL:{line.Msl}"; return(text); }
public int UpdateSalesInvoiceItem(SalesInvoiceItem objSalesInvoiceItem) { using (IDbConnection connection = OpenConnection(dataConnection)) { string sql = @"UPDATE SalesInvoiceItem SET SalesInvoiceId = @SalesInvoiceId ,WorkDescription = @WorkDescription ,SlNo = @SlNo ,ItemId = @ItemId,ItemDescription = @ItemDescription,PartNo = @PartNo,Quantity = @Quantity,Unit = @Unit,Rate = @Rate OUTPUT INSERTED.SalesInvoiceItemId WHERE SalesInvoiceItemId = @SalesInvoiceItemId"; var id = connection.Execute(sql, objSalesInvoiceItem); return(id); } }
public int InsertSalesInvoiceItem(SalesInvoiceItem objSalesInvoiceItem) { using (IDbConnection connection = OpenConnection(dataConnection)) { string sql = @"insert into SalesInvoiceItem(SalesInvoiceId,WorkDescription,SlNo,ItemId,ItemDescription,PartNo,Quantity,Unit,Rate,Discount,Amount,CreatedBy,CreatedDate,OrganizationId) Values (@SalesInvoiceId,@WorkDescription,@SlNo,@ItemId,@ItemDescription,@PartNo,@Quantity,@Unit,@Rate,@Discount,@Amount,@CreatedBy,@CreatedDate,@OrganizationId); SELECT CAST(SCOPE_IDENTITY() as int)"; var id = connection.Query <int>(sql, objSalesInvoiceItem).Single(); return(id); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.RequestType == "POST") { SalesInvoice oSalesInvoice = new SalesInvoice(); if (Request.Form["SalesInvoice[id_customer]"] == "") { Response.Redirect("FaturaListe.aspx"); } oSalesInvoice.Id_Customer = Convert.ToInt32(Request.Form["SalesInvoice[id_customer]"]); oSalesInvoice.Id_User_Create = Convert.ToInt32(Session["Id"]); oSalesInvoice.Tax_Number = Convert.ToInt32(Request.Form["SalesInvoice[tax_number]"].ToString()); oSalesInvoice.Tax_Office = Request.Form["SalesInvoice[tax_office]"].ToString(); oSalesInvoice.Grand_Total = Convert.ToDecimal(Request.Form["SalesInvoice[grandtotal]"].Replace(".", ",")); oSalesInvoice.Tax_Total = Convert.ToDecimal(Request.Form["SalesInvoice[taxtotal]"].Replace(".", ",")); oSalesInvoice.Total = Convert.ToDecimal(Request.Form["SalesInvoice[total]"].Replace(".", ",")); oSalesInvoice.Description = Request.Form["SalesInvoice[description]"].ToString(); oSalesInvoice.Create_At = DateTime.Now; int id = Convert.ToInt32(oSalesInvoice.Insert(true));// fatura kayıt edildi string[] items = Request.Form["sales_invoice_item_list_form_input"].Split('/'); for (int i = 0; i < items.Length; i++) { string[] item = items[i].Split('-'); //// item[]/ item[] --->itemformat id-name-quantity-price //-taxrate-total-taxtotal-grandtotal/ id-name-quantity-price-taxrate-total-taxtotal-grandtotal SalesInvoiceItem oSalesInvoiceItem = new SalesInvoiceItem(); oSalesInvoiceItem.Id_Sales_Invoice = id;// fatura id oSalesInvoiceItem.Id_Product = Convert.ToInt32(item[0]); oSalesInvoiceItem.Quantity = Convert.ToInt32(item[2]); oSalesInvoiceItem.Price = Convert.ToDecimal(item[3].Replace(".", ",")); oSalesInvoiceItem.Tax_Rate = Convert.ToDecimal(item[4].Replace(".", ",")); oSalesInvoiceItem.Insert(); } PaymentTransaction oPaymentTransaction = new PaymentTransaction(); oPaymentTransaction.Id_User_Create = Convert.ToInt32(Session["Id"]); oPaymentTransaction.Id_Customer = Convert.ToInt32(Request.Form["SalesInvoice[id_customer]"]); oPaymentTransaction.Payment_Type = 0; // borçlu oldu oPaymentTransaction.Amount = Convert.ToDecimal(Request.Form["SalesInvoice[grandtotal]"].Replace(".", ",")); oPaymentTransaction.Description = "Fatura Kesim"; oPaymentTransaction.Create_At = DateTime.Now; oPaymentTransaction.Insert(); Response.Redirect("FaturaDetay.aspx?Id=" + id); } }
private SalesInvoice toRecord(dynamic record) { SalesInvoice entity = new SalesInvoice(); entity.CodigoCliente = record.CardCode; entity.CodigoEmpresa = record.BPLid; entity.DataLancamento = Convert.ToDateTime((string)record.DocDate).ToString("yyyy-MM-dd"); entity.DataLiberacao = Convert.ToDateTime((string)record.U_SKILL_DTPRE).ToString("yyyy-MM-dd"); entity.NumeroRP = record.U_VS_RP; entity.NumeroNegociacao = record.U_VS_NEG; entity.CodigoCondicaoPagto = record.GroupNum; if (record.DocumentLines != null) { entity.Itens = new List <SalesInvoiceItem>(); foreach (var line in record.DocumentoLines) { SalesInvoiceItem item = new SalesInvoiceItem(); item.CodigoProduto = line.ItemCode; item.Quantidade = Convert.ToDouble(line.Quantity); item.ValorLiquido = Convert.ToDouble(line.Price); item.VerticalNegocio = line.CogsOcrCod; item.Programacao = line.CogsOcrCod2; item.Escritorio = line.CogsOcrCod3; entity.Itens.Add(item); } } if (record.DocumentInstallments != null) { entity.Parcelas = new List <SalesInvoiceInstallment>(); foreach (var installment in record.DocumentInstallments) { SalesInvoiceInstallment parcela = new SalesInvoiceInstallment(); parcela.DataVencimento = Convert.ToDateTime((string)installment.DueDate).ToString("yyyy-MM-dd"); parcela.ValorParcela = Convert.ToDouble(installment.Total); entity.Parcelas.Add(parcela); break; } } return(entity); }
public InvoiceItemModel(SalesInvoiceItem item) { this.Reference = item.InvoiceItemType?.Name; this.Product = item.Product?.Name; this.Description = item.Description; this.Details = item.Details; this.Quantity = item.Quantity; // TODO: Where does the currency come from? var currency = "€"; this.Price = item.CalculatedUnitPrice.ToString("0.00") + " " + currency; this.Amount = item.TotalExVat.ToString("0.00") + " " + currency; this.Comment = item.Comment; }
public InvoiceItemModel(SalesInvoiceItem item) { var currencyIsoCode = item.SalesInvoiceWhereSalesInvoiceItem.Currency.IsoCode; this.Reference = item.InvoiceItemType?.Name; this.Product = item.ExistProduct ? item.Product?.Name : item.Part?.Name; if (item.ExistDescription) { this.Description = item.Description; this.Description = Markdown.ToPlainText(this.Description); } this.Quantity = item.Quantity; // TODO: Where does the currency come from? var currency = "€"; this.Price = item.UnitPrice.ToString("N2", new CultureInfo("nl-BE")); this.Amount = item.TotalExVat.ToString("N2", new CultureInfo("nl-BE")); this.Comment = item.Comment; }
public InvoiceItemModel(SalesInvoiceItem item) { var currencyIsoCode = item.SalesInvoiceWhereSalesInvoiceItem.DerivedCurrency.IsoCode; this.Reference = item.InvoiceItemType?.Name; this.Product = item.ExistProduct ? item.Product?.Name : item.Part?.Name; var description = item.Description; if (description != null) { description = Markdown.ToPlainText(description); } this.Description = description?.Split('\n'); this.Quantity = item.Quantity; // TODO: Where does the currency come from? this.Price = Rounder.RoundDecimal(item.UnitPrice, 2).ToString("N2", new CultureInfo("nl-BE")); this.Amount = Rounder.RoundDecimal(item.TotalExVat, 2).ToString("N2", new CultureInfo("nl-BE")); this.Comment = item.Comment?.Split('\n'); }
private void SetSalesInvoiceSalesOrderLineData(SalesInvoice salesInvoice, SalesOrderLine salesOrderLine, SalesInvoiceItem salesInvoiceItem) { if (salesInvoiceItem.ForFreight == 1) { salesInvoice.FreightAmount = salesInvoiceItem.Amount; } else { var _ = salesInvoice.AddSalesOrderLine(salesOrderLine); _.Quantity = salesInvoiceItem.Qty; _.Amount = salesInvoiceItem.Amount; _.UnitPrice = Decimal.Divide(salesInvoiceItem.Amount, salesInvoiceItem.Qty); // _.CalculateUnitCost(_.Quantity, _.Amount); _.Description = GetLineDescription(salesInvoiceItem); } }
public SalesInvoiceItemViewModel(IViewModelDependencies appCtx, IZetboxContext dataCtx, ViewModel parent, SalesInvoiceItem obj) : base(appCtx, dataCtx, parent, obj) { this.InvoiceItem = obj; }