Ejemplo n.º 1
0
        public void AppsSend(SalesInvoiceSend method)
        {
            if (object.Equals(this.SalesInvoiceType, new SalesInvoiceTypes(this.Strategy.Session).SalesInvoice))
            {
                this.InvoiceNumber = this.Store.DeriveNextInvoiceNumber(this.InvoiceDate.Year);
            }

            if (object.Equals(this.SalesInvoiceType, new SalesInvoiceTypes(this.Strategy.Session).CreditNote))
            {
                this.InvoiceNumber = this.Store.DeriveNextCreditNoteNumber(this.InvoiceDate.Year);
            }

            this.SalesInvoiceState = new SalesInvoiceStates(this.Strategy.Session).Sent;

            if (this.BillToCustomer is Organisation organisation && organisation.IsInternalOrganisation)
            {
                var purchaseInvoice = new PurchaseInvoiceBuilder(this.Strategy.Session)
                                      .WithBilledFrom(this.BilledFrom)
                                      .WithBilledFromContactPerson(this.BilledFromContactPerson)
                                      .WithBilledTo((InternalOrganisation)this.BillToCustomer)
                                      .WithBilledToContactPerson(this.BillToContactPerson)
                                      .WithBillToEndCustomer(this.BillToEndCustomer)
                                      .WithBillToEndCustomerContactMechanism(this.BillToEndCustomerContactMechanism)
                                      .WithBillToEndCustomerContactPerson(this.BillToEndCustomerContactPerson)
                                      .WithBillToCustomerPaymentMethod(this.PaymentMethod)
                                      .WithShipToCustomer(this.ShipToCustomer)
                                      .WithShipToCustomerAddress(this.ShipToAddress)
                                      .WithShipToCustomerContactPerson(this.ShipToContactPerson)
                                      .WithShipToEndCustomer(this.ShipToEndCustomer)
                                      .WithShipToEndCustomerAddress(this.ShipToEndCustomerAddress)
                                      .WithShipToEndCustomerContactPerson(this.ShipToEndCustomerContactPerson)
                                      .WithDescription(this.Description)
                                      .WithInvoiceDate(DateTime.UtcNow)
                                      .WithPurchaseInvoiceType(new PurchaseInvoiceTypes(this.Strategy.Session).PurchaseInvoice)
                                      .WithVatRegime(this.VatRegime)
                                      .WithDiscountAdjustment(this.DiscountAdjustment)
                                      .WithSurchargeAdjustment(this.SurchargeAdjustment)
                                      .WithShippingAndHandlingCharge(this.ShippingAndHandlingCharge)
                                      .WithFee(this.Fee)
                                      .WithCustomerReference(this.CustomerReference)
                                      .WithComment(this.Comment)
                                      .WithInternalComment(this.InternalComment)
                                      .Build();

                foreach (SalesInvoiceItem salesInvoiceItem in this.SalesInvoiceItems)
                {
                    var invoiceItem = new PurchaseInvoiceItemBuilder(this.Strategy.Session)
                                      .WithInvoiceItemType(salesInvoiceItem.InvoiceItemType)
                                      .WithActualUnitPrice(salesInvoiceItem.ActualUnitPrice)
                                      .WithProduct(salesInvoiceItem.Product)
                                      .WithQuantity(salesInvoiceItem.Quantity)
                                      .WithComment(salesInvoiceItem.Comment)
                                      .WithInternalComment(salesInvoiceItem.InternalComment)
                                      .Build();

                    purchaseInvoice.AddPurchaseInvoiceItem(invoiceItem);
                }
            }
        }
Ejemplo n.º 2
0
 public void AppsSend(SalesInvoiceSend method)
 {
     this.CurrentObjectState = new SalesInvoiceObjectStates(this.Strategy.Session).Sent;
 }