public bool ValidConfirmObject(RetailPurchaseInvoice retailPurchaseInvoice, IRetailPurchaseInvoiceDetailService _retailPurchaseInvoiceDetailService, IRetailPurchaseInvoiceService _retailPurchaseInvoiceService, IWarehouseItemService _warehouseItemService, IContactService _contactService) { retailPurchaseInvoice.Errors.Clear(); VConfirmObject(retailPurchaseInvoice, _retailPurchaseInvoiceDetailService, _retailPurchaseInvoiceService, _warehouseItemService, _contactService); return(isValid(retailPurchaseInvoice)); }
public RetailPurchaseInvoice VUnconfirmObject(RetailPurchaseInvoice retailPurchaseInvoice, IRetailPurchaseInvoiceDetailService _retailPurchaseInvoiceDetailService, IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService) { VIsNotDeleted(retailPurchaseInvoice); if (!isValid(retailPurchaseInvoice)) { return(retailPurchaseInvoice); } VIsConfirmed(retailPurchaseInvoice); if (!isValid(retailPurchaseInvoice)) { return(retailPurchaseInvoice); } VIsNotPaid(retailPurchaseInvoice); if (!isValid(retailPurchaseInvoice)) { return(retailPurchaseInvoice); } VIsUnconfirmableRetailPurchaseInvoiceDetails(retailPurchaseInvoice, _retailPurchaseInvoiceDetailService); if (!isValid(retailPurchaseInvoice)) { return(retailPurchaseInvoice); } VHasNoPaymentVoucherDetails(retailPurchaseInvoice, _payableService, _paymentVoucherDetailService); return(retailPurchaseInvoice); }
public bool ValidUnconfirmObject(RetailPurchaseInvoice retailPurchaseInvoice, IRetailPurchaseInvoiceDetailService _retailPurchaseInvoiceDetailService, IPayableService _payableService, IPaymentVoucherDetailService _paymentVoucherDetailService) { retailPurchaseInvoice.Errors.Clear(); VUnconfirmObject(retailPurchaseInvoice, _retailPurchaseInvoiceDetailService, _payableService, _paymentVoucherDetailService); return(isValid(retailPurchaseInvoice)); }
public RetailPurchaseInvoice ConfirmObject(RetailPurchaseInvoice retailPurchaseInvoice, DateTime ConfirmationDate, int ContactId, IRetailPurchaseInvoiceDetailService _retailPurchaseInvoiceDetailService, IContactService _contactService, IPriceMutationService _priceMutationService, IPayableService _payableService, IRetailPurchaseInvoiceService _retailPurchaseInvoiceService, IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService, IClosingService _closingService) { retailPurchaseInvoice.ContactId = ContactId; retailPurchaseInvoice.ConfirmationDate = ConfirmationDate; if (_validator.ValidConfirmObject(retailPurchaseInvoice, _retailPurchaseInvoiceDetailService, _retailPurchaseInvoiceService, _warehouseItemService, _contactService)) { IList <RetailPurchaseInvoiceDetail> retailPurchaseInvoiceDetails = _retailPurchaseInvoiceDetailService.GetObjectsByRetailPurchaseInvoiceId(retailPurchaseInvoice.Id); retailPurchaseInvoice.Total = 0; retailPurchaseInvoice.CoGS = 0; foreach (var retailPurchaseInvoiceDetail in retailPurchaseInvoiceDetails) { retailPurchaseInvoiceDetail.Errors = new Dictionary <string, string>(); _retailPurchaseInvoiceDetailService.ConfirmObject(retailPurchaseInvoiceDetail, _retailPurchaseInvoiceService, _warehouseItemService, _warehouseService, _itemService, _barringService, _stockMutationService); retailPurchaseInvoice.Total += retailPurchaseInvoiceDetail.Amount; retailPurchaseInvoice.CoGS += retailPurchaseInvoiceDetail.CoGS; } // Tax dihitung setelah discount retailPurchaseInvoice.Total = (retailPurchaseInvoice.Total * (100 - retailPurchaseInvoice.Discount) / 100) * (100 - retailPurchaseInvoice.Tax) / 100; Payable payable = _payableService.CreateObject(retailPurchaseInvoice.ContactId, Core.Constants.Constant.PayableSource.RetailPurchaseInvoice, retailPurchaseInvoice.Id, retailPurchaseInvoice.Code, retailPurchaseInvoice.Total, (DateTime)retailPurchaseInvoice.DueDate.GetValueOrDefault()); retailPurchaseInvoice = _repository.ConfirmObject(retailPurchaseInvoice); } else { retailPurchaseInvoice.ConfirmationDate = null; //retailPurchaseInvoice.ContactId = 0; //null; } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice UnpaidObject(RetailPurchaseInvoice retailPurchaseInvoice, IPaymentVoucherService _paymentVoucherService, IPaymentVoucherDetailService _paymentVoucherDetailService, ICashBankService _cashBankService, IPayableService _payableService, ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { if (_validator.ValidUnpaidObject(retailPurchaseInvoice)) { Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.RetailPurchaseInvoice, retailPurchaseInvoice.Id); IList <PaymentVoucher> paymentVouchers = _paymentVoucherService.GetObjectsByCashBankId((int)retailPurchaseInvoice.CashBankId.GetValueOrDefault()); foreach (var paymentVoucher in paymentVouchers) { if (paymentVoucher.ContactId == retailPurchaseInvoice.ContactId) { paymentVoucher.Errors = new Dictionary <string, string>(); _paymentVoucherService.UnconfirmObject(paymentVoucher, _paymentVoucherDetailService, _cashBankService, _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); IList <PaymentVoucherDetail> paymentVoucherDetails = _paymentVoucherDetailService.GetObjectsByPaymentVoucherId(paymentVoucher.Id); foreach (var paymentVoucherDetail in paymentVoucherDetails) { _paymentVoucherDetailService.SoftDeleteObject(paymentVoucherDetail); } _paymentVoucherService.SoftDeleteObject(paymentVoucher, _paymentVoucherDetailService); } } retailPurchaseInvoice.AmountPaid = 0; retailPurchaseInvoice.IsFullPayment = false; retailPurchaseInvoice = _repository.UnpaidObject(retailPurchaseInvoice); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice PaidObject(RetailPurchaseInvoice retailPurchaseInvoice, decimal AmountPaid, ICashBankService _cashBankService, IPayableService _payableService, IPaymentVoucherService _paymentVoucherService, IPaymentVoucherDetailService _paymentVoucherDetailService, IContactService _contactService, ICashMutationService _cashMutationService, IGeneralLedgerJournalService _generalLedgerJournalService, IAccountService _accountService, IClosingService _closingService) { retailPurchaseInvoice.AmountPaid = AmountPaid; if (_validator.ValidPaidObject(retailPurchaseInvoice, _cashBankService, _paymentVoucherService)) { CashBank cashBank = _cashBankService.GetObjectById((int)retailPurchaseInvoice.CashBankId.GetValueOrDefault()); retailPurchaseInvoice.IsBank = cashBank.IsBank; if (!retailPurchaseInvoice.IsGBCH) { retailPurchaseInvoice.GBCH_No = null; retailPurchaseInvoice.Description = null; } if (retailPurchaseInvoice.AmountPaid == retailPurchaseInvoice.Total) { retailPurchaseInvoice.IsFullPayment = true; } Payable payable = _payableService.GetObjectBySource(Core.Constants.Constant.PayableSource.RetailPurchaseInvoice, retailPurchaseInvoice.Id); PaymentVoucher paymentVoucher = _paymentVoucherService.CreateObject((int)retailPurchaseInvoice.CashBankId.GetValueOrDefault(), retailPurchaseInvoice.ContactId, DateTime.Now, retailPurchaseInvoice.Total, retailPurchaseInvoice.IsGBCH, (DateTime)retailPurchaseInvoice.DueDate.GetValueOrDefault(), retailPurchaseInvoice.IsBank, _paymentVoucherDetailService, _payableService, _contactService, _cashBankService); PaymentVoucherDetail paymentVoucherDetail = _paymentVoucherDetailService.CreateObject(paymentVoucher.Id, payable.Id, (decimal)retailPurchaseInvoice.AmountPaid.GetValueOrDefault(), "Automatic Payment", _paymentVoucherService, _cashBankService, _payableService); retailPurchaseInvoice = _repository.PaidObject(retailPurchaseInvoice); _paymentVoucherService.ConfirmObject(paymentVoucher, (DateTime)retailPurchaseInvoice.ConfirmationDate.GetValueOrDefault(), _paymentVoucherDetailService, _cashBankService, _payableService, _cashMutationService, _generalLedgerJournalService, _accountService, _closingService); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VIsValidFullPayment(RetailPurchaseInvoice retailPurchaseInvoice) { if (retailPurchaseInvoice.AmountPaid != retailPurchaseInvoice.Total) { retailPurchaseInvoice.Errors.Add("AmountPaid", "Harus sama dengan Total Payable"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VIsValidGBCH_DueDate(RetailPurchaseInvoice retailPurchaseInvoice) { if (retailPurchaseInvoice.IsGBCH && (retailPurchaseInvoice.GBCH_DueDate == null || retailPurchaseInvoice.GBCH_DueDate.Equals(DateTime.FromBinary(0)))) { retailPurchaseInvoice.Errors.Add("GBCH_DueDate", "Tidak ada"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VIsValidGBCH_No(RetailPurchaseInvoice retailPurchaseInvoice) { if (retailPurchaseInvoice.IsGBCH && retailPurchaseInvoice.GBCH_No.Trim() == "") { retailPurchaseInvoice.Errors.Add("GBCH_No", "Tidak ada"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VIsConfirmed(RetailPurchaseInvoice retailPurchaseInvoice) { if (!retailPurchaseInvoice.IsConfirmed) { retailPurchaseInvoice.Errors.Add("Generic", "RetailPurchaseInvoice tidak terkonfirmasi"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VIsPaid(RetailPurchaseInvoice retailPurchaseInvoice) { if (!retailPurchaseInvoice.IsPaid) { retailPurchaseInvoice.Errors.Add("Generic", "RetailPurchaseInvoice belum dibayar"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VIsNotPaid(RetailPurchaseInvoice retailPurchaseInvoice) { if (retailPurchaseInvoice.IsPaid) { retailPurchaseInvoice.Errors.Add("Generic", "RetailPurchaseInvoice sudah terbayar"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VIsNotDeleted(RetailPurchaseInvoice retailPurchaseInvoice) { if (retailPurchaseInvoice.IsDeleted) { retailPurchaseInvoice.Errors.Add("Generic", "RetailPurchaseInvoice tidak boleh terhapus"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VHasPurchaseDate(RetailPurchaseInvoice retailPurchaseInvoice) { if (retailPurchaseInvoice.PurchaseDate == null || retailPurchaseInvoice.PurchaseDate.Equals(DateTime.FromBinary(0))) { retailPurchaseInvoice.Errors.Add("PurchaseDate", "Tidak ada"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VIsValidAmountPaid(RetailPurchaseInvoice retailPurchaseInvoice) { if (retailPurchaseInvoice.AmountPaid > retailPurchaseInvoice.Total) { retailPurchaseInvoice.Errors.Add("AmountPaid", "Harus lebih kecil atau sama dengan Total Payable"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VIsValidTax(RetailPurchaseInvoice retailPurchaseInvoice) { if (retailPurchaseInvoice.Tax < 0 || retailPurchaseInvoice.Tax > 100) { retailPurchaseInvoice.Errors.Add("Tax", "Harus diantara 0 sampai 100"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VIsValidDiscount(RetailPurchaseInvoice retailPurchaseInvoice) { if (retailPurchaseInvoice.Discount < 0 || retailPurchaseInvoice.Discount > 100) { retailPurchaseInvoice.Errors.Add("Discount", "Harus diantara 0 sampai 100"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VHasContact(RetailPurchaseInvoice retailPurchaseInvoice, IContactService _contactService) { Contact contact = _contactService.GetObjectById(retailPurchaseInvoice.ContactId); if (contact == null) { retailPurchaseInvoice.Errors.Add("ContactId", "Tidak valid"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VHasWarehouse(RetailPurchaseInvoice retailPurchaseInvoice, IWarehouseService _warehouseService) { Warehouse warehouse = _warehouseService.GetObjectById(retailPurchaseInvoice.WarehouseId); if (warehouse == null) { retailPurchaseInvoice.Errors.Add("WarehouseId", "Tidak valid"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VHasRetailPurchaseInvoiceDetails(RetailPurchaseInvoice retailPurchaseInvoice, IRetailPurchaseInvoiceDetailService _retailPurchaseInvoiceDetailService) { IList <RetailPurchaseInvoiceDetail> retailPurchaseInvoiceDetails = _retailPurchaseInvoiceDetailService.GetObjectsByRetailPurchaseInvoiceId(retailPurchaseInvoice.Id); if (!retailPurchaseInvoiceDetails.Any()) { retailPurchaseInvoice.Errors.Add("Generic", "Tidak ada retail purchase invoice details"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VCreateObject(RetailPurchaseInvoice retailPurchaseInvoice, IWarehouseService _warehouseService) { VHasPurchaseDate(retailPurchaseInvoice); if (!isValid(retailPurchaseInvoice)) { return(retailPurchaseInvoice); } VHasWarehouse(retailPurchaseInvoice, _warehouseService); return(retailPurchaseInvoice); }
public RetailPurchaseInvoiceDetail VHasRetailPurchaseInvoice(RetailPurchaseInvoiceDetail retailPurchaseInvoiceDetail, IRetailPurchaseInvoiceService _retailPurchaseInvoiceService) { RetailPurchaseInvoice retailPurchaseInvoice = _retailPurchaseInvoiceService.GetObjectById(retailPurchaseInvoiceDetail.RetailPurchaseInvoiceId); if (retailPurchaseInvoice == null) { retailPurchaseInvoiceDetail.Errors.Add("RetailPurchaseInvoiceId", "Tidak valid"); } return(retailPurchaseInvoiceDetail); }
public RetailPurchaseInvoice VHasNoRetailPurchaseInvoiceDetails(RetailPurchaseInvoice retailPurchaseInvoice, IRetailPurchaseInvoiceDetailService _retailPurchaseInvoiceDetailService) { IList <RetailPurchaseInvoiceDetail> retailPurchaseInvoiceDetails = _retailPurchaseInvoiceDetailService.GetObjectsByRetailPurchaseInvoiceId(retailPurchaseInvoice.Id); if (retailPurchaseInvoiceDetails.Any()) { retailPurchaseInvoice.Errors.Add("Generic", "Tidak boleh terasosiasi dengan RetailPurchaseInvoiceDetails"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoice VHasCashBank(RetailPurchaseInvoice retailPurchaseInvoice, ICashBankService _cashBankService) { CashBank cashBank = _cashBankService.GetObjectById((int)retailPurchaseInvoice.CashBankId.GetValueOrDefault()); if (cashBank == null) { retailPurchaseInvoice.Errors.Add("CashBankId", "Tidak valid"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoiceDetail SoftDeleteObject(RetailPurchaseInvoiceDetail retailPurchaseInvoiceDetail, IRetailPurchaseInvoiceService _retailPurchaseInvoiceService) { if (_validator.ValidDeleteObject(retailPurchaseInvoiceDetail, _retailPurchaseInvoiceService)) { RetailPurchaseInvoice retailPurchaseInvoice = _retailPurchaseInvoiceService.GetObjectById(retailPurchaseInvoiceDetail.RetailPurchaseInvoiceId); _repository.SoftDeleteObject(retailPurchaseInvoiceDetail); retailPurchaseInvoice.Total = CalculateTotal(retailPurchaseInvoice.Id); _retailPurchaseInvoiceService.GetRepository().Update(retailPurchaseInvoice); } return(retailPurchaseInvoiceDetail); }
public RetailPurchaseInvoice VIsCashBankTypeBank(RetailPurchaseInvoice retailPurchaseInvoice, ICashBankService _cashBankService) { CashBank cashBank = _cashBankService.GetObjectById((int)retailPurchaseInvoice.CashBankId.GetValueOrDefault()); if (!cashBank.IsBank) { retailPurchaseInvoice.Errors.Add("Generic", "CashBank bukan tipe Bank"); return(retailPurchaseInvoice); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoiceDetail VIsValidQuantity(RetailPurchaseInvoiceDetail retailPurchaseInvoiceDetail, IRetailPurchaseInvoiceService _retailPurchaseInvoiceService, IWarehouseItemService _warehouseItemService) { RetailPurchaseInvoice retailPurchaseInvoice = _retailPurchaseInvoiceService.GetObjectById(retailPurchaseInvoiceDetail.RetailPurchaseInvoiceId); WarehouseItem warehouseItem = _warehouseItemService.FindOrCreateObject(retailPurchaseInvoice.WarehouseId, retailPurchaseInvoiceDetail.ItemId); if (retailPurchaseInvoiceDetail.Quantity <= 0 || retailPurchaseInvoiceDetail.Quantity >= warehouseItem.Quantity) { retailPurchaseInvoiceDetail.Errors.Add("Quantity", "Quantity harus lebih besar dari 0 dan lebih kecil dari WarehouseItem Quantity"); return(retailPurchaseInvoiceDetail); } return(retailPurchaseInvoiceDetail); }
public RetailPurchaseInvoice VHasConfirmationDate(RetailPurchaseInvoice retailPurchaseInvoice) { if (retailPurchaseInvoice.ConfirmationDate == null || retailPurchaseInvoice.ConfirmationDate.Equals(DateTime.FromBinary(0))) { retailPurchaseInvoice.Errors.Add("ConfirmationDate", "Tidak ada"); } else if (retailPurchaseInvoice.ConfirmationDate.GetValueOrDefault().Date < retailPurchaseInvoice.PurchaseDate.Date) { retailPurchaseInvoice.Errors.Add("ConfirmationDate", "Harus lebih besar atau sama dengan Purchase Date"); } return(retailPurchaseInvoice); }
public RetailPurchaseInvoiceDetail VIsValidQuantityOrdered(RetailPurchaseInvoiceDetail retailPurchaseInvoiceDetail, IRetailPurchaseInvoiceService _retailPurchaseInvoiceService, IWarehouseItemService _warehouseItemService) { RetailPurchaseInvoice retailPurchaseInvoice = _retailPurchaseInvoiceService.GetObjectById(retailPurchaseInvoiceDetail.RetailPurchaseInvoiceId); WarehouseItem warehouseItem = _warehouseItemService.FindOrCreateObject(retailPurchaseInvoice.WarehouseId, retailPurchaseInvoiceDetail.ItemId); if (warehouseItem.Quantity - retailPurchaseInvoiceDetail.Quantity < 0) { retailPurchaseInvoiceDetail.Errors.Add("Generic", "Quantity harus lebih kecil atau sama dengan WarehouseItem Quantity"); return(retailPurchaseInvoiceDetail); } return(retailPurchaseInvoiceDetail); }
public RetailPurchaseInvoiceDetail VIsParentNotConfirmed(RetailPurchaseInvoiceDetail retailPurchaseInvoiceDetail, IRetailPurchaseInvoiceService _retailPurchaseInvoiceService) { RetailPurchaseInvoice retailPurchaseInvoice = _retailPurchaseInvoiceService.GetObjectById(retailPurchaseInvoiceDetail.RetailPurchaseInvoiceId); if (retailPurchaseInvoice != null) { if (retailPurchaseInvoice.IsConfirmed) { retailPurchaseInvoiceDetail.Errors.Add("Generic", "RetailPurchaseInvoice tidak boleh terkonfirmasi"); } } return(retailPurchaseInvoiceDetail); }