public static Invoice CreateInvoiceFromBill( string number, string buyerId, string sellerId, DateTime issueDate, Bill bill, InvoiceType invoiceType = InvoiceType.Purchase, InvoiceVariant invoiceVariant = InvoiceVariant.Invoice, InvoicePaymentType invoicePaymentType = InvoicePaymentType.BankTransfer, int daysOfDelayedPayment = 0) { var invoice = Invoice.Create( number, buyerId, sellerId, issueDate, invoiceType, invoiceVariant, invoicePaymentType, daysOfDelayedPayment); var invoiceItem = InvoiceItem.Create( 1, bill.Amount, Item.Create( string.Format("Bill from {0} for Project: {0}", bill.Date, bill.Project.Name), Мeasure.Pcs), invoice); bill.AttachInvoice(invoice.Id); return(invoice); }
public static Invoice Create( string number, string buyerId, string sellerId, DateTime issueDate, InvoiceType invoiceType = InvoiceType.Purchase, InvoiceVariant invoiceVariant = InvoiceVariant.Invoice, InvoicePaymentType invoicePaymentType = InvoicePaymentType.BankTransfer, int daysOfDelayedPayment = 0, int vat = 20) { var invoice = new Invoice() { Number = number, IssueDate = issueDate, BuyerId = buyerId, SellerId = sellerId, InvoiceType = invoiceType, InvoiceVariant = invoiceVariant, InvoicePaymentType = invoicePaymentType, DaysOfDelayedPayment = daysOfDelayedPayment, Vat = vat, IsPayed = invoicePaymentType == InvoicePaymentType.BankTransfer ? false : true, InvoiceItems = new HashSet <InvoiceItem>() }; Validate(invoice); if (daysOfDelayedPayment == 0) { invoice.PaymentDate = DateTime.Now; } else { invoice.PaymentDate = DateTime.Now.AddDays(daysOfDelayedPayment); } if (invoicePaymentType != InvoicePaymentType.BankTransfer) { invoice.DateOfPayment = DateTime.Now; } return(invoice); }