示例#1
0
        public void LoadSaveInvoiceTest(FileNameTestCase testCase)
        {
            Console.WriteLine($"{testCase.Version}->{testCase.InputFile}");
            var ebiList = InvoiceFactory.GetVersionsWithSaveSupported();
            var dlgMoq  = new Mock <IDialogService>();

            dlgMoq.Setup(dlg => dlg.ShowMessageBox(It.IsAny <string>(),
                                                   It.IsAny <string>(),
                                                   It.Is <MessageBoxButtons>(mb => mb == MessageBoxButtons.YesNo),
                                                   It.IsAny <MessageBoxIcon>())).Returns(DialogResult.OK);

            string iFn   = testCase.InputFile;
            string oFn   = testCase.OutputFile;
            var    invVM = Cmn.UContainer.Resolve <InvoiceViewModel>(new ResolverOverride[] {
                new ParameterOverride("invoice", Cmn.Invoice),
                new ParameterOverride("dialog", dlgMoq.Object)
            });

            invVM.LoadTemplateCommand.Execute(iFn);
            PlugInSettings.Default.EbInterfaceVersionString = testCase.Version;
            string oFnTagged = Path.GetFileNameWithoutExtension(oFn);

            invVM.SaveEbinterfaceCommand.Execute(oFn);
            if (!invVM.Results.IsValid)
            {
                foreach (var item in invVM.Results)
                {
                    Console.WriteLine(item.Message);
                }
            }
            Assert.IsTrue(File.Exists(oFn), "Outputfile missing - " + testCase.Version);
        }
示例#2
0
        public ActionResult DetailsForSpecifiedBooking(BookingDetails bookingDetails)
        {
            var roomBookings = from t in dbRoomBooking.RoomBookings select t;

            roomBookings = roomBookings.Where(r => r.BookingId == bookingDetails.booking.BookingId); //camerele ce aparti rezervarii curente

            List <Room> rooms = new List <Room>();

            foreach (var roomB in roomBookings)
            {
                Room r = dbRoom.Rooms.Find(roomB.RoomId);
                rooms.Add(r);
            }
            bookingDetails.rooms = rooms;


            InvoiceFactory invoiceFact = InvoiceFactory.getInstance();

            if (Request.Form["PDFInvoiceButton"] != null)
            {
                BookingInvoice e = invoiceFact.exportInvoice(InvoiceFactory.InvoiceTypes.PDF);
                e.export(bookingDetails);
            }
            else if (Request.Form["TxtInvoiceButton"] != null)
            {
                BookingInvoice e = invoiceFact.exportInvoice(InvoiceFactory.InvoiceTypes.TXT);
                Response.Write(e.export(bookingDetails));
                Response.ContentType = "application/txt";
                Response.AppendHeader("Content-Disposition", "attachment; filename=invoice.txt");
                Response.End();
            }
            return(RedirectToAction("BookingList"));
        }
示例#3
0
        /// <summary>
        /// Determines whether [is valid erb invoice] [the specified erb invoice].
        /// </summary>
        /// <param name="erbInvoice">The erb invoice.</param>
        /// <returns>Eine <see cref="EbInterfaceResult"/> Instanz</returns>
        public static EbInterfaceResult IsValidErbInvoice(string erbInvoice)
        {
            var inv = (InvoiceModel)InvoiceFactory.LoadXml(erbInvoice);
            EbInterfaceResult result = inv.IsValidErbInvoice();

            return(result);
        }
