예제 #1
0
        public override bool Submit()
        {
            EcritureJournal ej = new EcritureJournal();

            ej.CompteJournal        = this.ComtpeDebit;
            ej.MontantDebit         = this.MontantPaye;
            ej.MontantCredit        = 0;
            ej.ObjetEcriture        = "Entrée Paiement";
            ej.RefDate              = this.DateEcriture;
            ej.RefEcrtirurePaiement = this.Id;
            ej.RefNumber            = this.Name;
            ej.CompteContre         = this.Client?.GetObject("Client")?.Name;
            ej.Tier        = this.Client;
            ej.Utilisateur = DataHelpers.ConnectedUser?.Id;
            ej.Save();
            ej.Submit();

            EcritureJournal ejVente = new EcritureJournal();

            ejVente.RefEcrtirurePaiement = this.Id;
            ejVente.CompteJournal        = this.ComtpeCredit;
            ejVente.MontantDebit         = 0;
            ejVente.MontantCredit        = this.MontantPaye;
            ejVente.ObjetEcriture        = "Entrée Paiement";
            ejVente.RefDate      = this.DateEcriture;
            ejVente.RefNumber    = this.Name;
            ejVente.Tier         = this.Client;
            ejVente.CompteContre = this.ComtpeDebit.GetObject("CompteCompta")?.Name;
            ejVente.Utilisateur  = DataHelpers.ConnectedUser?.Id;
            ejVente.Save();
            ejVente.Submit();

            // Change Facture stat EstPaye
            var facture = this.RefFacture.GetObject("Facture") as Facture;

            if (facture != null)
            {
                facture.EstPaye = (this.MontantPaye == facture.MontantGlobalTTC);
                facture.Save();
            }


            return(base.Submit());
        }
예제 #2
0
        public override bool Submit()
        {
            // Write stock entry
            if (this.UpdateStock)
            {
                EcritureStock es = new EcritureStock();

                es.DateEcriture  = this.DateCreation;
                es.ObjetEcriture = "Sortie de Matériel";
                es.Remarques     = $"à partir du facture {this.Name}";
                es.RefFacture    = this.Id;
                foreach (var item in this.ArticleFacture)
                {
                    var line = new LigneEcritureStock();
                    line = DataHelpers.MapProperties(line, item) as LigneEcritureStock;

                    es.LigneEcritureStocks.Add(line);
                }
                es.StockSourceDefault      = this.Stock;
                es.StockDestinationDefault = CompteSettings.getInstance().StockSortie;
                es.Save();
                es.Submit();
            }

            EcritureJournal ej = new EcritureJournal();

            ej.CompteJournal = CompteSettings.getInstance().CompteDebiteur;
            ej.MontantDebit  = this.MontantGlobalTTC;
            ej.MontantCredit = 0;

            ej.ObjetEcriture = "Facture de vente";
            ej.RefDate       = this.DateCreation;
            ej.RefNumber     = this.Name;
            ej.CompteContre  = CompteSettings.getInstance().CompteVente?.GetObject("CompteCompta")?.Name;
            ej.Tier          = this.Client;
            ej.Utilisateur   = DataHelpers.ConnectedUser?.Id;
            ej.Save();
            ej.Submit();

            EcritureJournal ejVente = new EcritureJournal();

            ejVente.CompteJournal = CompteSettings.getInstance().CompteVente;
            ejVente.MontantDebit  = 0;
            ejVente.MontantCredit = this.MontantGlobalTTC;
            ejVente.ObjetEcriture = "Facture de vente";
            ejVente.RefDate       = this.DateCreation;
            ejVente.RefNumber     = this.Name;
            ejVente.Tier          = this.Client;
            ejVente.CompteContre  = this.NomClient;
            ejVente.Utilisateur   = DataHelpers.ConnectedUser?.Id;
            ejVente.Save();
            ejVente.Submit();

            RefEcritureJournal.Add(ej.Id);
            RefEcritureJournal.Add(ejVente.Id);

            if (this.EstPaye)
            {
                var ecritureapiemenrt = new EcriturePaiment();
                ecritureapiemenrt.RefFacture    = this.Id;
                ecritureapiemenrt               = DataHelpers.MapProperties(ecritureapiemenrt, this) as EcriturePaiment;
                ecritureapiemenrt.Client        = this.Client;
                ecritureapiemenrt.DateEcriture  = this.DateEcheance;
                ecritureapiemenrt.ModeDePiement = "Espèces";
                ecritureapiemenrt.MontantPaye   = this.MontantGlobalTTC;
                ecritureapiemenrt.ObjetEcriture = "Recevoir";
                ecritureapiemenrt.Remarques     = "Enregistrer depuis factur " + this.Name;
                ecritureapiemenrt.Save();
                ecritureapiemenrt.Submit();
            }

            return(base.Submit());
        }