Example #1
0
        public PrintProduct(Guid customerId, string categories, string barcode, string name, decimal qty, decimal total, decimal price, int tvaId, decimal procentDiscount,
                            decimal sumDiscount)
        {
            CustomerId      = customerId;
            Categories      = categories;
            Name            = name;
            TvaId           = tvaId;
            ProcentDiscount = procentDiscount;
            SumDiscount     = sumDiscount;

            if (customerId != Guid.Empty)
            {
                Qty      = qty;
                Total    = total;
                Barcode  = barcode;
                Price    = price;
                Ht       = Math.Round((total / qty) * (100 / (100 + RepositoryTva.GetById(tvaId))), 2) * qty;
                TvaTotal = total - Ht;
            }
            else
            {
                Qty      = 1;
                Total    = sumDiscount;
                Barcode  = string.Empty;
                Price    = 0;
                Ht       = decimal.Round(sumDiscount * (100 / (100 + RepositoryTva.GetById(tvaId))), 2);
                TvaTotal = sumDiscount - Ht;
            }
        }
Example #2
0
        public static void XmlToDbSaveD(XDocument x)
        {
            var infoClientsCustomerId = ModePro ? Pro.CustomerId : new Guid("87da7ba2-5e52-4d31-8def-5a2dad508e94");

            var di = new DevisIdType(-1, DateTime.Now, false, infoClientsCustomerId, 0);

            var products = x.GetXElements("check", "product");
            var p        = new List <XElement>();

            foreach (var product in products)
            {
                var pf = p.Find(l => (l.GetXElementValue("CustomerId") == product.GetXElementValue("CustomerId")));

                if (pf == null || (pf.GetXElementValue("price") != product.GetXElementValue("price")))
                {
                    p.Add(product);
                }
                else
                {
                    var qty    = pf.GetXElementValue("qty").ToDecimal();
                    var qty1   = product.GetXElementValue("qty").ToDecimal();
                    var total  = pf.GetXElementValue("total").ToDecimal();
                    var total1 = product.GetXElementValue("total").ToDecimal();
                    pf.GetXElement("qty").SetValue(qty + qty1);
                    pf.GetXElement("total").SetValue(total + total1);
                }
            }

            x.GetXElements("check", "product").Remove();

            di.DivisWebs = new List <DevisWebType>();

            foreach (var product in p)
            {
                x.GetXElement("check").Add(product);
                var prixHt      = Math.Round(product.GetXElementValue("price").ToDecimal(), 2);
                var tva         = RepositoryTva.GetById(product.GetXElementValue("tva").ToInt());
                var tva1        = PrixTtcOnlyTva(product.GetXElementValue("price").ToDecimal(), tva);
                var monPrixHt   = product.GetXElementValue("contenance").ToDecimal();
                var qty         = product.GetXElementValue("qty").ToDecimal();
                var prixHtValue = prixHt - tva1;
                var dw          = new DevisWebType(Guid.NewGuid(), -1, prixHtValue, monPrixHt == 0 ? 1 : monPrixHt, qty,
                                                   qty * prixHtValue, 0, true, product.GetXElementValue("CustomerId").ToGuid(), di.InfoClientsCustomerId ?? Guid.Empty);

                var cusumerIdRealStock = Guid.Parse(product.GetXElementValue("cusumerIdRealStock").Replace('.', ','));

                RepositoryStockReal.AddProductCount(-dw.Qty, cusumerIdRealStock);

                RepositoryStockReal.UpdateProductCountByEstablishment(dw.Qty, Config.IdEstablishmentGros, dw.ProductsCustomerId);
                di.DivisWebs.Add(dw);
            }

            di.Total = di.DivisWebs.Sum(l => l.TotalHt);
            SyncService.InsDevis(di);
            FileMove();
        }