示例#4
0
        public void TestFakturyWielopozycyjnej()

        {
            var factory = new InvoiceFactory(objectSpace);
            var faktura = factory.UtworzFakture(new string[] { "Gacie", "Skarpetki", "Skarpety" });

            Assert.IsNotNull(faktura, "nie utworzono faktury");
            Assert.AreEqual(3, faktura.PozycjeFaktury.Count());

            Assert.AreEqual("Gacie", faktura.PozycjeFaktury[0].Produkt.Nazwa);
            Assert.AreEqual("Skarpetki", faktura.PozycjeFaktury[1].Produkt.Nazwa);
            Assert.AreEqual("Skarpety", faktura.PozycjeFaktury[2].Produkt.Nazwa);

            Assert.AreEqual(100, faktura.PozycjeFaktury[0].WartoscNetto);
            Assert.AreEqual(33.33m, faktura.PozycjeFaktury[1].WartoscNetto);
            Assert.AreEqual(27.77, faktura.PozycjeFaktury[2].WartoscNetto);

            Assert.AreEqual(100 * 1.23, faktura.PozycjeFaktury[0].WartoscBrutto);
            Assert.AreEqual(33.33m * 1.07m, faktura.PozycjeFaktury[1].WartoscBrutto);
            Assert.AreEqual(27.77m * 1.07m, faktura.PozycjeFaktury[2].WartoscBrutto);

            Assert.AreEqual(100 * 1.23m + 33.33m * 1.07m + 27.77m * 1.07m, faktura.PozycjeFaktury.Sum(s => s.WartoscBrutto), "brutto pozycji i faktury nie jest zgodne");
            Assert.AreEqual(faktura.PozycjeFaktury.Sum(s => s.WartoscNetto), faktura.WartoscNetto, "netto pozycji i faktury nie jest zgodne");
            Assert.AreEqual(faktura.PozycjeFaktury.Sum(s => s.WartoscVAT), faktura.WartoscVAT, "vat pozycji i faktury nie jest zgodne");
            Assert.AreEqual(faktura.PozycjeFaktury.Sum(s => s.WartoscBrutto), faktura.WartoscBrutto, "brutto pozycji i faktury nie jest zgodne");

            faktura.Delete();
            objectSpace.CommitChanges();
        }
示例#5
0
        private static void Main(string[] args)
        {
            //BUILDER PATTERN:
            //If you have a class with many options and a big constructor. Use builder pattern
            var burger = BurgerBuilder.Init(100)
                         .WithCheese()
                         .WithBacon()
                         .Build();

            //ADAPTER PATTERN:
            //An adapter pattern is used to combine 2 different classes
            //Scenerio: EmployeeManager can only return results in CSV, But we need in pipe seperated format
            IEmployeeManager adaptedInstance = new EmployeeAdapter();
            var pipeSeperated = adaptedInstance.GetEmployess();

            //FACADE PATTERN:
            //Facade pattern can be used for simplified entrys to sub systems (Many internal functions)
            var shoppingfacade = new ShoppingFacade();

            shoppingfacade.BuyItem();

            //DECORATOR PATTERN:
            //Usefull to extend new functions to a class without inheriting (or if sealed)
            var car             = new BMW();
            var discountedPrice = new DiscountCalculator(car).GetDiscountedPrice();

            //FACTORY PATTERN:
            //Factory pattern helps build objects so client no need to know all concreate classes
            IInvoice invoice1 = InvoiceFactory.GetInvoice(1);
            IInvoice invoice2 = InvoiceFactory.GetInvoice(2);
        }
示例#6
0
 public void LoadTemplate4P1WithIndustryVorlageTagOk()
 {
     string fn = @"Daten\testTemplateInvoiceIndustrySample.xml";
     var invoice = InvoiceFactory.LoadTemplate(fn);
     Assert.IsNotNull(invoice);
     Assert.AreEqual(InvoiceSubtypes.ValidationRuleSet.Industries, invoice.InvoiceSubtype.VariantOption);
 }
