Exemple #1
0
        private static ClassSync.classPriceGros[] get_gros(Guid[] g)
        {
            var res = new ClassSync.classPriceGros[g.Length];

            for (int i = 0; i < res.Length; i++)
            {
                XElement x = ClassProducts.findCustomerId(g[i]);


                decimal pg = decimal.Parse(x.Element("priceGros").Value.Replace('.', ','));


                decimal procent = (decimal)(ClassSync.classPro.getDiscountValue(ClassProMode.pro));



                pg = pg + (pg * procent / 100);



                decimal tva_ = ClassTVA.getTVA(int.Parse(x.Element("tva").Value.Replace('.', ',')));

                decimal tva = PrixOnlyTVA(pg, tva_);

                pg = pg + tva;


                res[i] = new ClassSync.classPriceGros(new object[] {
                    Guid.Parse(x.Element("cusumerIdRealStock").Value),

                    Guid.Parse(x.Element("CustumerId").Value),

                    pg
                });
            }

            return(res);
        }
Exemple #2
0
 public product(Guid customerId, string categories, string barcode, string name, decimal qty, decimal total, decimal price, int tva, decimal procentDiscount, decimal sumDiscount)
 {
     if (customerId != Guid.Empty)
     {
         this.customerId = customerId;
         this.categories = categories;
         this.name       = name;
         this.qty        = qty;
         this.total      = total;
         this.barcode    = barcode;
         this.price      = price;
         this.tva        = tva;
         this.HT         = decimal.Round(total * (100 / (100 + ClassTVA.getTVA(tva))), 2);
         this.TvaTotal   = total - HT;
         // this.TvaTotal = (total / (100 + ClassTVA.getTVA(tva)) * ClassTVA.getTVA(tva));
         // this.HT = total - this.TvaTotal;
         this.procentDiscount = procentDiscount;
         this.sumDiscount     = sumDiscount;
     }
     else
     {
         this.customerId = customerId;
         this.categories = categories;
         this.name       = name;
         this.qty        = 1;
         this.total      = sumDiscount;
         this.barcode    = "";
         this.price      = 0;
         this.tva        = tva;
         this.HT         = decimal.Round(sumDiscount * (100 / (100 + ClassTVA.getTVA(tva))), 2);
         this.TvaTotal   = sumDiscount - HT;
         //this.TvaTotal = (sumDiscount / (100 + ClassTVA.getTVA(tva)) * ClassTVA.getTVA(tva));
         //this.HT = sumDiscount - this.TvaTotal;
         this.procentDiscount = procentDiscount;
         this.sumDiscount     = sumDiscount;
     }
 }
Exemple #3
0
                public product(Guid customerId, string categories, string barcode, string name, decimal qty, decimal total, decimal price, int tva, decimal procentDiscount, decimal sumDiscount)
                {
                    if (customerId != Guid.Empty)
                    {
                        this.customerId = customerId;
                        this.categories = categories;
                        this.name       = name;
                        this.qty        = qty;
                        this.total      = total;
                        this.barcode    = barcode;
                        this.price      = price;
                        this.tva        = tva;


                        this.HT = Math.Round((total / qty) * (100 / (100 + ClassTVA.getTVA(tva))), 2) * qty;


                        /*
                         *
                         * Вся проблема в том что мы работаем с суммой продуктов, нужно работать с ценой за штуку
                         *
                         *
                         *
                         * ЦенаЕд =
                         * ЦенаЕд + НДС =
                         *
                         *
                         *
                         *
                         *
                         *
                         *
                         *
                         *
                         *
                         * this.HT = (Math.Ceiling(  (total * (100 / (100 + ClassTVA.getTVA(tva)))) * 10)/10) ;
                         *
                         * this.HT = decimal.Round(total * ClassTVA.getTVA(tva), 2);
                         * this.HT = decimal.Round(total * (100 / (100 + ClassTVA.getTVA(tva))),5);
                         *
                         *
                         */


                        this.TvaTotal = total - HT;
                        // this.TvaTotal = (total / (100 + ClassTVA.getTVA(tva)) * ClassTVA.getTVA(tva));
                        // this.HT = total - this.TvaTotal;
                        this.procentDiscount = procentDiscount;
                        this.sumDiscount     = sumDiscount;
                    }
                    else
                    {
                        this.customerId = customerId;
                        this.categories = categories;
                        this.name       = name;
                        this.qty        = 1;
                        this.total      = sumDiscount;
                        this.barcode    = "";
                        this.price      = 0;
                        this.tva        = tva;



                        this.HT = decimal.Round(sumDiscount * (100 / (100 + ClassTVA.getTVA(tva))), 2);



                        this.TvaTotal = sumDiscount - HT;
                        //this.TvaTotal = (sumDiscount / (100 + ClassTVA.getTVA(tva)) * ClassTVA.getTVA(tva));
                        //this.HT = sumDiscount - this.TvaTotal;
                        this.procentDiscount = procentDiscount;
                        this.sumDiscount     = sumDiscount;
                    }
                }
