Exemple #1
0
        public override void ExecuteNewCreditNote()
        {
            var cn = new ORIN_ClientCreditNotes()
            {
                CardCode     = SelectedDownPayment.CardCode,
                DocTotal     = DownPaymentDetail.Price ?? 0,
                DocDate      = SelectedDownPayment.DocDate,
                Comments     = DownPaymentDetail.Dscription,
                DocDueDate   = SelectedDownPayment.DocDueDate,
                Series       = 3, //serie correspondiente a nota de credito
                NumAtCard    = SelectedDownPayment.NumAtCard,
                WhsCode      = SelectedDownPayment.WhsCode,
                PaymentTypeL = SelectedDownPayment.PaymentType,
                CnTypeL      = ClientCreditNoteType.DownPayment
            };


            var vm = new ClientCreditNoteViewModel
            {
                CreditNote = cn,
                FormTitle  = "Nueva Nota de Crédito de Anticipo",
            };

            ShowDialog(new DownPaymentCreditNoteView(), vm);
        }
        public static void SaveTransaction(ORIN_ClientCreditNotes obj)
        {
            lock (Extensions.Locker)
            {
                var db = ContextFactory.GetDBContext();

                var transfers = obj.RIN1_ClientCreditNoteDetail.Select(t => new OINM_Transaction(obj, t)).ToList();

                transfers.ForEach(t => db.OINM_Transaction.Add(t));

                ContextFactory.SaveChanges();

                //Actualizar existencias

                //var articles = (from detail in obj.RIN1_ClientCreditNoteDetail
                //                join article in db.OITW_BranchArticles on detail.ItemCode equals article.ItemCode
                //                where article.WhsCode == detail.WhsCode
                //                select article).ToList();

                //articles.ForEach(a =>
                //{
                //    var detail = obj.RIN1_ClientCreditNoteDetail.FirstOrDefault(d => d.ItemCode == a.ItemCode);
                //    a.OnHand = a.OnHand + detail.Quantity;
                //    a.OnHand1 = a.OnHand1 + detail.Quantity;
                //});

                //ContextFactory.SaveChanges();

                StoredCallbackProcessor.UpdateStock();
            }
        }
Exemple #3
0
        private static ORIN_ClientCreditNotes SyncUpload(ORIN_ClientCreditNotes note)
        {
            var result = WebApiClient.AddSaleCreditNote(note).Result;

            note.UpdateModelPropertiesFrom(result.Model);
            note.StateL = LocalStatus.Procesado;
            result.UpdateEntityVersion();
            ClientCreditNoteHelper.SaveTransaction(note);
            return(note);
        }
 public static void Add(ORIN_ClientCreditNotes creditNote)
 {
     lock (Extensions.Locker)
     {
         var db = ContextFactory.GetDBContext();
         using (var scope = new TransactionScope())
         {
             db.ORIN_ClientCreditNotes.Add(creditNote);
             db.SaveChanges();
             scope.Complete();
         }
     }
 }
Exemple #5
0
        // Common method   for View Modes.

        public static ORIN_ClientCreditNotes Synchronize(ORIN_ClientCreditNotes note)
        {
            CheckForUpdates();// Actualizar cambios antes de subir y verificar si el objeto no fue ya procesado
            note = ClientCreditNoteHelper.Get(note.IdClientCreditNoteL);
            if (note.StateL != LocalStatus.Procesado)
            {
                return(note.Upload(SyncUpload));
            }
            else
            {
                return(note);
            }
        }
 public static void Delete(ORIN_ClientCreditNotes creditNote)
 {
     lock (Extensions.Locker)
     {
         var db = ContextFactory.GetDBContext();
         using (var scope = new TransactionScope())
         {
             creditNote.RIN1_ClientCreditNoteDetail.ToList().ForEach(t => db.RIN1_ClientCreditNoteDetail.Remove(t));
             db.ORIN_ClientCreditNotes.Remove(creditNote);
             db.SaveChanges();
             scope.Complete();
         }
     }
 }
Exemple #7
0
        public override void ExecuteNewCreditNote()
        {
            var cn = new ORIN_ClientCreditNotes()
            {
                CardCode     = SelectedSale.CardCode,
                DocDate      = SelectedSale.DocDate,
                Comments     = SelectedSale.Comments,
                Series       = 3, //serie correspondiente a nota de credito
                NumAtCard    = SelectedSale.NumAtCard,
                DocTotal     = SelectedSale.DocTotal,
                WhsCode      = SelectedSale.WhsCode,
                PaymentTypeL = SelectedSale.PaymentType,
                CnTypeL      = ClientCreditNoteType.Sale
            };

            SalesDetailsCollection.ToList()
            .ForEach(pdc =>
            {
                var article = ArticlesHelper.GetArticle(pdc.ItemCode);
                cn.RIN1_ClientCreditNoteDetail.Add(

                    new RIN1_ClientCreditNoteDetail()
                {
                    ItemCode      = pdc.ItemCode,
                    Quantity      = pdc.Quantity,
                    Price         = pdc.Price,
                    LineTotal     = pdc.LineTotal,
                    OITM_Articles = article,
                    BaseDocNum    = selectedSale.DocNum,
                    BaseEntry     = selectedSale.DocEntry,
                    Dscription    = article.ItemName,
                    TaxCode       = pdc.TaxCode,
                });
            }
                     );


            var vm = new ClientCreditNoteViewModel
            {
                CreditNote = cn, FormTitle = "Nueva Nota de Crédito de Venta",
                //todo: reemplazar esto
                Exento      = SelectedSale.INV1_SalesDetail.Any(d => d.TaxCode == Config.IVACOM),
                WithHolding = !Exento && SelectedSale.INV1_SalesDetail.Any(d => d.TaxCode == Config.IVARET),
            };

            ShowDialog(new NewClientCreditNote(), vm);
        }
Exemple #8
0
 public static Task <Synchro <ORIN_ClientCreditNotes> > AddSaleCreditNote(ORIN_ClientCreditNotes note)
 {
     return(PostAsync <ORIN_ClientCreditNotes, Synchro <ORIN_ClientCreditNotes> >("api/SalesCreditNotes", note));
 }