示例#7
0
        public void TaxItemTest(string inputFile, string outputFile, Models.EbIVersion ebIVersion)
        {
            var invoice = InvoiceFactory.LoadTemplate(inputFile);

            invoice.PrintDump();
            EbInterfaceResult result = invoice.Save(outputFile, ebIVersion);

            Assert.That(result.ResultType == ResultType.IsValid);
            var inputXml = XDocument.Load(inputFile);
            var savedXml = XDocument.Load(outputFile);
            var inResult = inputXml.Descendants()
                           .Where(p1 => p1.Descendants().Count() == 0)
                           .Select(p => new NodeList
            {
                NodePath = p.GetPath(),
                Value    = p.Value
            }).Distinct().OrderBy(n => n.NodePath).ToList();
            var outResult = savedXml.Descendants().Where(p1 => p1.Descendants().Count() == 0).Select(p => new NodeList
            {
                NodePath = p.GetPath(),
                Value    = p.Value
            }).Distinct().OrderBy(n => n.NodePath).ToList();

            Console.WriteLine("Nodes not in Output -----------------------");
            var notInOut = inResult.Where(p => !outResult.Any(p2 => p2.NodePath == p.NodePath)).ToList();

            PrintDiff(notInOut);
            Console.WriteLine("Nodes not in Input -----------------------");

            var notInIn = outResult.Where(p => !inResult.Any(p2 => p2.NodePath == p.NodePath)).ToList();

            PrintDiff(notInIn);
            Console.WriteLine("Value different -----------------------");
            var valDif = inResult.Where(p => outResult.Any(p2 => p2.NodePath == p.NodePath && p2.Value != p.Value));
        }
示例#8
0
        public void GetVersionsWithSaveSupportedTest()
        {
            var supportedLIst = InvoiceFactory.GetVersionsWithSaveSupported();

            Assert.IsNotNull(supportedLIst);
            Assert.IsFalse(supportedLIst.Contains("V4P0"));
        }
示例#9
0
 private void SetFactory(int runNumber, DateTime fromDate, DateTime toDate)
 {
     _factory = new InvoiceFactory(_invoiceSettings, _dateTime.Object, _contractRepository.Object,
                                   _accountRepository.Object, _planRepository.Object,
                                   _networkRepository.Object, _contractService.Object, _companyRepository.Object,
                                   _contactRepository.Object,
                                   _generator.Object, new InvoiceRunContext(runNumber, fromDate, toDate));
 }
示例#10
0
 public void SaveTemplateAsIndustryOk()
 {
     string fn = @"Daten\Test-ebInterfaceRechn-2014-500-2014-03-19.xml";
     var invoice = InvoiceFactory.LoadTemplate(fn);
     invoice.InvoiceSubtype = InvoiceSubtypes.GetSubtype(InvoiceSubtypes.ValidationRuleSet.Industries);
     invoice.SaveTemplate(@"Daten\testTemplateInvoiceIndustry.xml");
     Assert.IsNotNull(invoice);
 }
示例#11
0
 public void LoadTemplateTestOk(string rechnungFn)
 {
     string fn = rechnungFn;// @"Daten\Test-ebInterfaceRechn-2014-500-2014-03-19.xml";
     var invoice = InvoiceFactory.LoadTemplate(fn);
     Assert.IsNotNull(invoice);
     Console.WriteLine($"{invoice.Version.ToString()}:\t{rechnungFn}");
     invoice.PrintDump();
 }
示例#12
0
        public void LoadTemplateTestNoGeneratingSystem()
        {
            string fn = @"Daten\DotNetApiCreatedInvoice.xml";
            var invoice = InvoiceFactory.LoadTemplate(fn);

            // invoice.Save(@"Daten\testInvoice.xml");
            Assert.AreEqual(invoice.InvoiceSubtype.VariantOption, InvoiceSubtypes.ValidationRuleSet.Invalid);
        }
示例#13
0
        public void CreateProductDiscountLineItems_WithInvalidDiscounts_CreatesZeroLineItems(Product product)
        {
            PopulateOrder(product, 5);

            var lineItems = InvoiceFactory.CreateProductDiscountLineItems(product, _order.ScannedItems);

            lineItems.Count().Should().Be(0);
        }
示例#14
0
        public void GetItemLoadRabattTestOk()
        {
            _common.Invoice = InvoiceFactory.LoadTemplate(Common.InvTest);

            var det     = DetailsListConverter.Load(_common.Invoice.Details.ItemList, _common.UContainer, false);
            var detList = DetailsListConverter.ConvertToItemList(det, "Z01");
            var det2    = DetailsListConverter.Load(detList, _common.UContainer, false);

            Assert.AreEqual(det[0].Rabatt, det2[0].Rabatt);
        }