Exemple #4
0
        public static void xmlToDbSaveD(XDocument x)
        {
            ClassSync.DevisId di = new ClassSync.DevisId();

            di.Close = false;

            di.Date = DateTime.Now;

            di.Id = -1;

            di.infoClientsCustomerId = modePro ? ClassSync.classPro.getcustumerId(pro) : new Guid("87da7ba2-5e52-4d31-8def-5a2dad508e94");

            di.Total = 0;



            IEnumerable <XElement> products = x.Element("check").Elements("product");

            List <XElement> p = new List <XElement>();

            foreach (var product in products)
            {
                var pf = p.Find(l => (l.Element("CustumerId").Value == product.Element("CustumerId").Value));


                if (pf == null || (pf.Element("price").Value != product.Element("price").Value))
                {
                    p.Add(product);
                }

                else
                {
                    decimal qty    = decimal.Parse(pf.Element("qty").Value.Replace('.', ','));
                    decimal qty_   = decimal.Parse(product.Element("qty").Value.Replace('.', ','));
                    decimal total  = decimal.Parse(pf.Element("total").Value.Replace('.', ','));
                    decimal total_ = decimal.Parse(product.Element("total").Value.Replace('.', ','));
                    pf.Element("qty").SetValue(qty + qty_);
                    pf.Element("total").SetValue(total + total_);
                }
            }

            x.Element("check").Elements("product").Remove();


            di.divisWeb = new List <ClassSync.DevisWeb>();

            string cmd_ = "";

            foreach (var product in p)
            {
                x.Element("check").Add(product);

                ClassSync.DevisWeb dw = new ClassSync.DevisWeb();

                dw.CustomerId = Guid.NewGuid();

                dw.IdDevis = -1;

                dw.InfoClients_custumerId = di.infoClientsCustomerId ?? Guid.Empty;

                decimal prixHT = Math.Round(decimal.Parse(product.Element("price").Value.Replace('.', ',')), 2);

                decimal TVA = ClassTVA.getTVA(int.Parse(product.Element("tva").Value));

                decimal tva = PrixTTCOnlyTVA(decimal.Parse(product.Element("price").Value.Replace('.', ',')), TVA);

                dw.QTY = decimal.Parse(product.Element("qty").Value.Replace('.', ','));

                dw.PrixHT = prixHT - tva;

                dw.TotalHT = dw.QTY * dw.PrixHT;

                dw.Operator = false;

                dw.PayementType = 0;

                dw.ProductsCustumerId = Guid.Parse(product.Element("CustumerId").Value);

                dw.MonPrixHT = decimal.Parse(product.Element("contenance").Value.Replace('.', ','));

                dw.MonPrixHT = dw.MonPrixHT == 0 ? 1 : dw.MonPrixHT;

                Guid cusumerIdRealStock = Guid.Parse(product.Element("cusumerIdRealStock").Value.Replace('.', ','));

                cmd_ += ClassSync.ProductDB.StockReal.query_add_qty(-dw.QTY, cusumerIdRealStock) +
                        ClassSync.ProductDB.StockReal.query_add_qty_from_est(dw.QTY, ClassGlobalVar.IdEstablishment_GROS, dw.ProductsCustumerId);

                di.divisWeb.Add(dw);
            }

            di.Total = di.divisWeb.Sum(l => l.TotalHT);


            ClassSync.InsDevis(di);

            ClassSync.ProductDB.StockReal.response(cmd_);

            fileMove();
        }
