Пример #1
0
        public PurchaseInvoice ConfirmObject(PurchaseInvoice purchaseInvoice, DateTime ConfirmationDate, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService, IPurchaseOrderService _purchaseOrderService,
                                             IPurchaseReceivalService _purchaseReceivalService, IPurchaseReceivalDetailService _purchaseReceivalDetailService, IPayableService _payableService)
        {
            purchaseInvoice.ConfirmationDate = ConfirmationDate;
            if (_validator.ValidConfirmObject(purchaseInvoice, _purchaseInvoiceDetailService, _purchaseReceivalService, _purchaseReceivalDetailService))
            {
                // confirm details
                // add all amount into amountpayable
                IList <PurchaseInvoiceDetail> details = _purchaseInvoiceDetailService.GetObjectsByPurchaseInvoiceId(purchaseInvoice.Id);
                foreach (var detail in details)
                {
                    detail.Errors = new Dictionary <string, string>();
                    _purchaseInvoiceDetailService.ConfirmObject(detail, ConfirmationDate, _purchaseReceivalDetailService);
                }
                purchaseInvoice = CalculateAmountPayable(purchaseInvoice, _purchaseInvoiceDetailService);

                // confirm object
                // create payable
                purchaseInvoice = _repository.ConfirmObject(purchaseInvoice);
                PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseInvoice.PurchaseReceivalId);
                _purchaseReceivalService.CheckAndSetInvoiceComplete(purchaseReceival, _purchaseReceivalDetailService);
                PurchaseOrder purchaseOrder = _purchaseOrderService.GetObjectById(purchaseReceival.PurchaseOrderId);
                Payable       payable       = _payableService.CreateObject(purchaseOrder.ContactId, Constant.PayableSource.PurchaseInvoice, purchaseInvoice.Id, purchaseInvoice.AmountPayable, purchaseInvoice.DueDate);
            }
            return(purchaseInvoice);
        }
Пример #2
0
        public PurchaseInvoice VHasPurchaseInvoiceDetails(PurchaseInvoice purchaseInvoice, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService)
        {
            IList <PurchaseInvoiceDetail> details = _purchaseInvoiceDetailService.GetObjectsByPurchaseInvoiceId(purchaseInvoice.Id);

            if (!details.Any())
            {
                purchaseInvoice.Errors.Add("Generic", "Tidak memiliki Purchase Invoice Details");
            }
            return(purchaseInvoice);
        }
Пример #3
0
        public PurchaseInvoiceDetail VIsUniquePurchaseReceivalDetail(PurchaseInvoiceDetail purchaseInvoiceDetail, IPurchaseInvoiceDetailService _purchaseInvoiceDetail, IPurchaseReceivalDetailService _purchaseReceivalDetailService)
        {
            IList <PurchaseInvoiceDetail> details = _purchaseInvoiceDetail.GetObjectsByPurchaseInvoiceId(purchaseInvoiceDetail.PurchaseInvoiceId);

            foreach (var detail in details)
            {
                if (detail.PurchaseReceivalDetailId == purchaseInvoiceDetail.PurchaseReceivalDetailId && detail.Id != purchaseInvoiceDetail.Id)
                {
                    purchaseInvoiceDetail.Errors.Add("PurchaseInvoiceDetail", "Tidak boleh memiliki lebih dari 2 Purchase Receival Detail");
                }
            }
            return(purchaseInvoiceDetail);
        }
Пример #4
0
        public PurchaseInvoice CalculateAmountPayable(PurchaseInvoice purchaseInvoice, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService)
        {
            IList <PurchaseInvoiceDetail> details = _purchaseInvoiceDetailService.GetObjectsByPurchaseInvoiceId(purchaseInvoice.Id);
            decimal AmountPayable = 0;

            foreach (var detail in details)
            {
                AmountPayable += detail.Amount;
            }
            decimal Discount      = purchaseInvoice.Discount / 100 * AmountPayable;
            decimal TaxableAmount = AmountPayable - Discount;

            purchaseInvoice.AmountPayable = TaxableAmount * (decimal)1.1;  // 10% Tax
            _repository.Update(purchaseInvoice);
            return(purchaseInvoice);
        }
Пример #5
0
        public PurchaseInvoice VAllPurchaseInvoiceDetailsAreConfirmable(PurchaseInvoice purchaseInvoice, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService, IPurchaseReceivalDetailService _purchaseReceivalDetailService)
        {
            IList <PurchaseInvoiceDetail> details = _purchaseInvoiceDetailService.GetObjectsByPurchaseInvoiceId(purchaseInvoice.Id);

            foreach (var detail in details)
            {
                detail.ConfirmationDate = purchaseInvoice.ConfirmationDate;
                _purchaseInvoiceDetailService.GetValidator().VConfirmObject(detail, _purchaseInvoiceDetailService, _purchaseReceivalDetailService);
                foreach (var error in detail.Errors)
                {
                    purchaseInvoice.Errors.Add(error.Key, error.Value);
                }
                if (!isValid(purchaseInvoice))
                {
                    return(purchaseInvoice);
                }
            }
            return(purchaseInvoice);
        }
Пример #6
0
 public PurchaseInvoice UnconfirmObject(PurchaseInvoice purchaseInvoice, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService,
                                        IPurchaseReceivalService _purchaseReceivalService, IPurchaseReceivalDetailService _purchaseReceivalDetailService,
                                        IPaymentVoucherDetailService _paymentVoucherDetailService, IPayableService _payableService)
 {
     if (_validator.ValidUnconfirmObject(purchaseInvoice, _purchaseInvoiceDetailService, _paymentVoucherDetailService, _payableService))
     {
         IList <PurchaseInvoiceDetail> details = _purchaseInvoiceDetailService.GetObjectsByPurchaseInvoiceId(purchaseInvoice.Id);
         foreach (var detail in details)
         {
             detail.Errors = new Dictionary <string, string>();
             _purchaseInvoiceDetailService.UnconfirmObject(detail, _purchaseReceivalService, _purchaseReceivalDetailService);
         }
         _repository.UnconfirmObject(purchaseInvoice);
         PurchaseReceival purchaseReceival = _purchaseReceivalService.GetObjectById(purchaseInvoice.PurchaseReceivalId);
         _purchaseReceivalService.UnsetInvoiceComplete(purchaseReceival);
         Payable payable = _payableService.GetObjectBySource(Constant.PayableSource.PurchaseInvoice, purchaseInvoice.Id);
         _payableService.SoftDeleteObject(payable);
     }
     return(purchaseInvoice);
 }
Пример #7
0
        public PurchaseInvoice VAllPurchaseInvoiceDetailsAreUnconfirmable(PurchaseInvoice purchaseInvoice, IPurchaseInvoiceDetailService _purchaseInvoiceDetailService, IPaymentVoucherDetailService _paymentVoucherDetailService, IPayableService _payableService)
        {
            IList <PurchaseInvoiceDetail> details = _purchaseInvoiceDetailService.GetObjectsByPurchaseInvoiceId(purchaseInvoice.Id);

            foreach (var detail in details)
            {
                if (!_purchaseInvoiceDetailService.GetValidator().ValidUnconfirmObject(detail))
                {
                    foreach (var error in detail.Errors)
                    {
                        purchaseInvoice.Errors.Add("Generic", error.Value);
                    }
                    if (!isValid(purchaseInvoice))
                    {
                        return(purchaseInvoice);
                    }
                }
            }
            return(purchaseInvoice);
        }