示例#15
0
        public void CreateRetailLineItems_CreatesOneRetailLineItemPerScannedItem()
        {
            AddFullSetOfScannedItemsToOrder();
            var lineItems = InvoiceFactory.CreateRetailLineItems(_order.ScannedItems);

            var lineItemScannedItemIds = lineItems.Select(x => ((RetailLineItem)x).ScannedItemId).ToList();

            lineItemScannedItemIds.Should().OnlyHaveUniqueItems();
            lineItemScannedItemIds.Should().BeEquivalentTo(_order.ScannedItems.Select(x => x.Id));
        }
示例#16
0
        public void LoadTest()
        {
            _common.Invoice = InvoiceFactory.LoadTemplate(Common.InvTest);
            var det = DetailsListConverter.Load(_common.Invoice.Details.ItemList, _common.UContainer, false);

            Assert.IsNotNull(det);
            Assert.AreEqual((int)4, det.Count);
            Assert.AreEqual("DAY", det[0].Einheit);
            Assert.AreEqual("LS", det[2].Einheit);
        }
示例#17
0
 public void SaveTemplateOk(string fnSource)
 {
     string outDir = Path.GetDirectoryName(fnSource);
     string saveFn = Path.Combine(outDir, Path.GetFileNameWithoutExtension(fnSource) + "-template.xml");
     File.Delete(saveFn);
     var invoice = InvoiceFactory.LoadTemplate(fnSource);
     invoice.PrintDump();
     Assert.IsNotNull(invoice);
     //Console.WriteLine(invoice.Dump());
     invoice.SaveTemplate(saveFn);
 }
示例#18
0
 public Invoice InvoiceGenerator(GoodsMovement _goodsMovement, bool _toPay, double _discount, Customer _subject, string _employeeCode, bool _isPerc)
 {
     if (_isPerc)
     {
         return(InvoiceFactory.CreateInvoice(UpdateProgressiveNumber(), _toPay, Services.CalculateDiscountPerc(_discount, Services.CalculateAmount(_goodsMovement)), _discount, _subject, new Employee(_employeeCode), _goodsMovement));
     }
     else
     {
         return(InvoiceFactory.CreateInvoice(UpdateProgressiveNumber(), _toPay, Services.CalculateAmountWithDiscount(Services.CalculateAmount(_goodsMovement), _discount), _discount, _subject, new Employee(_employeeCode), _goodsMovement));
     }
 }
示例#19
0
        public void TotalsAndTaxTest(string inputFn)
        {
            XDocument xInv  = XDocument.Load(inputFn);
            var       attrs = xInv.Root.Attributes().
                              Where(p => p.IsNamespaceDeclaration == true).
                              FirstOrDefault(x => x.Name.LocalName == "eb");

            var invoice = InvoiceFactory.LoadTemplate(inputFn);

            Console.WriteLine($"{attrs.Value}: {inputFn}");
            var totals = from a in invoice.Details.ItemList[0].ListLineItem
                         group a by 1 into g
                         select new
            {
                netto     = g.Sum(x => x.LineItemAmount),
                ustGesamt = g.Sum(x => x.TaxItem.TaxPercent.Value * x.LineItemAmount / 100).FixedFraction(2)
            };

            totals.PrintDump();
            var tax = invoice.Details.ItemList[0].ListLineItem
                      .GroupBy(s => new
            {
                Prozent = s.TaxItem.TaxPercent.Value,
                Code    = s.TaxItem.TaxPercent.TaxCategoryCode
            })
                      .Select(p => new TaxItemType
            {
                TaxPercent = new TaxPercentType()
                {
                    TaxCategoryCode = p.Key.Code,
                    Value           = p.Key.Prozent
                },
                TaxableAmount = p.Sum(x => x.LineItemAmount),
                TaxAmount     = (p.Sum(x => x.LineItemAmount) * p.Key.Prozent / 100),
            });

            tax.PrintDump();
            var totale = totals.FirstOrDefault();

            Assert.AreEqual(totale.ustGesamt, invoice.TaxAmountTotal, "USt Gesamt");
            Assert.AreEqual(totale.ustGesamt + totale.netto, invoice.TotalGrossAmount, "Gesamt Betrag");
            Assert.AreEqual(tax.Count(), invoice.Tax.TaxItem.Count, "TaxItem Count");
            Assert.Multiple(() =>
            {
                var taxLIst = tax.ToList();
                for (int i = 0; i < taxLIst.Count; i++)
                {
                    Assert.AreEqual(taxLIst[i].TaxableAmount, invoice.Tax.TaxItem[i].TaxableAmount, "TaxableAmount");
                    Assert.AreEqual(taxLIst[i].TaxAmount, invoice.Tax.TaxItem[i].TaxAmount, "Amount");
                    Assert.AreEqual(taxLIst[i].TaxPercent.TaxCategoryCode, invoice.Tax.TaxItem[i].TaxPercent.TaxCategoryCode, "Percent");
                    Assert.AreEqual(taxLIst[i].TaxPercent.Value, invoice.Tax.TaxItem[i].TaxPercent.Value, "Value");
                }
            });
        }
