public dynamic GetInfo(int Id) { SalesInvoice model = new SalesInvoice(); try { model = _salesInvoiceService.GetObjectById(Id); } catch (Exception ex) { LOG.Error("GetInfo", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Id, model.Code, model.DeliveryOrderId, DeliveryOrder = _deliveryOrderService.GetObjectById(model.DeliveryOrderId).Code, model.AmountReceivable, model.Discount, model.Description, model.IsTaxable, model.InvoiceDate, model.DueDate, model.Errors }, JsonRequestBehavior.AllowGet)); }
public SalesInvoiceDetail VHasSalesInvoice(SalesInvoiceDetail salesInvoiceDetail, ISalesInvoiceService _salesInvoiceService) { SalesInvoice salesInvoice = _salesInvoiceService.GetObjectById(salesInvoiceDetail.SalesInvoiceId); if (salesInvoice == null) { salesInvoiceDetail.Errors.Add("SalesInvoiceId", "Tidak terasosiasi dengan sales invoice"); } return(salesInvoiceDetail); }
public SalesInvoiceDetail SoftDeleteObject(SalesInvoiceDetail salesInvoiceDetail, ISalesInvoiceService _salesInvoiceService) { if (_validator.ValidDeleteObject(salesInvoiceDetail)) { SalesInvoice salesInvoice = _salesInvoiceService.GetObjectById(salesInvoiceDetail.SalesInvoiceId); _repository.SoftDeleteObject(salesInvoiceDetail); _salesInvoiceService.CalculateAmountReceivable(salesInvoice, this); } return(salesInvoiceDetail); }
public SalesInvoiceDetail VDeliveryOrderDetailAndSalesInvoiceMustHaveTheSameDeliveryOrder(SalesInvoiceDetail salesInvoiceDetail, IDeliveryOrderDetailService _deliveryOrderDetailService, ISalesInvoiceService _salesInvoiceService) { DeliveryOrderDetail deliveryOrderDetail = _deliveryOrderDetailService.GetObjectById(salesInvoiceDetail.DeliveryOrderDetailId); SalesInvoice salesInvoice = _salesInvoiceService.GetObjectById(salesInvoiceDetail.SalesInvoiceId); if (deliveryOrderDetail.DeliveryOrderId != salesInvoice.DeliveryOrderId) { deliveryOrderDetail.Errors.Add("Generic", "Delivery order detail dan sales invoice memiliki delivery order berbeda"); } return(salesInvoiceDetail); }
public SalesInvoiceDetail UpdateObject(SalesInvoiceDetail salesInvoiceDetail, ISalesInvoiceService _salesInvoiceService, ISalesOrderDetailService _salesOrderDetailService, IDeliveryOrderDetailService _deliveryOrderDetailService) { if (_validator.ValidUpdateObject(salesInvoiceDetail, _salesInvoiceService, this, _deliveryOrderDetailService)) { DeliveryOrderDetail deliveryOrderDetail = _deliveryOrderDetailService.GetObjectById(salesInvoiceDetail.DeliveryOrderDetailId); SalesOrderDetail salesOrderDetail = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId); salesInvoiceDetail.Amount = salesInvoiceDetail.Quantity * salesOrderDetail.Price; _repository.UpdateObject(salesInvoiceDetail); SalesInvoice salesInvoice = _salesInvoiceService.GetObjectById(salesInvoiceDetail.SalesInvoiceId); _salesInvoiceService.CalculateAmountReceivable(salesInvoice, this); } return(salesInvoiceDetail); }
public SalesInvoiceDetail CreateObject(SalesInvoiceDetail salesInvoiceDetail, ISalesInvoiceService _salesInvoiceService, ISalesOrderDetailService _salesOrderDetailService, IDeliveryOrderDetailService _deliveryOrderDetailService) { salesInvoiceDetail.Errors = new Dictionary <String, String>(); if (_validator.ValidCreateObject(salesInvoiceDetail, _salesInvoiceService, this, _deliveryOrderDetailService)) { DeliveryOrderDetail deliveryOrderDetail = _deliveryOrderDetailService.GetObjectById(salesInvoiceDetail.DeliveryOrderDetailId); SalesOrderDetail salesOrderDetail = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId); salesInvoiceDetail.Amount = salesInvoiceDetail.Quantity * salesOrderDetail.Price; salesInvoiceDetail = _repository.CreateObject(salesInvoiceDetail); SalesInvoice salesInvoice = _salesInvoiceService.GetObjectById(salesInvoiceDetail.SalesInvoiceId); _salesInvoiceService.CalculateAmountReceivable(salesInvoice, this); } return(salesInvoiceDetail); }