internal static void AddNewTransactionDetail(string codeProduct, string terminal, string transaction, bool minus) { using (IDalTransaction dal = new DalTransaction()) { //find productId with codeProduct PRODUCT prod; using (IDalProduct dalP = new DalProduct()) { prod = dalP.GetProductByCode(codeProduct); } //verify if product exist in detail and Add or Remove itemDetail IList <TRANSACTION_DETAILS> detailList = FindTransactionDetailsListById(transaction); var result = VerifyProductInDetail(prod.idProduct, detailList); if (result) { //Product exist --> Modify qty foreach (var item in detailList) { if (item.productId == prod.idProduct) { var newqty = 0; if (minus) { //qty-- newqty = item.quantity - 1; if (newqty == 0) { dal.DeleteDetail(item.idTransactionDetails); break; } dal.EditQtyToDetailById(item.idTransactionDetails, newqty); break; } else { //qty++ newqty = item.quantity + 1; dal.EditQtyToDetailById(item.idTransactionDetails, newqty); break; } } } } else { //Add new detail --> param product, terminalId, transactionId, vatItem decimal vatItem; using (IDalVat dalV = new DalVat()) { vatItem = dalV.GetVatValById(prod.vatId); } int terminalId = int.Parse(terminal); int transactionId = int.Parse(transaction); dal.CreateDetail(prod, terminalId, transactionId, vatItem); } } }
private static string FindVatValById(int?vatId) { if (vatId != null) { using (IDalVat dal = new DalVat()) { return((dal.GetVatValById(vatId)).ToString()); } } return("no VAT"); }
internal static string FindVatValById(int?vatId) { if (vatId != null) { using (IDalVat dal = new DalVat()) { var temp = (dal.GetVatValById(vatId) * 100).ToString(); var tempsplit = temp.Split(','); var tva = tempsplit[0] + "%"; return(tva); } } return("no VAT"); }
internal static Decimal VatIncl(int id, decimal price) { using (IDalVat dal = new DalVat()) { decimal vat = dal.GetVatValById(id); if (vat != 0) { ++vat; return(price * vat); } return(price); } }