示例#20
0
        public FrmSelectVersion()
        {
            InitializeComponent();
            this.FileDlgType          = Win32Types.FileDialogType.SaveFileDlg;
            this.FileDlgStartLocation = AddonWindowLocation.Bottom;
            List <string> ebiLIst = InvoiceFactory.GetVersionsWithSaveSupported().OrderByDescending(p => p).ToList();

            comboBox1.DataSource = ebiLIst;
            // comboBox1.SelectedItem = SelectedVersion.ToString();
            //comboBox1.SelectedText = SelectedVersion.ToString();
            //  this.comboBox2.DataBindings.Add(new System.Windows.Forms.Binding("SelectedItem", this.bindingSourceReStellerSetting, "SelectedVersion", true));
        }
示例#21
0
 public OrderService(OrderFactory orderFactory, InvoiceFactory invoiceFactory, PaymentFactory paymentFactory, IOrderRepository orderRepo,
                     IPaymentRepository paymentRepo, IProductRepository productRepo, IInvoiceRepository invoiceRepo, IStripeApiService stripeService)
 {
     this._orderFactory   = orderFactory;
     this._invoiceFactory = invoiceFactory;
     this._paymentFactory = paymentFactory;
     this._orderRepo      = orderRepo;
     this._paymentRepo    = paymentRepo;
     this._productRepo    = productRepo;
     this._invoiceRepo    = invoiceRepo;
     this._stripeService  = stripeService;
 }
示例#22
0
        protected void UploadInvoice(string strFlag, int selIndex)
        {
            try
            {
                Seller seller = new Seller();
                seller.SellerDaTa = new List <Seller>();

                //TEMPORARY SOLUTION
                Invoice b2bInvoice = InvoiceFactory.CreateInvoice(InvoiceType.B2BInvoice);
                seller.Invoice = b2bInvoice;

                seller.SellerDaTa = (List <Seller>)Session["SellerDaTa"];
                int result = seller.Invoice.UploadInvoice(seller.SellerDaTa, strInvoiceNo);

                if (result > 0)
                {
                    if (Session["SellerDaTa"] != null)
                    {
                        Session["SellerDaTa"] = null;
                    }

                    BindGrid();

                    if (strFlag == "all")
                    {
                        BtnUpload.Attributes.Add("style", "display:none");
                    }
                    else if (strFlag == "single")
                    {
                        // GVUploadInvoice.Rows[selIndex].FindControl("lnkUpload").Visible = false;
                    }
                    BALAJI.GSP.APPLICATION.User.User masterPage = this.Master as BALAJI.GSP.APPLICATION.User.User;
                    //  masterPage.ShowModalPopupSuccess();
                    ////masterPage.ErrorMessage = "Data Uploaded Successfully !!!";
                }
                else
                {
                    if (Session["SellerDaTa"] != null)
                    {
                        Session["SellerDaTa"] = null;
                    }
                    BALAJI.GSP.APPLICATION.User.User masterPage = this.Master as BALAJI.GSP.APPLICATION.User.User;
                    ////masterPage.ShowModalPopup();
                    ////masterPage.ErrorMessage = "Error !!! Unable to Upload Data!";
                }
            }
            catch (Exception ex)
            {
                cls_ErrorLog ob = new cls_ErrorLog();
                cls_ErrorLog.LogError(ex, Common.LoggedInUserID());
            }
        }