Example #3
0
        public static void MegaSync()
        {
            // check tables
            var syncTask = Task <bool> .Factory.StartNew(
                () =>
            {
                RepositoryActionHashBox.Sync();
                //RepositoryCheck
                RepositoryCheckTicket.Sync();
                RepositoryCheckTicketTmp.Sync();
                RepositoryPro.Sync();
                RepositoryClientInfo.Sync();
                RepositoryCloseTicket.Sync();
                RepositoryCloseTicketCheckDiscount.Sync();
                RepositoryCloseTicketG.Sync();
                RepositoryCloseTicketTmp.Sync();
                RepositoryCountry.Sync();
                RepositoryCurrency.Sync();
                //RepositoryCurrencyRelations
                RepositoryDevisId.Sync();
                RepositoryDevisWeb.Sync();
                //RepositoryDiscount
                RepositoryDiscountCard.Sync();
                RepositoryEstablishment.Sync();
                RepositoryGeneral.Sync();
                RepositoryGroupProduct.Sync();
                //RepositoryHistoryChangeProduct
                RepositoryInfoClientsDiscountsType.Sync();
                RepositoryLastUpdate.Sync();
                RepositoryOpenTicketWindow.Sync();
                RepositoryPayProduct.Sync();
                RepositoryPayProductTmp.Sync();
                //RepositoryPriceGros
                RepositoryProduct.Sync();
                RepositoryProductBc.Sync();
                RepositoryStatNation.Sync();
                RepositoryStatNationPopup.Sync();
                RepositoryStatPlaceArrond.Sync();
                //RepositoryStockLogs
                RepositoryStockReal.Sync();
                RepositorySyncPlus.Sync();
                RepositorySyncPlusProduct.Sync();
                //RepositoryTes
                RepositoryTva.Sync();
                RepositoryTypePay.Sync();
                //RepositoryXmlFile
                return(true);
            });

            syncTask.ContinueWith(
                s => { });
        }
Example #4
0
        private void BtnAddClick(object sender, RoutedEventArgs e)
        {
            var window = new TextWindow(false, Properties.Resources.LabelVat);

            if (window.ShowDialog() == true)
            {
                var tva = new Tva(Guid.NewGuid(), RepositoryTva.Tvases.Count + 1, window.NameText.ToDecimal());
                RepositoryTva.Add(tva);

                DataGridGroups.ItemsSource = null;
                DataGridGroups.ItemsSource = RepositoryTva.Tvases;
            }
        }
Example #5
0
 public static PayProductTmp FromCheckXElement(XElement element, Guid customerId, Guid checksTicketCustomerId)
 {
     return(new PayProductTmp(
                customerId,
                element.GetXElementValue("CustomerId").ToGuid(),
                element.GetXElementValue("Name"),
                element.GetXElementValue("CodeBare"),
                element.GetXElementValue("qty").ToDecimal(),
                RepositoryTva.GetById(element.GetXElementValue("tva").ToInt()),
                element.GetXElementValue("price").ToDecimal(),
                element.GetXElementValue("total").ToDecimal(),
                checksTicketCustomerId,
                0,
                0));
 }
Example #6
0
        private static PriceGrosType[] GetGros(Guid[] g)
        {
            var res = new PriceGrosType[g.Length];

            for (var i = 0; i < res.Length; i++)
            {
                var     x       = RepositoryProduct.GetXElementByElementName("CustomerId", g[i].ToString());
                var     pg      = x.GetXElementValue("priceGros").ToDecimal();
                decimal procent = Pro.DiscountValue;
                pg = pg + (pg * procent / 100);
                var tva1 = RepositoryTva.GetById(x.GetXElementValue("tva").ToInt());
                var tva  = PrixOnlyTva(pg, tva1);
                pg = pg + tva;

                res[i] = new PriceGrosType(x.GetXElementValue("cusumerIdRealStock").ToGuid(), x.GetXElementValue("CustomerId").ToGuid(), pg);
            }
            return(res);
        }
Example #7
0
        public WBallance(object arg)
        {
            InitializeComponent();
            _product                 = arg as ProductType;
            xCodebar.Content         = _product.CodeBare.Trim() == "" ? "not" : _product.CodeBare;
            xName.Content            = _product.Name;
            xDescription.Content     = _product.Desc;
            xPrix.Text               = _product.Price.ToString();
            xTVA.Content             = RepositoryTva.GetById(_product.TvaId);
            xBallance.Content        = _product.Balance;
            xContenance.Content      = _product.Contenance;
            xUniteContenance.Content = _product.UniteContenance;
            xTare.Content            = _product.Tare;

            GetBallance();
            Product = _product;

            numPad.TextBox  = xPrix;
            numPad.BEnter   = bOk;
            numPad2.TextBox = xBallance_kg;
            numPad2.BEnter  = bOk;
        }
