Beispiel #1
0
        private void UpdateInvoiceItems(List<InvoiceItem> invoiceItems,
                                        IInvoiceItemDomainService invoiceItemDomainService,
                                        IBalanceDomainService balanceDomainService)
        {
            if (InvoiceType == InvoiceTypes.Attach)
            {
                if (InvoiceRefrence == null)
                    throw new BusinessRuleException("", "Reference not Set");

                //<A.H> Moved to the outside of if block.
                //foreach (var invoiceItem in InvoiceItems.ToList())
                //{
                //    invoiceItemDomainService.DeleteInvoiceItem(invoiceItem);
                //}

                //<A.H> Moved to the outside of if block.
                //InvoiceItems = invoiceItems;
            }

            for (int index = 0; index < InvoiceItems.Count; index++)
            {
                invoiceItemDomainService.DeleteInvoiceItem(InvoiceItems[index]);
            }
            InvoiceItems = invoiceItems;

            //<A.H> : The implementation has been moved to Submit method.
            //else
            //{
            //    if (OrderRefrences == null)
            //        throw new BusinessRuleException("", "Reference not Set");
            //    var c = new CalculateChangeInOrderBlance(invoiceItemDomainService, balanceDomainService);
            //    InvoiceItems = c.Process(this, invoiceItems, OrderRefrences);
            //}
        }
Beispiel #2
0
        //        public void DeleteAllItems(IInvoiceItemDomainService invoiceItemDomainService)
        //        {
        //            for (int index = 0; index < InvoiceItems.Count; index++)
        //            {
        //                
        //            }
        //        }
        public void CheckDeleteRules(IBalanceDomainService balanceDomainService, IInvoiceItemDomainService invoiceItemDomainService)
        {
            if (!(State == States.Open || State == States.SubmitRejected))
                throw new BusinessRuleException("BR_IN7", "Invoice Is Open");

            foreach (var invoiceItem in InvoiceItems.ToList())
            {
                balanceDomainService.DeleteInvoiceItemRefrencesFromBalance(invoiceItem.Id);
                invoiceItemDomainService.DeleteInvoiceItem(invoiceItem);
            }
        }