示例#23
0
        public void MapV4P1ToVmTest()
        {
            string fn      = @"Daten\Test-ebInterfaceRechn-2014-500-2014-03-19.xml";
            var    invoice = InvoiceFactory.LoadTemplate(fn);

            // var invVm = DocumentViewModel.MapV4P1ToVm(invoice as ebIModels.Schema.ebInterface4p1.InvoiceType);
            // var inv4p1 = MappingService.MapVMToV4p1(invVm);
            //Assert.AreEqual(new DateTime(2014, 04, 19), invoice.PaymentConditions.DueDate);
            Assert.AreEqual(CountryCodeType.AT.ToString(), invoice.Biller.Address.Country.CountryCode);
            Assert.AreEqual("Österreich", invoice.Biller.Address.Country.Value);
            invoice.SaveTemplate(@"Daten\ConvertedInvoice.xml");
            Assert.IsNotNull(invoice);
        }
示例#24
0
        protected override void PersistUpdatedItem(IInvoice entity)
        {
            ((Entity)entity).UpdatingEntity();

            var factory = new InvoiceFactory(entity.Items, entity.Orders);
            var dto     = factory.BuildDto(entity);

            Database.Update(dto);

            _invoiceLineItemRepository.SaveLineItem(entity.Items, entity.Key);

            entity.ResetDirtyProperties();
        }
示例#25
0
        public void CreateProductDiscountLineItems_CreatesSpecialLineItems(decimal retailPrice, Special special, int scannedItemCount, int expectedLineItemCount, decimal expectedValue)
        {
            var product = new Product("product with special", Money.USDollar(retailPrice), SellByType.Unit)
            {
                Special = special
            };

            PopulateOrder(product, scannedItemCount);
            var discountLineItems = InvoiceFactory.CreateProductDiscountLineItems(product, _order.ScannedItems);
            var specialLineItems  = discountLineItems.Where(x => x.GetType() == typeof(SpecialLineItem)).ToList();

            specialLineItems.Count().Should().Be(expectedLineItemCount);
            specialLineItems.Sum(x => x.SalePrice.Amount).Should().Be(expectedValue);
        }
示例#26
0
        public void SaveInvoiceTest(string inputFile, string outputFile, Models.EbIVersion ebIVersion, string expectedAttr)
        {
            var invoice = InvoiceFactory.LoadTemplate(inputFile);
            //invoice.PrintDump();
            EbInterfaceResult result = invoice.Save(outputFile, ebIVersion);

            result.PrintDump();
            Assert.That(result.ResultType == ResultType.IsValid, $"Validation Error: {outputFile} ");
            XDocument xInv  = XDocument.Load(outputFile);
            var       attrs = xInv.Root.Attributes().Where(p => p.IsNamespaceDeclaration == true).FirstOrDefault(x => x.Name.LocalName == "eb");

            Assert.IsNotNull(attrs);
            Assert.AreEqual(expectedAttr, attrs.Value);
        }
