public void BaseInvoice(PurchaseOrderInvoice method) { if (this.CanInvoice) { var purchaseInvoice = new PurchaseInvoiceBuilder(this.Strategy.Session) .WithBilledFrom(this.TakenViaSupplier) .WithBilledFromContactMechanism(this.TakenViaContactMechanism) .WithBilledFromContactPerson(this.TakenViaContactPerson) .WithBilledTo(this.OrderedBy) .WithBilledToContactPerson(this.BillToContactPerson) .WithDescription(this.Description) .WithInvoiceDate(this.Session().Now()) .WithVatRegime(this.VatRegime) .WithDiscountAdjustment(this.DiscountAdjustment) .WithSurchargeAdjustment(this.SurchargeAdjustment) .WithShippingAndHandlingCharge(this.ShippingAndHandlingCharge) .WithFee(this.Fee) .WithCustomerReference(this.CustomerReference) .WithPurchaseInvoiceType(new PurchaseInvoiceTypes(this.Session()).PurchaseInvoice) .Build(); foreach (PurchaseOrderItem orderItem in this.ValidOrderItems) { if (orderItem.CanInvoice) { var invoiceItem = new PurchaseInvoiceItemBuilder(this.Strategy.Session) .WithAssignedUnitPrice(orderItem.UnitPrice) .WithPart(orderItem.Part) .WithQuantity(orderItem.QuantityOrdered) .WithAssignedVatRegime(orderItem.AssignedVatRegime) .WithDescription(orderItem.Description) .WithInternalComment(orderItem.InternalComment) .WithMessage(orderItem.Message) .Build(); var invoiceItemTypes = new InvoiceItemTypes(this.Strategy.Session); invoiceItem.InvoiceItemType = invoiceItem.ExistPart ? invoiceItemTypes.PartItem : invoiceItemTypes.WorkDone; purchaseInvoice.AddPurchaseInvoiceItem(invoiceItem); new OrderItemBillingBuilder(this.Strategy.Session) .WithQuantity(orderItem.QuantityOrdered) .WithAmount(orderItem.TotalBasePrice) .WithOrderItem(orderItem) .WithInvoiceItem(invoiceItem) .Build(); } } } }
public void BaseInvoice(PurchaseOrderInvoice method) { if (this.CanInvoice) { var purchaseInvoice = new PurchaseInvoiceBuilder(this.Strategy.Session) .WithBilledFrom(this.TakenViaSupplier) .WithAssignedBilledFromContactMechanism(this.DerivedTakenViaContactMechanism) .WithBilledFromContactPerson(this.TakenViaContactPerson) .WithBilledTo(this.OrderedBy) .WithBilledToContactPerson(this.BillToContactPerson) .WithDescription(this.Description) .WithInvoiceDate(this.Session().Now()) .WithAssignedVatRegime(this.DerivedVatRegime) .WithAssignedIrpfRegime(this.DerivedIrpfRegime) .WithCustomerReference(this.CustomerReference) .WithPurchaseInvoiceType(new PurchaseInvoiceTypes(this.Session()).PurchaseInvoice) .Build(); foreach (OrderAdjustment orderAdjustment in this.OrderAdjustments) { OrderAdjustment newAdjustment = null; if (orderAdjustment.GetType().Name.Equals(typeof(DiscountAdjustment).Name)) { newAdjustment = new DiscountAdjustmentBuilder(this.Session()).Build(); } if (orderAdjustment.GetType().Name.Equals(typeof(SurchargeAdjustment).Name)) { newAdjustment = new SurchargeAdjustmentBuilder(this.Session()).Build(); } if (orderAdjustment.GetType().Name.Equals(typeof(Fee).Name)) { newAdjustment = new FeeBuilder(this.Session()).Build(); } if (orderAdjustment.GetType().Name.Equals(typeof(ShippingAndHandlingCharge).Name)) { newAdjustment = new ShippingAndHandlingChargeBuilder(this.Session()).Build(); } if (orderAdjustment.GetType().Name.Equals(typeof(MiscellaneousCharge).Name)) { newAdjustment = new MiscellaneousChargeBuilder(this.Session()).Build(); } newAdjustment.Amount ??= orderAdjustment.Amount; newAdjustment.Percentage ??= orderAdjustment.Percentage; purchaseInvoice.AddOrderAdjustment(newAdjustment); } foreach (PurchaseOrderItem orderItem in this.ValidOrderItems) { if (orderItem.CanInvoice) { var invoiceItem = new PurchaseInvoiceItemBuilder(this.Strategy.Session) .WithAssignedUnitPrice(orderItem.UnitPrice) .WithInvoiceItemType(orderItem.InvoiceItemType) .WithPart(orderItem.Part) .WithQuantity(orderItem.QuantityOrdered) .WithAssignedVatRegime(orderItem.AssignedVatRegime) .WithAssignedIrpfRegime(orderItem.AssignedIrpfRegime) .WithDescription(orderItem.Description) .WithInternalComment(orderItem.InternalComment) .WithMessage(orderItem.Message) .Build(); purchaseInvoice.AddPurchaseInvoiceItem(invoiceItem); new OrderItemBillingBuilder(this.Strategy.Session) .WithQuantity(orderItem.QuantityOrdered) .WithAmount(orderItem.TotalBasePrice) .WithOrderItem(orderItem) .WithInvoiceItem(invoiceItem) .Build(); } } } }