Exemple #1
0
        public void EcritureStock()
        {
            var es = new EcritureStock();

            es = DataHelpers.MapProperties(es, this) as EcritureStock;

            es.DateEcriture = DateTime.Now;
            es.LigneEcritureStocks.Add(new LigneEcritureStock()
            {
                Code         = this.Code,
                Designiation = this.Designiation,
                lArticle     = this.Id,
                Qts          = 1
            });

            DataHelpers.Shell.OpenScreenAttach(es, es.Name);
        }
Exemple #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());
        }