示例#27
0
        public void CreateProductDiscountLineItems_CreatesMarkdownLineItems(Markdown markdown, Special special, int scannedItemCount, int expectedLineItemCount, decimal expectedValue)
        {
            var product = new Product("test product", Money.USDollar(1m), SellByType.Unit)
            {
                Markdown = markdown,
                Special  = special
            };

            PopulateOrder(product, scannedItemCount);
            var discountLineItems = InvoiceFactory.CreateProductDiscountLineItems(product, _order.ScannedItems);
            var markdownLineItems = discountLineItems.Where(x => x.GetType() == typeof(MarkdownLineItem)).ToList();

            markdownLineItems.Count().Should().Be(expectedLineItemCount);
            markdownLineItems.Sum(x => x.SalePrice.Amount).Should().Be(expectedValue);
        }
示例#28
0
        /// <summary>
        /// Gets an <see cref="IInvoice"/>.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="IInvoice"/>.
        /// </returns>
        protected override IInvoice PerformGet(Guid key)
        {
            var sql = GetBaseQuery(false)
              .Where(GetBaseWhereClause(), new { Key = key });

            var dto = Database.Fetch<InvoiceDto, InvoiceIndexDto, InvoiceStatusDto>(sql).FirstOrDefault();

            if (dto == null)
                return null;

            var lineItems = GetLineItemCollection(key);
            var orders = GetOrderCollection(key);
            var factory = new InvoiceFactory(lineItems, orders);
            return factory.BuildEntity(dto);
        }
示例#29
0
        //打印住院发票
        public static void Print(int CostMasterID)
        {
            grproLib.GridppReport Report = new grproLib.GridppReport();
            string ReportPath;
            string PrinterName;
            Object invoice;

            //广东发票打印
            //ReportPath = Constant.ApplicationDirectory + "\\report\\住院发票.grf";
            //PrinterName = HIS_PublicManager.PublicPrintSet.GetPrinterNameByReport("住院发票.grf");
            //invoice =InvoiceFactory.CreateInvoice(CostMasterID,"广东");
            //湖南发票打印
            ReportPath  = Constant.ApplicationDirectory + "\\report\\住院发票_HN.grf";
            PrinterName = HIS_PublicManager.PublicPrintSet.GetPrinterNameByReport("住院发票_HN.grf");
            invoice     = InvoiceFactory.CreateInvoice(CostMasterID, "湖南");


            Report.LoadFromFile(ReportPath);
            Report.Printer.PrinterName = PrinterName;
            GWI_DesReport.HisReport.FillRecordToReport(Report, invoice);
            Report.ParameterByName("WorkName").AsString = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.WorkName;

            #region 发票项目
            DataTable dt = ((AbstractInvoice)invoice).发票项目费用;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 1; j <= Report.Parameters.Count; j++)
                {
                    if (dt.Rows[i]["itemname"].ToString().Trim() == Report.Parameters[j].Name)
                    {
                        Report.Parameters[j].Value = dt.Rows[i]["Tolal_Fee"].ToString();
                    }
                }
            }
            #endregion

            if (Report.Printer.PrinterName == null || Report.Printer.PrinterName == "")
            {
                MessageBox.Show("请先设置好此报表的打印机!", "询问", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                return;
            }
#if DEBUG
            Report.PrintPreview(false);
#else
            //Report.PrintPreview(false);
            Report.Print(false);
#endif
        }
示例#30
0
        public void CreateProductMarkdownLineItems_CreatesOneMarkdownLineItemPerScannedItem(int scannedItemCount)
        {
            var product = new Product("product with markdown", Money.USDollar(1m), SellByType.Unit)
            {
                Markdown = MarkdownProvider.GetMarkdown(DateRange.Active)
            };

            PopulateOrder(product, scannedItemCount);

            var lineItems = InvoiceFactory.CreateProductMarkdownLineItems(_order.ScannedItems).ToList();

            var lineItemScannedItemIds = lineItems.Select(x => ((MarkdownLineItem)x).ScannedItemId).ToList();

            lineItemScannedItemIds.Should().OnlyHaveUniqueItems();
            lineItemScannedItemIds.Should().BeEquivalentTo(_order.ScannedItems.Select(x => x.Id));
        }