Exemple #5
0
        public static void xmlToDbSave(XDocument x)
        {
            ClassSync.TES Tes = new ClassSync.TES();

            Tes.CustomerId = Guid.NewGuid();

            Tes.a_CodeFournisseur = 0; //short.Parse( pro.Nclient);

            Tes.a_FRTVA = ClassSync.classPro.getFRTVA(pro);

            Tes.a_Mail = pro.Mail;

            Tes.a_Name = ClassSync.classPro.getName(pro) ?? "";

            Tes.a_Sex = ClassSync.classPro.SexToInt(ClassSync.classPro.getSex(pro));

            Tes.a_Surname = ClassSync.classPro.getSurName(pro) ?? "";

            Tes.a_NameCompany = pro.NameCompany;

            Tes.a_OfficeAddress = ClassSync.classPro.getOfficeAddress(pro);

            Tes.a_OfficeCity = ClassSync.classPro.getOfficeCity(pro);

            Tes.a_OfficeZipCode = ClassSync.classPro.getOfficeZipCode(pro);



            Tes.a_SIRET = ClassSync.classPro.getSIRET(pro);



            Tes.a_Telephone = pro.Telephone;

            Tes.CustomerId = Guid.NewGuid();

            Tes.DateTime = DateTime.Now;

            Tes.Description = "";

            Tes.Id = ClassSync.TES.maxId(0) + 1;

            Tes.Livraison = false;

            Tes.Montant = decimal.Parse(x.Element("check").Attribute("sum").Value.Replace('.', ','));

            Tes.Nclient = pro.Nclient.ToString();

            Tes.Payement = false;

            Tes.Type = 0;

            Tes.v_Adresse = ClassGlobalVar.Establishment.Adresse;

            Tes.v_CodeNAF = "0";

            Tes.v_CP = ClassGlobalVar.Establishment.CP;

            Tes.v_Fax = ClassGlobalVar.Establishment.Phone;

            Tes.v_FRTVA = "";

            Tes.v_Mail = ClassGlobalVar.Establishment.Mail;

            Tes.v_NameCompany = ClassGlobalVar.Establishment.Name;

            Tes.v_Phone = ClassGlobalVar.Establishment.Phone;

            Tes.v_SIRET = "";

            Tes.v_Ville = ClassGlobalVar.Establishment.Ville;


            IEnumerable <XElement> products = x.Element("check").Elements("product");

            string cmdSr = " ";

            List <XElement> p = new List <XElement>();

            foreach (var product in products)
            {
                var pf = p.Find(l => (l.Element("CustumerId").Value == product.Element("CustumerId").Value));


                if (pf == null || (pf.Element("price").Value != product.Element("price").Value))
                {
                    p.Add(product);
                }

                else
                {
                    decimal qty    = decimal.Parse(pf.Element("qty").Value.Replace('.', ','));
                    decimal qty_   = decimal.Parse(product.Element("qty").Value.Replace('.', ','));
                    decimal total  = decimal.Parse(pf.Element("total").Value.Replace('.', ','));
                    decimal total_ = decimal.Parse(product.Element("total").Value.Replace('.', ','));
                    pf.Element("qty").SetValue(qty + qty_);
                    pf.Element("total").SetValue(total + total_);
                }
            }

            x.Element("check").Elements("product").Remove();



            foreach (var product in p)
            {
                x.Element("check").Add(product);

                ClassSync.TESproducts prod = new ClassSync.TESproducts();

                prod.Balance = bool.Parse(product.Element("balance").Value);

                prod.CodeBar = replaceCodeBare(product.Element("CodeBare").Value);

                prod.ConditionAchat = 1;// decimal.Parse( product.Element("qty").Value);

                prod.CustomerId = -1;

                prod.CustomerIdProduct = Guid.Parse(product.Element("CustumerId").Value);

                prod.Date = DateTime.Now;

                prod.Description = ClassGlobalVar.Name;

                prod.Group = ClassGroupProduct.getName(int.Parse(product.Element("grp").Value));

                prod.NameProduct = product.Element("Name").Value;

                prod.PrixHT = Math.Round(decimal.Parse(product.Element("price").Value.Replace('.', ',')), 2);

                prod.ProductsWeb = Guid.Parse(product.Element("ProductsWeb_CustomerId").Value);

                prod.QTY = decimal.Parse(product.Element("qty").Value.Replace('.', ','));

                prod.SubGroup = ClassGroupProduct.getName(int.Parse(product.Element("grp").Value));

                prod.TESCustomerId = Tes.CustomerId;

                prod.TVA = ClassTVA.getTVA(int.Parse(product.Element("tva").Value));

                decimal tva = PrixTTCOnlyTVA(decimal.Parse(product.Element("price").Value.Replace('.', ',')), prod.TVA);

                prod.PrixHT = prod.PrixHT - tva;

                prod.TotalHT = prod.QTY * prod.PrixHT; //decimal.Parse(product.Element("total").Value.Replace('.', ',')) - totalOnlyTVA(product);

                prod.TypeID = 1;

                Tes.TESproducts.Add(prod);

                decimal qty = prod.QTY;

                Guid cusumerIdRealStock = Guid.Parse(product.Element("cusumerIdRealStock").Value.Replace('.', ','));

                cmdSr += ClassSync.ProductDB.StockReal.query_add_qty(-qty, cusumerIdRealStock);
            }

            foreach (ClassSync.TypesPayDB type in ClassSync.TypesPayDB.t)
            {
                ClassSync.TESreglement reglement = new ClassSync.TESreglement();

                var r = reglement.TypePayItems.FirstOrDefault(l => l.Text == type.NameCourt);

                var elm = x.Element("check").Attribute(type.NameCourt);

                if (elm != null && r != null)
                {
                    reglement.Caisse = ClassGlobalVar.nameTicket;

                    reglement.CustomerId = Guid.NewGuid();

                    reglement.DateTime = DateTime.Now;

                    if (r.Value == "En espèces")
                    {
                        var rendux = x.Element("check").Attribute("Rendu");

                        if (rendux != null)
                        {
                            decimal rendu = decimal.Parse(rendux.Value.Replace('.', ','));

                            reglement.Montant = decimal.Parse(elm.Value.Replace('.', ',')) + rendu;
                        }
                        else
                        {
                            reglement.Montant = decimal.Parse(elm.Value.Replace('.', ','));
                        }
                    }
                    else
                    {
                        reglement.Montant = decimal.Parse(elm.Value.Replace('.', ','));
                    }
                    reglement.TESCustomerId = Tes.CustomerId;

                    reglement.TypePay = r.Value;

                    Tes.TESreglement.Add(reglement);
                }
                Tes.Payement = (Tes.TESreglement.Sum(l => l.Montant) >= Tes.Montant);
            }


            int c_tes  = 0;
            int c_tes_ = 0;
            int c_sr   = 0;

            if (Tes.TESreglement.Count > 0)
            {
                ClassSync.TES Tes_ = new ClassSync.TES();

                Tes_.CustomerId = Guid.NewGuid();

                Tes_.a_CodeFournisseur = (short)(pro.Nclient);

                Tes_.a_FRTVA = ClassSync.classPro.getFRTVA(pro);

                Tes_.a_Mail = pro.Mail;

                Tes_.a_Name = ClassSync.classPro.getName(pro) ?? "";

                Tes_.a_Sex = ClassSync.classPro.SexToInt(ClassSync.classPro.getSex(pro));

                Tes_.a_Surname = ClassSync.classPro.getSurName(pro) ?? "";


                Tes_.a_NameCompany = pro.NameCompany;

                Tes_.a_OfficeAddress = ClassSync.classPro.getOfficeAddress(pro);

                Tes_.a_OfficeCity = ClassSync.classPro.getOfficeCity(pro);

                Tes_.a_OfficeZipCode = ClassSync.classPro.getOfficeZipCode(pro);



                Tes_.a_SIRET = ClassSync.classPro.getSIRET(pro);

                Tes_.a_Telephone = pro.Telephone;

                Tes_.CustomerId = Guid.NewGuid();

                Tes_.DateTime = DateTime.Now;

                Tes_.Description = "{" + Tes.CustomerId + "}{" + Tes.Id + "}{" + Tes.Type + "}";

                Tes_.Id = ClassSync.TES.maxId(1) + 1;


                Tes_.Livraison = Tes.Livraison;

                Tes_.Montant = decimal.Parse(x.Element("check").Attribute("sum").Value.Replace('.', ','));

                Tes_.Nclient = pro.Nclient.ToString();

                Tes_.Payement = Tes.Payement;

                Tes_.Type = 1;

                Tes_.v_Adresse = Tes.v_Adresse;

                Tes_.v_CodeNAF = Tes.v_CodeNAF;

                Tes_.v_CP = Tes.v_CP;

                Tes_.v_Fax = Tes.v_Fax;

                Tes_.v_FRTVA = Tes.v_FRTVA;

                Tes_.v_Mail = Tes.v_Mail;

                Tes_.v_NameCompany = Tes.v_NameCompany;

                Tes_.v_Phone = Tes.v_Phone;

                Tes_.v_SIRET = Tes.v_SIRET;

                Tes_.v_Ville = Tes.v_Ville;

                Tes.Description = "{" + Tes_.CustomerId + "}{" + Tes_.Id + "}{" + Tes_.Type + "}";

                foreach (var t in Tes.TESreglement)
                {
                    if (t.Montant > 0)
                    {
                        t.TESCustomerId = Tes_.CustomerId;

                        Tes_.TESreglement.Add(t);
                    }
                }

                Tes.TESreglement.Clear();
                //   foreach (var t in Tes.TESproducts)
                //     Tes_.TESproducts.Add(t);

                c_tes_ = ClassSync.TES.ins(Tes_);
            }

            c_tes = ClassSync.TES.ins(Tes);

            c_sr = ClassSync.ProductDB.StockReal.response(cmdSr);

            nfact = Tes.Id ?? -1;


            fileMove();
        }