Exemple #1
0
 private void ExecLocalToDistant(Model.Local.Article Article, Model.Local.ArticleRepository ArticleRepository, Model.Prestashop.PsProduct Product, Model.Prestashop.PsProductRepository ProductRepository)
 {
     try
     {
         Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository();
         if (F_ARTICLERepository.ExistArticle(Article.Sag_Id))
         {
             Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadArticle(Article.Sag_Id);
             Model.Prestashop.PsPackRepository PsPackRepository = new Model.Prestashop.PsPackRepository();
             List <Model.Prestashop.PsPack>    ListPsPack       = PsPackRepository.ListProductPack(Product.IDProduct);
             foreach (Model.Prestashop.PsPack PsPack in ListPsPack)
             {
                 PsPackRepository.Delete(PsPack);
             }
             #region Pack/nomenclature
             if (Article.Art_Pack == true)
             {
                 Model.Sage.F_NOMENCLATRepository F_NOMENCLATRepository = new Model.Sage.F_NOMENCLATRepository();
                 List <Model.Sage.F_NOMENCLAT>    ListF_NOMENCLAT       = F_NOMENCLATRepository.ListRef(F_ARTICLE.AR_Ref);
                 Model.Sage.F_ARTICLE             F_ARTICLENOMENCLAT;
                 Model.Local.Article     ArticleNomenclat;
                 Model.Prestashop.PsPack PsPackAdd;
                 foreach (Model.Sage.F_NOMENCLAT F_NOMENCLAT in ListF_NOMENCLAT)
                 {
                     if (F_ARTICLERepository.ExistReference(F_NOMENCLAT.NO_RefDet))
                     {
                         F_ARTICLENOMENCLAT = F_ARTICLERepository.ReadReference(F_NOMENCLAT.NO_RefDet);
                         if (ArticleRepository.ExistSag_Id(F_ARTICLENOMENCLAT.cbMarq) &&
                             F_ARTICLENOMENCLAT.AR_SuiviStock != (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_SuiviStock.Aucun)
                         // pour ne pas prendre en compte les articles non suivi en stock
                         {
                             ArticleNomenclat = ArticleRepository.ReadSag_Id(F_ARTICLENOMENCLAT.cbMarq);
                             if (ArticleNomenclat.Pre_Id != null && ArticleNomenclat.Pre_Id.Value != 0)
                             {
                                 if (ProductRepository.ExistId((UInt32)ArticleNomenclat.Pre_Id.Value))
                                 {
                                     PsPackAdd = new Model.Prestashop.PsPack()
                                     {
                                         IDProductPack = Product.IDProduct,
                                         IDProductItem = (UInt32)ArticleNomenclat.Pre_Id.Value,
                                         Quantity      = (UInt32)F_NOMENCLAT.NO_Qte.Value
                                     };
                                     PsPackRepository.Add(PsPackAdd);
                                 }
                             }
                         }
                     }
                 }
             }
             #endregion
         }
     }
     catch (Exception ex)
     {
         Core.Error.SendMailError(ex.ToString());
     }
 }
Exemple #2
0
        private void ExecLocalToDistant(Model.Local.Article Article, Model.Prestashop.PsProduct Product, Model.Prestashop.PsProductRepository PsProductRepository,
                                        out List <string> log_chrono)
        {
            log_chrono = new List <string>();
            try
            {
                if (Article.TypeArticle == Model.Local.Article.enum_TypeArticle.ArticleComposition)
                {
                    if (Core.UpdateVersion.License.Option2)
                    {
                        Product.Price    = 0;
                        Product.Quantity = 0;
                        SynchronisationArticle.WriteStockAvailableProduct(Product);
                        ExecCompositionArticle(Article, Product);
                    }
                }
                else
                {
                    Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository();
                    if (F_ARTICLERepository.ExistArticle(Article.Sag_Id))
                    {
                        Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadArticle(Article.Sag_Id);
                        SynchronisationArticle.ReadQuantity(F_ARTICLE, Product);

                        #region Stock pack limité par composés
                        if (Article.Art_Pack == true || F_ARTICLE.AR_Nomencl == (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_Nomencl.Commerciale_Composant ||
                            F_ARTICLE.AR_Nomencl == (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_Nomencl.Commerciale_Compose)                                        // pour que les articles en nomenclature soient pris en compte
                        {
                            Model.Sage.F_NOMENCLATRepository F_NOMENCLATRepository = new Model.Sage.F_NOMENCLATRepository();
                            List <Model.Sage.F_NOMENCLAT>    ListF_NOMENCLAT       = F_NOMENCLATRepository.ListRef(F_ARTICLE.AR_Ref);
                            Model.Sage.F_ARTICLE             F_ARTICLENOMENCLAT;
                            Int32 QuantityPack = 0;
                            foreach (Model.Sage.F_NOMENCLAT F_NOMENCLAT in ListF_NOMENCLAT)
                            {
                                if (F_ARTICLERepository.ExistReference(F_NOMENCLAT.NO_RefDet))
                                {
                                    F_ARTICLENOMENCLAT = F_ARTICLERepository.ReadReference(F_NOMENCLAT.NO_RefDet);
                                    if (F_ARTICLENOMENCLAT.AR_SuiviStock != (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_SuiviStock.Aucun)                                                            // pour ne pas prendre en compte les articles non suivi en stock
                                    {
                                        Int32 CurrentQuantity = SynchronisationArticle.ReadQuantityPack(F_ARTICLENOMENCLAT, F_NOMENCLAT.NO_Qte.Value);
                                        if (Core.Global.GetConfig().ArticleStockNegatifZero&& CurrentQuantity < 0)
                                        {
                                            CurrentQuantity = 0;
                                        }
                                        if (CurrentQuantity < QuantityPack)
                                        {
                                            QuantityPack = CurrentQuantity;
                                        }
                                        else if (QuantityPack == 0)
                                        {
                                            QuantityPack = CurrentQuantity;
                                            // <AM> 14/08/2014 Si un des articles composant n'a pas de stock on sort de la fonction pour que l'article parent ai un stock à 0
                                            if (CurrentQuantity == 0)
                                            {
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            Product.Quantity = QuantityPack;
                        }
                        #endregion

                        int CatComptaArticle      = Core.Global.GetConfig().ConfigArticleCatComptable;
                        Model.Sage.F_TAXE TaxeTVA = SynchronisationArticle.ReadTaxe(F_ARTICLE, Product, CatComptaArticle);
                        Model.Sage.F_TAXE TaxeEco = SynchronisationArticle.ReadEcoTaxe(F_ARTICLE, Product, TaxeTVA, CatComptaArticle);
                        // <JG> 03/06/2016
                        if (Article.Art_SyncPrice)
                        {
                            SynchronisationArticle.ReadPrice(F_ARTICLE, Product, TaxeTVA);
                        }

                        if (Core.Global.GetConfig().MajPoidsSynchroStock)
                        {
                            SynchronisationArticle.ReadWeight(F_ARTICLE, Product);
                        }

                        if (Core.Global.GetConfig().ArticleDateDispoInfoLibreActif)
                        {
                            SynchronisationArticle.ReadDateDispo(Product, F_ARTICLE);
                        }

                        PsProductRepository.Save();
                        PsProductRepository.WriteDate(Product.IDProduct);

                        // <JG> 05/11/2013 déplacement pour application taxes et pdt spécifiques sur nouvelles déclinaisons
                        this.ExecAttribute(Article, Product, TaxeTVA, PsProductRepository);
                        this.ExecConditioning(Article, Product, TaxeTVA, PsProductRepository);

                        // <JG> 03/06/2016
                        if (Article.Art_SyncPrice)
                        {
                            List <string> log;
                            SynchronisationArticle.ExecSpecificPrice(F_ARTICLE, Product, Article, null, TaxeTVA, TaxeEco, out log);
                            if (log != null && log.Count > 0)
                            {
                                log_chrono.AddRange(log);
                            }
                        }

                        // <JG> 17/12/2012
                        SynchronisationArticle.ExecShopProduct(Product);

                        SynchronisationArticle.WriteStockAvailableProduct(Product);
                    }
                }
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
        }
Exemple #3
0
        private void ExecLocalToDistant(Model.Local.Article Article, Model.Prestashop.PsProduct Product, Model.Prestashop.PsProductRepository PsProductRepository)
        {
            try
            {
                if (Article.TypeArticle == Model.Local.Article.enum_TypeArticle.ArticleComposition)
                {
                    if (Core.UpdateVersion.License.Option2)
                    {
                        Product.Quantity = 0;
                        SynchronisationArticle.WriteStockAvailableProduct(Product);
                        ExecCompositionArticle(Article, Product);
                    }
                }
                else
                {
                    Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository();
                    if (F_ARTICLERepository.ExistArticle(Article.Sag_Id))
                    {
                        Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadArticle(Article.Sag_Id);
                        SynchronisationArticle.ReadQuantity(F_ARTICLE, Product);

                        #region Stock pack limité par composés
                        if (Article.Art_Pack == true || F_ARTICLE.AR_Nomencl == (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_Nomencl.Commerciale_Composant ||
                            F_ARTICLE.AR_Nomencl == (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_Nomencl.Commerciale_Compose)                                        // pour que les articles en nomenclature soient pris en compte
                        {
                            Model.Sage.F_NOMENCLATRepository F_NOMENCLATRepository = new Model.Sage.F_NOMENCLATRepository();
                            List <Model.Sage.F_NOMENCLAT>    ListF_NOMENCLAT       = F_NOMENCLATRepository.ListRef(F_ARTICLE.AR_Ref);
                            Model.Sage.F_ARTICLE             F_ARTICLENOMENCLAT;
                            Int32 QuantityPack = 0;
                            foreach (Model.Sage.F_NOMENCLAT F_NOMENCLAT in ListF_NOMENCLAT)
                            {
                                if (F_ARTICLERepository.ExistReference(F_NOMENCLAT.NO_RefDet))
                                {
                                    F_ARTICLENOMENCLAT = F_ARTICLERepository.ReadReference(F_NOMENCLAT.NO_RefDet);
                                    if (F_ARTICLENOMENCLAT.AR_SuiviStock != (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_SuiviStock.Aucun)                                            // pour ne pas prendre en compte les articles non suivi en stock
                                    {
                                        Int32 CurrentQuantity = SynchronisationArticle.ReadQuantityPack(F_ARTICLENOMENCLAT, F_NOMENCLAT.NO_Qte.Value);
                                        if (Core.Global.GetConfig().ArticleStockNegatifZero&& CurrentQuantity < 0)
                                        {
                                            CurrentQuantity = 0;
                                        }
                                        if (CurrentQuantity < QuantityPack)
                                        {
                                            QuantityPack = CurrentQuantity;
                                            // <AM> 14/08/2014 Si un des articles composant n'a pas de stock on sort de la fonction pour que l'article parent ai un stock à 0
                                            if (CurrentQuantity == 0)
                                            {
                                                break;
                                            }
                                        }
                                        else if (QuantityPack == 0)
                                        {
                                            QuantityPack = CurrentQuantity;
                                            // <AM> 14/08/2014 Si un des articles composant n'a pas de stock on sort de la fonction pour que l'article parent ai un stock à 0
                                            if (CurrentQuantity == 0)
                                            {
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            Product.Quantity = QuantityPack;
                        }
                        #endregion

                        // <JG> 29/10/2012 ajout synchronisation des stocks seule
                        //SynchronisationArticle.ReadEcoTaxe(F_ARTICLE, Product);
                        //SynchronisationArticle.ReadPrice(F_ARTICLE, Product);

                        if (Core.Global.GetConfig().MajPoidsSynchroStock)
                        {
                            SynchronisationArticle.ReadWeight(F_ARTICLE, Product);
                        }

                        if (Core.Global.GetConfig().ArticleDateDispoInfoLibreActif)
                        {
                            SynchronisationArticle.ReadDateDispo(Product, F_ARTICLE);
                        }

                        PsProductRepository.Save();
                        PsProductRepository.WriteDate(Product.IDProduct);

                        this.ExecAttribute(Article, Product, PsProductRepository);
                        this.ExecConditioning(Article, Product, PsProductRepository);

                        //SynchronisationArticle.ExecSpecificPrice(F_ARTICLE, Product);

                        // <JG> 17/12/2012
                        SynchronisationArticle.ExecShopProduct(Product);

                        SynchronisationArticle.WriteStockAvailableProduct(Product);
                    }
                }
            }
            catch (Exception ex)
            {
                Core.Error.SendMailError(ex.ToString());
            }
        }