示例#31
0
        protected override void PersistNewItem(IInvoice entity)
        {
            ((Entity)entity).AddingEntity();

            var factory = new InvoiceFactory(entity.Items, new OrderCollection());
            var dto     = factory.BuildDto(entity);

            Database.Insert(dto);
            entity.Key = dto.Key;

            Database.Insert(dto.InvoiceIndexDto);
            ((Invoice)entity).ExamineId = dto.InvoiceIndexDto.Id;

            _invoiceLineItemRepository.SaveLineItem(entity.Items, entity.Key);

            entity.ResetDirtyProperties();
        }
示例#32
0
        public int InvoiceRun(DateTime callCutoffDate)
        {
            if (runInProgress)
            {
                throw new InvoiceRunInProgressException();
            }
            runInProgress = true;

            try
            {
                // SRD-PCMS-40 (001-62) Only invoice once per month
                DateTime? lastInvoiceDate = _invoiceSettings.LastInvoiceRunPerformedDate;
                if (lastInvoiceDate != null && lastInvoiceDate.Value.Month == callCutoffDate.Month && lastInvoiceDate.Value.Year == callCutoffDate.Year)
                {
                    LoggingUtility.LogDebug("InvoiceRun", "AirtimeBilling.Services.InvoicingService",
                                            string.Format(
                                                "Attempted Invoice Run more than once in the same month. Last Run Date={0}.  Current Date={1}",
                                                lastInvoiceDate.Value, _dateTime.Now));

                    throw new InvoiceRunFrequencyException();
                }

                int runNumber = 0;
                using (var ts = new TransactionScope())
                {
                    var rootAccounts = _accountRepository.GetAllRootAccounts();
                    if (rootAccounts.Count == 0)
                    {
                        LoggingUtility.LogDebug("InvoiceRun", "InvoicingService",
                                                "An Invoice Run was Started but no accounts were found.");
                        return 0;
                    }

                    runNumber = _numberGeneratorService.NextInvoiceRunNumber();

                    DateTime fromDate = DateTime.MinValue;
                    if (lastInvoiceDate.HasValue)
                    {
                        fromDate = lastInvoiceDate.Value.AddDays(1);
                    }

                    var context = new InvoiceRunContext(runNumber, fromDate, callCutoffDate);
                    var factory = new InvoiceFactory(_invoiceSettings, _dateTime, _contractRepository,
                                                                _accountRepository,
                                                                _planRepository, _networkRepository, _contractService, _companyRepository,
                                                                _contactRepository,
                                                                _numberGeneratorService, context);

                    foreach (var rootAccount in rootAccounts)
                    {
                        var invoice = factory.GenerateInvoice(rootAccount);
                        if (invoice == null) continue;

                        _invoiceRepository.InsertInvoice(invoice);
                        if (invoice.Id == null)
                        {
                            // TODO Return failure reason and log.
                            return 0;
                        }

                        rootAccount.LogActivity("Invoice Number '" + invoice.InvoiceNumber + "' created in Invoice Run " + runNumber);

                        rootAccount.AmountPaid = 0;
                        rootAccount.PreviousBill = invoice.CurrentBill;

                        if (!_accountRepository.UpdateAccount(rootAccount)) {
                            return 0;
                        }
                    }

                    _invoiceSettings.LastInvoiceRunPerformedDate = callCutoffDate;

                    ts.Complete();
                }

                // Report generation times out the transaction.
                // Report generation doesn't participate in the ambient transaction so
                // there's no real reason to do it in the transaction.
                var invoices = _invoiceRepository.FindInvoicesByRunNumber(runNumber);
                foreach (var invoice in invoices)
                    _invoiceHardcopyRepository.Save(invoice);

                // SRD-PCMS-54 (001-76) Invoice data file emailed
                // Now make a manual process to cope with credit cards.
                //SendCustomerInvoiceInEmail(runNumber);

                return runNumber;
            }
            catch (Exception ex)
            {
                LoggingUtility.LogException(ex);
                throw;
                //return 0;
            }
            finally
            {
                runInProgress = false;
            }
        }