public static CheckDTO ConvertToDTO(this Check model, IMapper _mapper) { CheckDTO dto = _mapper.Map <Check, CheckDTO>(model); dto.UserChecks = model.UserChecks.Select(c => c.ConvertToDTO(_mapper)).ToList(); return(dto); }
private async Task SetLastResultStatus(CheckDTO check, bool simpleStatus = true) { var result = await _checkResults.GetAll().Where(x => x.CheckID == check.ID).OrderByDescending(x => x.ID).FirstOrDefaultAsync(); var status = result?.Status; if (status == null) { check.LastResultStatus = CheckResultStatus.NotRun; } else if (!simpleStatus) { check.LastResultStatus = status; } else if (status > CheckResultStatus.Success) { check.LastResultStatus = CheckResultStatus.Warning; } else if (status == CheckResultStatus.Success) { check.LastResultStatus = CheckResultStatus.Success; } else { check.LastResultStatus = CheckResultStatus.Failed; } }
public IActionResult TakeAction([FromBody] CheckDTO Check) { var result = _CheckRepositry.GetById(Check.id); if (!string.IsNullOrEmpty(Check.result) && result != null) { CheckResult CheckResult = new CheckResult(); CheckResult.orderid = Check.id; CheckResult.result = Check.result; CheckResult.useraction = Check.useraction; CheckResult.createdate = DateTime.Now; var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Check").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } _CheckResultRepositry.Insert(CheckResult); _CheckResultRepositry.Save(); _CheckRepositry.Update(result); _CheckRepositry.Save(); } if (Check.Done == true && result != null) { result.Done = Check.Done; result.useraction = Check.useraction; var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Check").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } _CheckRepositry.Update(result); _CheckRepositry.Save(); } if (Check.late.HasValue && result != null) { if (Check.late.Value < DateTime.Now || Check.late.Value.Hour < 9 || Check.late.Value.Hour > 17) { return(Ok("Invalid Date")); } var difference = (int)(Check.late.Value - result.create).TotalHours; result.count = difference; result.useraction = Check.useraction; var lockresult = _LockRepositry.GetAll().Where(s => s.customerid == result.customerid && s.objectname == "Check").FirstOrDefault(); if (lockresult != null) { _LockRepositry.Delete(lockresult.id); _LockRepositry.Save(); } _CheckRepositry.Update(result); _CheckRepositry.Save(); } return(Ok(true)); }
private void SetLastResultStatus(CheckDTO check, LastResultStatus lastResultStatus) { if (lastResultStatus == null) { check.LastResultStatus = null; check.LastResultType = null; } else { check.LastResultStatus = lastResultStatus.StatusID; check.LastResultType = lastResultStatus.TypeID; } }
public async ValueTask <IActionResult> Get(int id) { Check check = await _repo.Item() .Where(c => c.Id == id) .Include(c => c.UserChecks) .FirstOrDefaultAsync(); if (check != null) { CheckDTO model = check.ConvertToDTO(_mapper); return(Ok(model)); } return(NotFound(new ErrorDTO { Message = "Item not found" })); }
public List <CheckDTO> GetCheck() { List <CheckDTO> checks = new List <CheckDTO>(); foreach (var c in context.Checks.ToList()) { CheckDTO check = new CheckDTO() { Date = c.Date, Price = c.Price, Sale = c.Sale, }; checks.Add(check); } return(checks); }
public void MakePurchaseReturnsCode409() { CheckDTO returnedCheck = null; var request = new PurchaseRequest(); var dbMock = new Mock <IPurchaseRepository>(); dbMock.Setup(f => f.isUserAndShopExists(request)).Returns(true); dbMock.Setup(f => f.MakePurchase(request)).Returns(returnedCheck); var controllerMock = new Mock <PurchasesController>(dbMock.Object); controllerMock.Setup(f => f.isPurchaseRequestValid(request)).Returns(true); PurchasesController controller = controllerMock.Object; var result = controller.MakePurchase(request); Assert.Equal(409, result.StatusCode); }
public JsonResult MakePurchase(PurchaseRequest request) { if (!isPurchaseRequestValid(request)) { return(_Response.BadRequest()); } if (!_db.isUserAndShopExists(request)) { return(_Response.BadRequest()); } CheckDTO check = _db.MakePurchase(request); if (check == null) { return(_Response.Conflict()); } return(_Response.Ok(check)); }
public CheckDTO GetCheckByAttributes(int pDocEntry, string pBankAcct, int pCheckNum, double pCheckSum) { SAPbobsCOM.Recordset lObjResults = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); try { Dictionary <string, string> lObjParameters = new Dictionary <string, string>(); lObjParameters.Add("DocEntry", pDocEntry.ToString()); lObjParameters.Add("BankAcct", pBankAcct); lObjParameters.Add("CheckNum", pCheckNum.ToString()); lObjParameters.Add("CheckSum", pCheckSum.ToString()); string lStrQuery = this.GetSQL("GetCheckByAttributes").Inject(lObjParameters); lObjResults.DoQuery(lStrQuery); if (lObjResults.RecordCount > 0) { CheckDTO lObjBank = new CheckDTO(); lObjBank.CheckKey = lObjResults.GetColumnValue <int>("CheckKey"); lObjBank.CheckNum = lObjResults.GetColumnValue <int>("CheckNum"); lObjBank.CheckSum = lObjResults.GetColumnValue <double>("CheckSum"); lObjBank.CardName = lObjResults.GetColumnValue <string>("CardName"); lObjBank.CardCode = lObjResults.GetColumnValue <string>("CardCode"); lObjBank.CheckDate = lObjResults.GetColumnValue <DateTime>("CheckDate"); lObjBank.Deposited = lObjResults.GetColumnValue <string>("Deposited"); lObjBank.BankAcct = lObjResults.GetColumnValue <string>("BankAcct"); return(lObjBank); } return(null); } catch (Exception e) { LogUtility.WriteError(string.Format("[CheckDAO - GetCheckByAttributes] Error al obtener el cheque: {0}", e.Message)); throw new Exception(string.Format("Error al obtener el cheque: {0}", e.Message)); } finally { MemoryUtility.ReleaseComObject(lObjResults); } }
public IList <CheckDTO> GetChecks() { SAPbobsCOM.Recordset lObjResults = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); IList <CheckDTO> lLstChecks = new List <CheckDTO>(); try { string lStrQuery = this.GetSQL("GetChecks"); lObjResults.DoQuery(lStrQuery); if (lObjResults.RecordCount > 0) { for (int i = 0; i < lObjResults.RecordCount; i++) { CheckDTO lObjBank = new CheckDTO(); lObjBank.CheckKey = lObjResults.GetColumnValue <int>("CheckKey"); lObjBank.CheckNum = lObjResults.GetColumnValue <int>("CheckNum"); lObjBank.CheckSum = lObjResults.GetColumnValue <double>("CheckSum"); lObjBank.CardName = lObjResults.GetColumnValue <string>("CardName"); lObjBank.CardCode = lObjResults.GetColumnValue <string>("CardCode"); lObjBank.CheckDate = lObjResults.GetColumnValue <DateTime>("CheckDate"); lObjBank.Deposited = lObjResults.GetColumnValue <string>("Deposited"); lObjBank.BankAcct = lObjResults.GetColumnValue <string>("BankAcct"); lObjBank.Currency = lObjResults.GetColumnValue <string>("Currency"); lLstChecks.Add(lObjBank); lObjResults.MoveNext(); } } return(lLstChecks); } catch (Exception lObjException) { LogUtility.WriteError(string.Format("[CheckDAO - GetChecks] Error al obtener los cheques: {0}", lObjException.Message)); throw new Exception(string.Format("Error al obtener los cheques: {0}", lObjException.Message)); } finally { MemoryUtility.ReleaseComObject(lObjResults); } }
private void AddCheck() { var dueDate = DateTime.Now.AddDays(BusinessPartner.PaymentTerm); if (SelectedCheck == null) { SelectedCheck = new CheckDTO { CheckDate = dueDate, CheckDueDate = dueDate, CheckAmount = SelectedPaymentModel.AmountLeft.ToString("N"), CustomerBankAccount = new FinancialAccountDTO() }; } var checkEntry = new CheckEntry(SelectedCheck); checkEntry.ShowDialog(); if (checkEntry.DialogResult != null && !(bool)checkEntry.DialogResult) { SelectedCheck = null; } }
public string PostPayments(TransactionHeaderDTO transaction2, PaymentDTO payment2, PaymentModel paymentModel, CheckDTO selectedCheck) { string stat = string.Empty; try { var transaction = _transactionRepository .Query() .Include(t => t.Warehouse, t => t.BusinessPartner, t => t.TransactionLines, t => t.Payments) .Filter(t => t.Id == transaction2.Id) .Get() .FirstOrDefault(); if (transaction == null) { return("Empty transaction"); } var bp = _businessPartnerRepository .Query() .Filter(b => b.Id == transaction.BusinessPartnerId) .Get() .FirstOrDefault(); if (bp == null) { return("No Business Partner"); } PaymentDTO cashPayment = null; if (paymentModel.Amount > 0) //always cash payment { #region Cash Payment cashPayment = GetNewPayment(transaction, paymentModel.PaymentDate); if (cashPayment != null) { cashPayment.PaymentMethod = PaymentMethods.Cash; cashPayment.Status = PaymentStatus.NotDeposited; cashPayment.Amount = paymentModel.Amount - paymentModel.Change; if (!Singleton.Setting.HandleBankTransaction) { cashPayment.Status = PaymentStatus.Cleared; } _paymentRepository.Insert(cashPayment); if (payment2 != null) { bp.TotalCredits = bp.TotalCredits - cashPayment.Amount; if (payment2.Amount - cashPayment.Amount == 0) { bp.TotalNoOfCreditTransactions = bp.TotalNoOfCreditTransactions - 1; } _businessPartnerRepository.InsertUpdate(bp); } } #endregion } //Commented because is always cash payment if (paymentModel.Amount < paymentModel.AmountRequired) { if (selectedCheck != null && selectedCheck.CheckNumber.Length > 0) { #region Check Payment var checkPayment = GetNewPayment(transaction, paymentModel.PaymentDate); if (checkPayment != null) { checkPayment.Check = selectedCheck; checkPayment.PaymentMethod = PaymentMethods.Check; checkPayment.Amount = paymentModel.AmountRequired - paymentModel.Amount; //piList.Add(checkPayment); _paymentRepository.Insert(checkPayment); if (payment2 == null) { bp.TotalCredits = bp.TotalCredits + checkPayment.Amount; bp.TotalNoOfCreditTransactions = bp.TotalNoOfCreditTransactions + 1; _businessPartnerRepository.InsertUpdate(bp); } } #endregion } else if (transaction.BusinessPartner.AllowCreditsWithoutCheck) { #region Credit Payment var creditPayment = GetNewPayment(transaction, paymentModel.PaymentDate); if (creditPayment != null) { creditPayment.PaymentMethod = PaymentMethods.Credit; creditPayment.DueDate = DateTime.Now.AddDays(transaction.BusinessPartner.PaymentTerm); creditPayment.Amount = paymentModel.AmountRequired - paymentModel.Amount; _paymentRepository.Insert(creditPayment); if (payment2 == null) { bp.TotalCredits = bp.TotalCredits + creditPayment.Amount; bp.TotalNoOfCreditTransactions = bp.TotalNoOfCreditTransactions + 1; _businessPartnerRepository.InsertUpdate(bp); } } #endregion } else { stat = "Got problem while getting check detail, Can't take credit or problem on check .."; if (cashPayment != null) { _paymentRepository.Delete(cashPayment); } } } if (string.IsNullOrEmpty(stat)) { if (payment2 == null) { // Update Inventory var iqList = new ItemQuantityService(_iDbContext).UpdateInventoryByTransaction(transaction); foreach (var itemQuantityDTO in iqList) { _itemsQuantityRepository.InsertUpdate(itemQuantityDTO); } //Update transaction transaction.Status = TransactionStatus.Posted; _transactionRepository.InsertUpdate(transaction); _unitOfWork.Commit(); } else { var payment = _paymentRepository.FindById(payment2.Id); payment.Enabled = false; _paymentRepository.Update(payment); _unitOfWork.Commit(); } } } catch (Exception exception) { stat = exception.Message; } finally { _iDbContext.Dispose(); } return(stat); }
public CheckEntry(CheckDTO check) { CheckEntryViewModel.Errors = 0; InitializeComponent(); Messenger.Default.Send <CheckDTO>(check); }