/// <summary>
        /// Charge les champs principaux pour instancier une facture
        /// </summary>
        /// <param name="Account"></param>
        /// <returns></returns>
        public Invoice PrepareInvoice(SOLUTIONS.GENERAL.ACCOUNT.Account Account, CAMPAIGN.Campaign Campagne)
        {
            if (Account == null || Account.IDAccount == 0)
            {
                throw new Exception("AccountError");
            }
            Invoice invoice = new Invoice();

            invoice.IDInvoice   = -1; // sera créer au prochain Save
            invoice.IDAccount   = Account.IDAccount;
            invoice.DateInvoice = DateTime.Now.Date;
            if (Campagne != null)
            {
                invoice.IDCampaign      = Campagne.IDCampaign;
                invoice.InvoiceLogo     = Campagne.DefaultLogoUrl;
                invoice.BuyerIDAddress  = Campagne.IdAddresseBuyerDefault;
                invoice.BuyerAddress    = Campagne.AddresseBuyerDefault;
                invoice.SellerIDAddress = Campagne.IdAddresseSellerDefault;
                invoice.SellerAddress   = Campagne.AddresseSellerDefault;
                //var _campaignProvider = new CAMPAIGN.CampaignProvider(Connector);
                //_campaignProvider.getCampagne()
            }

            //invoice.Lines.NewLine()
            return(invoice);
        }
        private Invoice GetInvoice(int idInvoice, int?selectedIDCampaign = null)
        {
            SOLUTIONS.GENERAL.ACCOUNT.AccountProvider accountProvider = new SOLUTIONS.GENERAL.ACCOUNT.AccountProvider(this.Connector);
            SOLUTIONS.GENERAL.ACCOUNT.Account         MyAccount       = accountProvider.GetAccount(this.MyUser.IDAccount);

            SOLUTIONS.INVOICES.CAMPAIGN.Campaign selectedCampaign = null;
            if (selectedIDCampaign.HasValue)
            {
                selectedCampaign = campaignProvider.getCampagne(selectedIDCampaign.Value);                             //  camapgne par default si besoin de création
            }
            Invoice invoice = null;

            if (idInvoice == 0)
            {
                return(null);                // invalide
            }
            if (idInvoice == -2)
            {
                InvoiceCache = null;                  // Force la recréation
            }
            if (idInvoice < 0)
            { // mode création nouvelle facture
                if (InvoiceCache == null)
                {
                    InvoiceCache = this.invoiceProvider.PrepareInvoice(MyAccount, selectedCampaign);
                }
                invoice = this.InvoiceCache;
            }
            else
            {
                invoice = invoiceProvider.GetInvoice(idInvoice);  // en base
            }
            this.ViewBag.invoice = invoice;

            DataInvoice.SOLUTIONS.GENERAL.GENERATOR.DocGeneratorProvider generatorprovider = new SOLUTIONS.GENERAL.GENERATOR.DocGeneratorProvider(this.Connector);
            DataInvoice.SOLUTIONS.GENERAL.GENERATOR.DocGeneratorPO       docgenerator      = generatorprovider.GetDocGenerator(1);
            this.ViewBag.docgenerator = docgenerator;

            return(invoice);
        }