private async Task GenerateInvoices(IList <Guid> packageIds, Payrun payrun, InvoiceTypes invoiceType) { var lastInvoiceNumber = await _invoiceGateway.GetInvoicesCountAsync(); var iterations = Math.Ceiling((double)packageIds.Count / PackageBatchSize); for (var i = 0; i < iterations; i++) { var batchIds = packageIds.Skip(i * PackageBatchSize).Take(PackageBatchSize).ToList(); var packages = await _carePackageGateway.GetListAsync(batchIds); var invoices = await _invoiceGenerator.GenerateAsync(packages, payrun.EndDate, invoiceType, lastInvoiceNumber); _logger.LogDebug("Generated invoices: {Invoices}", JsonConvert.SerializeObject(invoices, Formatting.Indented)); foreach (var invoice in invoices) { if (!invoice.Items.Any()) { continue; } var payrunInvoice = new PayrunInvoice { Payrun = payrun, Invoice = invoice, InvoiceStatus = InvoiceStatus.Accepted }; payrun.PayrunInvoices.Add(payrunInvoice); } lastInvoiceNumber += invoices.Count; } }
public InvoiceCommand(InvoiceTypes invoiceType, string invoiceNumber, Company owner, DateTime invoiceDate, DivisionMethods divisionMethod, AccountingTypes accountType, Invoice invoiceRefrence, List<long> orderRefrences, Currency currency, Company transporter, Company supplier, string description, List<InvoiceItemCommand> list) { // TODO: Complete member initialization InvoiceType = invoiceType; InvoiceNumber = invoiceNumber; Owner = owner; InvoiceDate = invoiceDate; DivisionMethod = divisionMethod; AccountingType = accountType; InvoiceRefrence = invoiceRefrence; OrdersRefrenceId = orderRefrences; Currency = currency; Transporter = transporter; Supplier = supplier; Description = description; InvoiceItems = list; }
public Invoice(InvoiceTypes invoiceType, string invoiceNumber, Company owner, DateTime invoiceDate, DivisionMethods divisionMethod, AccountingTypes accountType, Invoice invoiceRefrence, List<Order> orderRefrences, Currency currency, bool isCreditor, Company transporter, Company supplier, string description, List<InvoiceItem> list, List<InvoiceAdditionalPrice> invoiceAdditionalPriceList, IEntityConfigurator<Invoice> invoiceConfigurator, IInvoiceDomainService invoiceDomainService, IInvoiceItemDomainService invoiceItemDomainService, IGoodUnitConvertorDomainService goodUnitConvertorDomainService, IInvoiceAdditionalPriceDomainService invoiceAdditionalPriceDomainService, IBalanceDomainService balanceDomainService) : this() { // TODO: Complete member initialization InvoiceType = invoiceType; InvoiceNumber = invoiceNumber; Owner = owner; InvoiceDate = invoiceDate; DivisionMethod = divisionMethod; AccountingType = accountType; InvoiceRefrence = invoiceRefrence; OrderRefrences = orderRefrences; Currency = currency; IsCreditor = isCreditor; Transporter = transporter; Supplier = supplier; TransporterId = Transporter == null ? (long?)null : Transporter.Id; SupplierId = Supplier == null ? (long?)null : Supplier.Id; InvoiceRefrenceId = InvoiceRefrence == null ? (long?)null : InvoiceRefrence.Id; Description = description; UpdateInvoiceItems(list, null, balanceDomainService); UpdateInvoiceAdditionalPrice(invoiceAdditionalPriceList, null); this.invoiceConfigurator = invoiceConfigurator; this.invoiceAdditionalPriceDomainService = invoiceAdditionalPriceDomainService; invoiceConfigurator.Configure(this); invoiceBaseType.ValidateType(this); checkInvoiceNumberToBeUnique(invoiceDomainService); CheckInvoiceHaveInvoiceItem(); invoiceBaseType.CheckInvoiceItemValidateQuantityAndRefrence(this, invoiceItemDomainService, goodUnitConvertorDomainService); invoiceAdditionalPriceDomainService.CalculateAdditionalPrice(this); }
private void SaveInvoiceType() { if (SelectedInvoiceType.InvoiceTypeId != 0) { InvoiceTypes.Update(SelectedInvoiceType); } else { InvoiceTypes.Insert(SelectedInvoiceType); } }
public BookingInvoice exportInvoice(InvoiceTypes invoiceType) { BookingInvoice invoice = null; if (invoiceType.Equals(InvoiceTypes.PDF)) { invoice = new PDFInvoice(); } else if (invoiceType.Equals(InvoiceTypes.TXT)) { invoice = new TXTInvoice(); } return(invoice); }
/// <summary> /// 获取商家发票类型列表 /// </summary> /// <param name="shopid"></param> /// <returns></returns> public static List <InvoiceTypes> GetInvoiceTypes(long shopid) { List <long> shops = new List <long>(); shops.Add(shopid); var isInvoice = Service.HasProvideInvoice(shops); if (!isInvoice) { return(null); } else { var config = GetShopInvoiceConfig(shopid); List <InvoiceTypes> types = new List <InvoiceTypes>(); if (config.IsPlainInvoice) { var type = new InvoiceTypes() { Id = InvoiceType.OrdinaryInvoices.GetHashCode(), Name = InvoiceType.OrdinaryInvoices.ToDescription(), Rate = config.PlainInvoiceRate }; types.Add(type); } if (config.IsElectronicInvoice) { var type = new InvoiceTypes() { Id = InvoiceType.ElectronicInvoice.GetHashCode(), Name = InvoiceType.ElectronicInvoice.ToDescription(), Rate = config.PlainInvoiceRate }; types.Add(type); } if (config.IsVatInvoice) { var type = new InvoiceTypes() { Id = InvoiceType.VATInvoice.GetHashCode(), Name = InvoiceType.VATInvoice.ToDescription(), Rate = config.VatInvoiceRate }; types.Add(type); } return(types); } }
/// <summary> /// Return the next validation to execute. /// </summary> /// <param name="requestedProperty">The requested property.</param> /// <param name="value">The value.</param> /// <returns></returns> /// <exception cref="ninja.model.Exceptions.BusinessException">The type of invoice must be a value of these {string.Join(",", validInvoiceTypes)}</exception> public override object Validate(string requestedProperty, object value) { if (requestedProperty.Equals("Type")) { string[] validInvoiceTypes = InvoiceTypes.GetValidInvoiceTypes(); if (!validInvoiceTypes.Any(x => x.Equals(Convert.ToString(value)))) { throw new BusinessException($"The type of invoice must be a value of these {string.Join(",", validInvoiceTypes)}"); } return(base._nextHandler); } else { return(base.Validate(requestedProperty, value)); } }
private void DeleteInvoiceType() { if (SelectedInvoiceType == null) { return; } if (SelectedInvoiceType.InvoiceTypeId == 0) { _InvoiceTypes.Remove(SelectedInvoiceType); SelectedInvoiceType = null; return; } InvoiceTypes.Delete(SelectedInvoiceType.InvoiceTypeId); _InvoiceTypes.Remove(SelectedInvoiceType); SelectedInvoiceType = null; }
/// <summary> /// Gets the invoice types. /// </summary> /// <param name="current">The current.</param> /// <returns></returns> private IEnumerable <SelectListItem> GetInvoiceTypes(string current) { string[] invoiceTypes = InvoiceTypes.GetValidInvoiceTypes(); SelectListGroup group = new SelectListGroup() { Disabled = false, Name = "Invoice types" }; var items = invoiceTypes.Select(x => new SelectListItem() { Disabled = false, Group = group, Selected = x == current, Text = x, Value = x }); return(items); }
private Invoice GenerateInvoice( CarePackage package, IList <InvoiceDomain> packageInvoices, DateTimeOffset invoiceEndDate, InvoiceTypes invoiceTypes, ref long lastInvoiceNumber) { var invoiceItems = new List <InvoiceItem>(); var generators = _generators[package.PackageType]; foreach (var generator in generators) { if (invoiceTypes.HasFlag(InvoiceTypes.Refund)) { RejectOutdatedInvoices(package, packageInvoices); invoiceItems.AddRange(generator.CreateRefundItems(package, packageInvoices)); } if (invoiceTypes.HasFlag(InvoiceTypes.Normal)) { invoiceItems.AddRange(generator.CreateNormalItems(package, packageInvoices, invoiceEndDate)); } } foreach (var item in invoiceItems) { item.Name += $"\n{item.FromDate:ddMMyy}{item.ToDate:ddMMyy} {package.ServiceUser.HackneyId}"; } var totals = CalculateTotals(invoiceItems); return(new Invoice { SupplierId = package.SupplierId.GetValueOrDefault(), ServiceUserId = package.ServiceUserId, PackageId = package.Id, Items = invoiceItems, GrossTotal = totals.Gross, NetTotal = totals.Net, TotalCost = totals.Net, // TODO: VK: Review, remove? Number = $"INV-{DateTimeOffset.UtcNow:yyMMdd}-{++lastInvoiceNumber:0000}" }); }
private void GetData() { InvoiceTypeList = InvoiceTypes.GetAll().ToSvenTechCollection(); PaymentConditionList = PaymentConditions.GetAll().ToSvenTechCollection(); UserList = Users.GetAll().ToSvenTechCollection(); }
public async Task <IList <Invoice> > GenerateAsync(IList <CarePackage> packages, DateTimeOffset invoiceEndDate, InvoiceTypes invoiceTypes, long lastInvoiceNumber) { InitializeGeneratorsAsync(); var invoices = new List <Invoice>(); var packageIds = packages .Select(package => package.Id) .ToList(); var oldInvoices = await _invoiceGateway.GetInvoicesByPackageIds(packageIds); foreach (var package in packages) { var packageInvoices = oldInvoices.GetValueOrDefault(package.Id) ?? new List <InvoiceDomain>(); invoices.Add(GenerateInvoice( package, packageInvoices, invoiceEndDate, invoiceTypes, ref lastInvoiceNumber)); } await _invoiceGateway.AcceptReleasedInvoices(packageIds); return(invoices); }
private SvenTechCollection <InvoiceType> LoadAllInvoiceTypes() { SvenTechCollection <InvoiceType> allInvoiceTypes = new SvenTechCollection <InvoiceType>(); return(InvoiceTypes.GetAll().ToSvenTechCollection()); }