public CashSalesInvoiceDetail SoftDeleteObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService) { if (_validator.ValidDeleteObject(cashSalesInvoiceDetail, _cashSalesInvoiceService)) { CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId); _repository.SoftDeleteObject(cashSalesInvoiceDetail); cashSalesInvoice.Total = CalculateTotal(cashSalesInvoice.Id); cashSalesInvoice.CoGS = CalculateCoGS(cashSalesInvoice.Id); _cashSalesInvoiceService.GetRepository().Update(cashSalesInvoice); } ; return(cashSalesInvoiceDetail); }
public CashSalesInvoiceDetail CreateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService, IItemService _itemService, IWarehouseItemService _warehouseItemService, IQuantityPricingService _quantityPricingService) { cashSalesInvoiceDetail.Errors = new Dictionary <String, String>(); if (_validator.ValidCreateObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, this, _itemService, _warehouseItemService, _quantityPricingService)) { Item item = _itemService.GetObjectById(cashSalesInvoiceDetail.ItemId); QuantityPricing quantityPricing = _quantityPricingService.GetObjectByItemTypeIdAndQuantity(item.ItemTypeId, cashSalesInvoiceDetail.Quantity); decimal price = item.SellingPrice; decimal discount = cashSalesInvoiceDetail.Discount; if (cashSalesInvoiceDetail.IsManualPriceAssignment) { price = cashSalesInvoiceDetail.AssignedPrice; } else { cashSalesInvoiceDetail.AssignedPrice = 0; } if (quantityPricing != null) { if (cashSalesInvoiceDetail.Discount <= 0) { discount = quantityPricing.Discount; } ; } cashSalesInvoiceDetail.Amount = (price * (100 - discount) / 100) * cashSalesInvoiceDetail.Quantity; cashSalesInvoiceDetail.CoGS = cashSalesInvoiceDetail.Quantity * item.AvgPrice; CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId); cashSalesInvoiceDetail.PriceMutationId = item.PriceMutationId; cashSalesInvoiceDetail = _repository.CreateObject(cashSalesInvoiceDetail); cashSalesInvoice.Total = CalculateTotal(cashSalesInvoice.Id); cashSalesInvoice.CoGS = CalculateCoGS(cashSalesInvoice.Id); _cashSalesInvoiceService.GetRepository().Update(cashSalesInvoice); } return(cashSalesInvoiceDetail); }