public CashSalesReturn ConfirmObject(CashSalesReturn cashSalesReturn, DateTime ConfirmationDate, decimal Allowance, ICashSalesReturnDetailService _cashSalesReturnDetailService, IContactService _contactService, ICashSalesInvoiceService _cashSalesInvoiceService, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IPriceMutationService _priceMutationService, IPayableService _payableService, ICashSalesReturnService _cashSalesReturnService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, IClosingService _closingService) { cashSalesReturn.ConfirmationDate = ConfirmationDate; cashSalesReturn.Allowance = Allowance; if (_validator.ValidConfirmObject(cashSalesReturn, _cashSalesReturnDetailService, _cashSalesReturnService, _cashSalesInvoiceService, _cashSalesInvoiceDetailService)) { IList <CashSalesReturnDetail> cashSalesReturnDetails = _cashSalesReturnDetailService.GetObjectsByCashSalesReturnId(cashSalesReturn.Id); foreach (var cashSalesReturnDetail in cashSalesReturnDetails) { cashSalesReturnDetail.Errors = new Dictionary <string, string>(); _cashSalesReturnDetailService.ConfirmObject(cashSalesReturnDetail, _cashSalesReturnService, _cashSalesInvoiceService, _cashSalesInvoiceDetailService, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService, _cashSalesReturnDetailService); } // DueDate untuk Payable dari mana ? Contact contact = _contactService.GetObjectByName(Core.Constants.Constant.BaseContact); Payable payable = _payableService.CreateObject(contact.Id, Core.Constants.Constant.PayableSource.CashSalesReturn, cashSalesReturn.Id, cashSalesReturn.Code, cashSalesReturn.Total, ConfirmationDate.Add(Core.Constants.Constant.PaymentDueDateTimeSpan)); cashSalesReturn = _repository.ConfirmObject(cashSalesReturn); } else { cashSalesReturn.ConfirmationDate = null; cashSalesReturn.Allowance = 0; } return(cashSalesReturn); }
public CashSalesReturn VHasCashSalesReturnDetails(CashSalesReturn cashSalesReturn, ICashSalesReturnDetailService _cashSalesReturnDetailService) { IList <CashSalesReturnDetail> cashSalesReturnDetails = _cashSalesReturnDetailService.GetObjectsByCashSalesReturnId(cashSalesReturn.Id); if (!cashSalesReturnDetails.Any()) { cashSalesReturn.Errors.Add("Generic", "CashSalesReturnDetils Tidak ada"); } return(cashSalesReturn); }
public CashSalesReturn VHasNoCashSalesReturnDetails(CashSalesReturn cashSalesReturn, ICashSalesReturnDetailService _cashSalesReturnDetailService) { IList <CashSalesReturnDetail> cashSalesReturnDetails = _cashSalesReturnDetailService.GetObjectsByCashSalesReturnId(cashSalesReturn.Id); if (cashSalesReturnDetails.Any()) { cashSalesReturn.Errors.Add("Generic", "Tidak boleh terasosiasi dengan CashSalesReturnDetails"); } return(cashSalesReturn); }
public CashSalesReturn VIsUnconfirmableCashSalesReturnDetails(CashSalesReturn cashSalesReturn, ICashSalesReturnDetailService _cashSalesReturnDetailService) { IList <CashSalesReturnDetail> cashSalesReturnDetails = _cashSalesReturnDetailService.GetObjectsByCashSalesReturnId(cashSalesReturn.Id); if (!cashSalesReturnDetails.Any()) { cashSalesReturn.Errors.Add("Generic", "CashSalesReturnDetails Tidak ada"); } else { ICashSalesReturnDetailValidator validator = _cashSalesReturnDetailService.GetValidator(); foreach (var cashSalesReturnDetail in cashSalesReturnDetails) { cashSalesReturnDetail.Errors = new Dictionary <string, string>(); if (!validator.ValidUnconfirmObject(cashSalesReturnDetail)) { cashSalesReturn.Errors.Add("Generic", "CashSalesReturnDetails harus unconfirmable semua"); return(cashSalesReturn); } } } return(cashSalesReturn); }
public CashSalesReturn UnconfirmObject(CashSalesReturn cashSalesReturn, ICashSalesReturnDetailService _cashSalesReturnDetailService, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, IClosingService _closingService) { if (_validator.ValidUnconfirmObject(cashSalesReturn, _cashSalesReturnDetailService, _payableService, _paymentVoucherDetailService)) { cashSalesReturn = _repository.UnconfirmObject(cashSalesReturn); IList <CashSalesReturnDetail> cashSalesReturnDetails = _cashSalesReturnDetailService.GetObjectsByCashSalesReturnId(cashSalesReturn.Id); foreach (var cashSalesReturnDetail in cashSalesReturnDetails) { cashSalesReturnDetail.Errors = new Dictionary <string, string>(); _cashSalesReturnDetailService.UnconfirmObject(cashSalesReturnDetail, _cashSalesInvoiceDetailService, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService); } Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.CashSalesReturn, cashSalesReturn.Id); _payableService.SoftDeleteObject(payable); cashSalesReturn.Total = 0; cashSalesReturn.Allowance = 0; } return(cashSalesReturn); }