示例#1
0
        public EcriturePaiment SaisirPaiement(bool open = true)
        {
            if (EnsureIsSavedSubmit())
            {
                EcriturePaiment ep = new EcriturePaiment();
                ep = DataHelpers.MapProperties(ep, this) as EcriturePaiment;

                ep.Client        = this.Client;
                ep.DateEcriture  = DateTime.Now;
                ep.ModeDePiement = "Espèces";
                ep.ComtpeCredit  = CompteSettings.getInstance().CompteDebiteur;
                ep.ComtpeDebit   = CompteSettings.getInstance().ComptePaiementClient;
                ep.MontantPaye   = this.MontantGlobalTTC;
                ep.ObjetEcriture = "Recevoir";
                ep.Utilisateur   = DataHelpers.ConnectedUser?.Id;
                ep.RefFacture    = this.Id;

                this.RefPaiement = ep.Id;
                if (this.Save() && open)
                {
                    DataHelpers.Shell.OpenScreenAttach(ep, ep.Name);
                }

                return(ep);
            }
            return(null);
        }
示例#2
0
 public decimal?TauxSolde()
 {
     if (!isLocal && Taux == null)
     {
         var compteDebiteur = CompteSettings.getInstance().CompteDebiteur;
         var ecritureClient = DS.db.GetAll <EcritureJournal>(a => a.CompteJournal == compteDebiteur && a.Tier == this.Id);
         Taux = ecritureClient.Sum(z => z.MontantCredit) - ecritureClient.Sum(e => e.MontantDebit);
     }
     return(Taux);
 }
示例#3
0
 public EcriturePaiment()
 {
     Series            = MyModule()?.SeriesDefault;
     this.ComtpeCredit = CompteSettings.getInstance().CompteDebiteur;
     this.ComtpeDebit  = CompteSettings.getInstance().ComptePaiementClient;
 }
示例#4
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());
        }
示例#5
0
 public Facture()
 {
     Series     = MyModule()?.SeriesDefault;
     this.Stock = CompteSettings.getInstance().StockSortie;
 }