Example #8
0
        public static void XmlToDbSave(XDocument x)
        {
            var tes = new Tes
            {
                CustomerId       = Guid.NewGuid(),
                ACodeFournisseur = 0,
                AFrtva           = Pro.Frtva ?? string.Empty,
                AMail            = Pro.Mail,
                AName            = Pro.Name ?? string.Empty,
                ASex             = Pro.SexToInt(Pro.Sex),
                ASurname         = Pro.Surname ?? string.Empty,
                ANameCompany     = Pro.NameCompany,
                AOfficeAddress   = Pro.OfficeAddress ?? string.Empty,
                AOfficeCity      = Pro.OfficeCity ?? string.Empty,
                AOfficeZipCode   = Pro.OfficeZipCode ?? string.Empty,
                ASiret           = Pro.Siret ?? string.Empty,
                ATelephone       = Pro.Telephone
            };

            tes.CustomerId   = Guid.NewGuid();
            tes.DateTime     = DateTime.Now;
            tes.Description  = string.Empty;
            tes.Id           = RepositoryTes.MaxId(0) + 1;
            tes.Livraison    = false;
            tes.Montant      = x.GetXAttributeValue("check", "sum").ToDecimal();
            tes.Nclient      = Pro.Nclient.ToString();
            tes.Payement     = false;
            tes.Type         = 0;
            tes.VAdresse     = RepositoryEstablishment.Establishment.Adress;
            tes.VCodeNaf     = "0";
            tes.VCp          = RepositoryEstablishment.Establishment.Cp;
            tes.VFax         = RepositoryEstablishment.Establishment.Phone;
            tes.VFrtva       = "";
            tes.VMail        = RepositoryEstablishment.Establishment.Mail;
            tes.VNameCompany = RepositoryEstablishment.Establishment.Name;
            tes.VPhone       = RepositoryEstablishment.Establishment.Phone;
            tes.VSiret       = "";
            tes.VVille       = RepositoryEstablishment.Establishment.Ville;
            var products = x.GetXElements("check", "product");

            var p = new List <XElement>();

            foreach (var product in products)
            {
                var pf = p.Find(l => l.GetXElementValue("CustomerId") == product.GetXElementValue("CustomerId"));

                if (pf == null || (pf.GetXElementValue("price") != product.GetXElementValue("price")))
                {
                    p.Add(product);
                }
                else
                {
                    var qty    = pf.GetXElementValue("qty").ToDecimal();
                    var qty1   = product.GetXElementValue("qty").ToDecimal();
                    var total  = pf.GetXElementValue("total").ToDecimal();
                    var total1 = product.GetXElementValue("total").ToDecimal();
                    pf.GetXElement("qty").SetValue(qty + qty1);
                    pf.GetXElement("total").SetValue(total + total1);
                }
            }
            x.GetXElements("check", "product").Remove();

            foreach (var product in p)
            {
                x.GetXElement("check").Add(product);
                var prod = new TesProduct
                {
                    Balance           = product.GetXElementValue("balance").ToBool(),
                    CodeBar           = ReplaceCodeBare(product.GetXElementValue("CodeBare")),
                    ConditionAchat    = 1,
                    CustomerId        = -1,
                    CustomerIdProduct = product.GetXElementValue("CustomerId").ToGuid(),
                    Date          = DateTime.Now,
                    Description   = Config.Name,
                    Group         = RepositoryGroupProduct.GetGroupNameById(product.GetXElementValue("grp").ToInt()),
                    NameProduct   = product.GetXElementValue("Name"),
                    PrixHt        = Math.Round(product.GetXElementValue("price").ToDecimal(), 2),
                    ProductsWeb   = product.GetXElementValue("ProductsWeb_CustomerId").ToGuid(),
                    Qty           = product.GetXElementValue("qty").Replace('.', ',').ToDecimal(),
                    SubGroup      = RepositoryGroupProduct.GetGroupNameById(product.GetXElementValue("grp").ToInt()),
                    TesCustomerId = tes.CustomerId,
                    Tva           = RepositoryTva.GetById(product.GetXElementValue("tva").ToInt())
                };

                var tva = PrixTtcOnlyTva(product.GetXElementValue("price").ToDecimal(), prod.Tva);
                prod.PrixHt  = prod.PrixHt - tva;
                prod.TotalHt = prod.Qty * prod.PrixHt;
                prod.TypeId  = 1;
                tes.TesProducts.Add(prod);

                var qty = prod.Qty;
                var cusumerIdRealStock = product.GetXElementValue("cusumerIdRealStock").ToGuid();

                RepositoryStockReal.AddProductCount(-qty, cusumerIdRealStock);
            }

            foreach (var type in RepositoryTypePay.TypePays)
            {
                var reglement = new TesReglament();
                var r         = RepositoryTypePay.TypePays.FirstOrDefault(l => l.NameCourt == type.NameCourt);
                var elm       = x.GetXAttribute("check", type.NameCourt);

                if (elm != null && r != null)
                {
                    reglement.Caisse     = Config.NameTicket;
                    reglement.CustomerId = Guid.NewGuid();
                    reglement.DateTime   = DateTime.Now;

                    if (r.Name == "En espèces")
                    {
                        var rendux = x.GetXAttribute("check", "Rendu");

                        if (rendux != null)
                        {
                            var rendu = rendux.Value.ToDecimal();
                            reglement.Montant = elm.Value.ToDecimal() + rendu;
                        }
                        else
                        {
                            reglement.Montant = elm.Value.ToDecimal();
                        }
                    }
                    else
                    {
                        reglement.Montant = elm.Value.ToDecimal();
                    }

                    reglement.TesCustomerId = tes.CustomerId;
                    reglement.TypePay       = r.Name;
                    tes.TesReglaments.Add(reglement);
                }
                tes.Payement = (tes.TesReglaments.Sum(l => l.Montant) >= tes.Montant);
            }

            if (tes.TesReglaments.Count > 0)
            {
                var newTes = new Tes
                {
                    CustomerId       = Guid.NewGuid(),
                    ACodeFournisseur = (short)(Pro.Nclient),
                    AFrtva           = Pro.Frtva ?? string.Empty,
                    AMail            = Pro.Mail,
                    AName            = Pro.Name ?? string.Empty,
                    ASex             = Pro.SexToInt(Pro.Sex),
                    ASurname         = Pro.Surname ?? string.Empty,
                    ANameCompany     = Pro.NameCompany,
                    AOfficeAddress   = Pro.OfficeAddress ?? string.Empty,
                    AOfficeCity      = Pro.OfficeCity ?? string.Empty,
                    AOfficeZipCode   = Pro.OfficeZipCode ?? string.Empty,
                    ASiret           = Pro.Siret ?? string.Empty,
                    ATelephone       = Pro.Telephone,
                    DateTime         = DateTime.Now,
                    Description      = "{" + tes.CustomerId + "}{" + tes.Id + "}{" + tes.Type + "}",
                    Id           = RepositoryTes.MaxId(1) + 1,
                    Livraison    = tes.Livraison,
                    Montant      = decimal.Parse(x.Element("check").Attribute("sum").Value.Replace('.', ',')),
                    Nclient      = Pro.Nclient.ToString(),
                    Payement     = tes.Payement,
                    Type         = 1,
                    VAdresse     = tes.VAdresse,
                    VCodeNaf     = tes.VCodeNaf,
                    VCp          = tes.VCp,
                    VFax         = tes.VFax,
                    VFrtva       = tes.VFrtva,
                    VMail        = tes.VMail,
                    VNameCompany = tes.VNameCompany,
                    VPhone       = tes.VPhone,
                    VSiret       = tes.VSiret,
                    VVille       = tes.VVille
                };
                tes.Description = "{" + newTes.CustomerId + "}{" + newTes.Id + "}{" + newTes.Type + "}";

                foreach (var t in tes.TesReglaments)
                {
                    if (t.Montant > 0)
                    {
                        t.TesCustomerId = newTes.CustomerId;
                        newTes.TesReglaments.Add(t);
                    }
                }
                tes.TesReglaments.Clear();

                RepositoryTes.AddToDb(newTes);
            }

            RepositoryTes.AddToDb(tes);

            Nfact = tes.Id ?? -1;
            FileMove();
        }