public bool AddTransaction(MVCQutationModel quatationModel) { bool result = false; try { TransactionModel model = new TransactionModel(); model.CompanyId = (int)quatationModel.CompanyId; model.AccountTitle = "Accounts receivable"; int AccountId = CommonController.GetAcccountId(model); if (AccountId > 0) { AccountTransictionTable _TransactionTable = new AccountTransictionTable(); _TransactionTable.FK_AccountID = AccountId; _TransactionTable.Dr = quatationModel.SubTotal; _TransactionTable.Cr = 0; _TransactionTable.TransictionNumber = Guid.NewGuid().ToString(); _TransactionTable.TransictionRefrenceId = quatationModel.QutationID.ToString(); _TransactionTable.CreationTime = DateTime.Now.TimeOfDay; _TransactionTable.AddedBy = Convert.ToInt32(Session["LoginUserID"]); _TransactionTable.FK_CompanyId = quatationModel.CompanyId; _TransactionTable.TransictionType = "Dr"; _TransactionTable.FKPaymentTerm = null; _TransactionTable.TransictionDate = DateTime.Now; _TransactionTable.Description = "invoice Creating Time Transaction"; if (TransactionClass.PerformTransaction(_TransactionTable)) { result = true; model.AccountTitle = "Input VAT"; int AccountId1 = CommonController.GetAcccountId(model); _TransactionTable.FK_AccountID = AccountId1; _TransactionTable.Dr = quatationModel.TotalVat21 + quatationModel.TotalVat6; if (TransactionClass.PerformTransaction(_TransactionTable)) { result = true; model.AccountTitle = "Cash on hand"; int AccountId12 = CommonController.GetAcccountId(model); _TransactionTable.FK_AccountID = AccountId12; _TransactionTable.Cr = quatationModel.TotalAmount; _TransactionTable.Dr = 0; _TransactionTable.TransictionType = "Cr"; if (TransactionClass.PerformTransaction(_TransactionTable)) { result = true; } } } } } catch (Exception) { throw; } return(result); }
public ActionResult DeleteInvoice(int Id, int ExpenseDetailId, int vat, float total) { try { HttpResponseMessage response = GlobalVeriables.WebApiClient.GetAsync("GetExpenseById/" + Id).Result; ExpenseViewModel ExpenseMosel = response.Content.ReadAsAsync <ExpenseViewModel>().Result; double ResultVAT = CommonController.CalculateVat(vat, total); ExpenseMosel.GRAND_TOTAL = Convert.ToDouble(ExpenseMosel.GRAND_TOTAL) - Convert.ToDouble(ResultVAT); ExpenseMosel.GRAND_TOTAL = Convert.ToDouble(ExpenseMosel.GRAND_TOTAL) - Convert.ToDouble(total); ExpenseMosel.VAT_AMOUNT = ExpenseMosel.VAT_AMOUNT - Convert.ToDouble(vat); ExpenseMosel.SUBTOTAL = ExpenseMosel.SUBTOTAL - Convert.ToDouble(total); if (vat == 6) { ExpenseMosel.Vat6 = (ExpenseMosel.Vat6) - Convert.ToDouble(ResultVAT); } if (vat == 21) { ExpenseMosel.Vat21 = (ExpenseMosel.Vat21) - Convert.ToDouble(ResultVAT); } response = GlobalVeriables.WebApiClient.PutAsJsonAsync("PutExpense/" + ExpenseMosel.Id, ExpenseMosel).Result; EXPENSE exp = response.Content.ReadAsAsync <EXPENSE>().Result; if (response.StatusCode == System.Net.HttpStatusCode.OK) { HttpResponseMessage deleteExpenseDetail = GlobalVeriables.WebApiClient.DeleteAsync("DeleteExpenseDetails/" + ExpenseDetailId).Result; if (deleteExpenseDetail.StatusCode == System.Net.HttpStatusCode.OK) { return(new JsonResult { Data = new { Status = "Success" } }); } } return(new JsonResult { Data = new { Status = "Fail" } }); } catch (Exception ex) { return(new JsonResult { Data = new { Status = "Fail" } }); } }
public bool Transaction(MVCQutationModel quatationModel, string TransType) { bool result = false; try { if (TransType == "Add") { if (AddTransaction(quatationModel)) { return(result = true); } else { return(result = false); } } else { if (CommonController.DeleteFromTransactionTableByRefrenceId((int)quatationModel.QutationID)) { if (AddTransaction(quatationModel)) { return(result = true); } else { return(result = false); } } } } catch (Exception) { result = false; throw; } return(result); }