Exemple #1
0
        private void sales_order_detailDataGrid_InitializingNewItem(object sender, InitializingNewItemEventArgs e)
        {
            sales_order_detail sales_order_detail = (sales_order_detail)e.NewItem;
            sales_order        sales_order        = (sales_order)sales_orderDataGrid.SelectedItem;

            sales_order_detail.sales_order = sales_order;
        }
Exemple #2
0
        //Sales order
        public void Document_PrintOrder(int document_id, sales_order sales_order, bool OverRide_AutoPrint)
        {
            try
            {
                if (sales_order.app_document_range.printer_name != null && OverRide_AutoPrint == false)
                {
                    DocumentViewr MainWindow = new DocumentViewr();
                    MainWindow.loadSalesOrderReport(sales_order.id_sales_order);
                }
                else // true
                {
                    NotSupportedException ex = new NotSupportedException();
                    throw ex;
                }
            }
            catch
            {
                DocumentViewr MainWindow = new DocumentViewr();
                MainWindow.loadSalesOrderReport(sales_order.id_sales_order);

                Window window = new Window
                {
                    Title   = "Report",
                    Content = MainWindow
                };
                window.ShowDialog();
            }
        }
        private void PopulateSalesOrder(string SONumber)
        {
            sales_order _sales_order = new sales_order();

            using (var dbContext = new MRP4MEEntities())
            {
                _sales_order = dbContext.sales_order.Find(SONumber);

                if (!String.IsNullOrEmpty(_sales_order.so_number))
                {
                    this.ThisIsEnabled = false;
                    this.CustomerName  = _sales_order.customer_name;
                    this.RequiredDate  = _sales_order.required_date;
                    this.SONumber      = _sales_order.so_number;
                    this.ItemCode      = _sales_order.item_code;
                    this.Name          = _sales_order.name;
                    this.Unit          = _sales_order.unit;
                    this.UnitCost      = _sales_order.unit_cost.ToString();
                    this.Description   = _sales_order.description;
                    this.Quantity      = _sales_order.quantity.ToString();
                    if (_sales_order.quantity_received != null)
                    {
                        this.QuantityReceived = _sales_order.quantity_received.ToString();
                    }
                    if (_sales_order.back_ordered != null)
                    {
                        this.BackOrdered = _sales_order.back_ordered.ToString();
                    }
                    this.Attachment  = _sales_order.attachment;
                    this.UploadImage = _sales_order.upload_image;
                    this.User        = _sales_order.user;
                    this.Level       = "0";
                }
            }
        }
Exemple #4
0
        private void select_Item(sales_order sales_order, item item)
        {
            Settings SalesSettings = new Settings();

            if (sales_order.sales_order_detail.Where(a => a.id_item == item.id_item).FirstOrDefault() == null || SalesSettings.AllowDuplicateItem)
            {
                sales_order_detail _sales_order_detail = new sales_order_detail();
                _sales_order_detail.State            = EntityState.Added;
                _sales_order_detail.sales_order      = sales_order;
                _sales_order_detail.Contact          = sales_order.contact;
                _sales_order_detail.item_description = item.description;
                _sales_order_detail.item             = item;
                _sales_order_detail.id_item          = item.id_item;

                sales_order.sales_order_detail.Add(_sales_order_detail);
            }
            else
            {
                sales_order_detail sales_order_detail = sales_order.sales_order_detail.Where(a => a.id_item == item.id_item).FirstOrDefault();
                sales_order_detail.quantity += 1;
            }

            Dispatcher.BeginInvoke((Action)(() =>
            {
                CollectionViewSource sales_ordersales_order_detailViewSource = FindResource("sales_ordersales_order_detailViewSource") as CollectionViewSource;
                sales_ordersales_order_detailViewSource.View.Refresh();
                calculate_vat(null, null);
            }));
        }
Exemple #5
0
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int id_contact = sbxContact.ContactID;

            if (sales_orderViewSource != null)
            {
                if (sales_orderViewSource.View != null)
                {
                    if (sales_orderViewSource.View.Cast <sales_order>().Count() > 0)
                    {
                        sales_orderViewSource.View.Filter = i =>
                        {
                            sales_order sales_order = (sales_order)i;
                            if (sales_order.id_contact == id_contact)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        };
                    }
                }
            }
        }
Exemple #6
0
        private void toolBar_btnSearch_Click(object sender, string query)
        {
            if (!string.IsNullOrEmpty(query) && sales_orderViewSource != null)
            {
                try
                {
                    sales_orderViewSource.View.Filter = i =>
                    {
                        sales_order sales_order = i as sales_order;

                        string number   = sales_order.number != null ? sales_order.number : "";
                        string customer = sales_order.contact != null ? sales_order.contact.name : "";

                        if (customer.ToLower().Contains(query.ToLower()) ||
                            number.ToLower().Contains(query.ToLower()))
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    };
                }
                catch { }
            }
            else
            {
                sales_orderViewSource.View.Filter = null;
            }
        }
Exemple #7
0
        private void sales_orderDatagrid_LoadingRowDetails(object sender, DataGridRowDetailsEventArgs e)
        {
            sales_order _sales_order  = ((System.Windows.Controls.DataGrid)sender).SelectedItem as sales_order;
            int         id_salesOrder = _sales_order.id_sales_order;

            Task task_PrimaryData = Task.Factory.StartNew(() => LoadOrderDetail(id_salesOrder, e));
        }
Exemple #8
0
        private void salesorder_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            Hyperlink   Hyperlink   = (Hyperlink)sender;
            sales_order sales_order = (sales_order)Hyperlink.Tag;

            if (sales_order != null)
            {
                entity.Brillo.Document.Start.Automatic(sales_order, sales_order.app_document_range);
            }
        }
Exemple #9
0
        private void Totals_btnClean_Click(object sender)
        {
            sales_order sales_order = sales_orderViewSource.View.CurrentItem as sales_order;

            if (sales_order != null)
            {
                decimal TrailingDecimals = sales_order.GrandTotal - Math.Floor(sales_order.GrandTotal);
                sales_order.DiscountWithoutPercentage += TrailingDecimals;
            }
        }
Exemple #10
0
        private void salesorder_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            Hyperlink   Hyperlink   = (Hyperlink)sender;
            sales_order sales_order = (sales_order)Hyperlink.Tag;

            if (sales_order != null)
            {
                entity.Brillo.Logic.Document Document = new entity.Brillo.Logic.Document();
                Document.Document_PrintOrder(0, sales_order, true);
            }
        }
Exemple #11
0
 private void set_ContactPref(object sender, EventArgs e)
 {
     if (sbxContact.ContactID > 0)
     {
         contact     contact     = dbContext.contacts.Where(x => x.id_contact == sbxContact.ContactID).FirstOrDefault();
         sales_order sales_order = (sales_order)sales_orderDataGrid.SelectedItem;
         sales_order.id_contact = contact.id_contact;
         sales_order.contact    = contact;
         Task thread_SecondaryData = Task.Factory.StartNew(() => set_ContactPref_Thread(contact));
     }
 }
Exemple #12
0
        private void New_Click(object sender)
        {
            Settings SalesSettings = new Settings();

            sales_order sales_order = dbContext.New();

            sales_order.trans_date = DateTime.Now.AddDays(SalesSettings.TransDate_Offset);

            cbxCurrency.get_DefaultCurrencyActiveRate();
            dbContext.sales_order.Add(sales_order);
            sales_orderViewSource.View.MoveCurrentTo(sales_order);
        }
Exemple #13
0
        private void toolBar_btnPrint_Click(object sender, MouseButtonEventArgs e)
        {
            sales_order sales_order = sales_orderDataGrid.SelectedItem as sales_order;

            if (sales_order != null)
            {
                entity.Brillo.Document.Start.Manual(sales_order, sales_order.app_document_range);
            }
            else
            {
                toolBar.msgWarning("Please select");
            }
        }
Exemple #14
0
        private void item_Select(object sender, EventArgs e)
        {
            if (sbxItem.ItemID > 0)
            {
                sales_order sales_order = sales_orderViewSource.View.CurrentItem as sales_order;
                item        item        = dbContext.items.Where(x => x.id_item == sbxItem.ItemID).FirstOrDefault();

                if (item != null && item.id_item > 0 && sales_order != null)
                {
                    Task Thread = Task.Factory.StartNew(() => select_Item(sales_order, item));
                }
                sales_order.RaisePropertyChanged("GrandTotal");
            }
        }
Exemple #15
0
 private void toolBar_btnEdit_Click(object sender)
 {
     if (sales_orderDataGrid.SelectedItem != null)
     {
         sales_order sales_order_old = (sales_order)sales_orderDataGrid.SelectedItem;
         sales_order_old.IsSelected             = true;
         sales_order_old.State                  = EntityState.Modified;
         dbContext.Entry(sales_order_old).State = EntityState.Modified;
     }
     else
     {
         toolBar.msgWarning("Please Select an Item");
     }
 }
Exemple #16
0
 private void sales_orderDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         sales_order sales_order = (sales_order)sales_orderDataGrid.SelectedItem;
         if (sales_order != null)
         {
             calculate_vat(sender, e);
         }
     }
     catch (Exception ex)
     {
         toolBar.msgError(ex);
     }
 }
Exemple #17
0
        private void btnSalesBudget_Click(object sender, RoutedEventArgs e)
        {
            crud_modal.Visibility = Visibility.Visible;
            if (sbxContact.ContactID > 0)
            {
                contact contact = dbContext.contacts.Where(x => x.id_contact == sbxContact.ContactID).FirstOrDefault();
                pnlSalesBudget._contact = contact;
            }
            pnlSalesBudget.SalesBudget_Click += SalesBudget_Click;

            sales_order _sales_order = (sales_order)sales_orderViewSource.View.CurrentItem;

            pnlSalesBudget.sales_order = _sales_order;
            pnlSalesBudget.db          = dbContext;
            crud_modal.Children.Add(pnlSalesBudget);
        }
Exemple #18
0
        private void cbxCurrency_LostFocus(object sender, RoutedEventArgs e)
        {
            sales_order sales_order = sales_orderViewSource.View.CurrentItem as sales_order;

            if (sales_order != null)
            {
                if (sales_order.id_currencyfx > 0)
                {
                    if (dbContext.app_currencyfx.Where(x => x.id_currencyfx == sales_order.id_currencyfx).FirstOrDefault() != null)
                    {
                        sales_order.app_currencyfx = dbContext.app_currencyfx.Where(x => x.id_currencyfx == sales_order.id_currencyfx).FirstOrDefault();
                    }
                }
            }
            calculate_vat(sender, e);
        }
Exemple #19
0
 private void toolBar_btnDelete_Click(object sender)
 {
     try
     {
         if (MessageBox.Show("Are you sure want to Delete?", "Cognitivo", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             sales_order sales_order = (sales_order)sales_orderDataGrid.SelectedItem;
             sales_order.is_head    = false;
             sales_order.State      = EntityState.Deleted;
             sales_order.IsSelected = true;
         }
     }
     catch (Exception ex)
     {
         toolBar.msgError(ex);
     }
 }
Exemple #20
0
        /// <summary>
        /// delete the sales order from the database.  This method is invoked by the DeleteSOCommand.
        /// </summary>
        public void DeleteSO(string SONumber)
        {
            MessageBoxResult messageBoxResult =
                System.Windows.MessageBox.Show("Are you sure to delete sales order # " + SONumber + " ?", "MRP4ME - Delete Confirmation", System.Windows.MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                using (var dbContext = new MRP4MEEntities())
                {
                    sales_order item = Salesorders.FirstOrDefault(x => x.so_number == SONumber);
                    dbContext.sales_order.Attach(item);
                    dbContext.sales_order.Remove(item);
                    dbContext.SaveChanges();
                    dbContext.Entry(item).State = System.Data.Entity.EntityState.Detached;
                    Salesorders.Remove(item);
                    NotifyPropertyChanged("Salesorders");
                }
            }
        }
Exemple #21
0
        public async void SalesBudget_Click(object sender)
        {
            sales_order sales_order = (sales_order)sales_orderViewSource.View.CurrentItem;

            foreach (sales_order_detail detail in sales_order.sales_order_detail)
            {
                detail.CurrencyFX_ID = sales_order.id_currencyfx;
                detail.item          = await dbContext.items.Where(x => x.id_item == detail.id_item).FirstOrDefaultAsync();
            }

            cbxContactRelation.ItemsSource = dbContext.contacts.Where(x => x.parent.id_contact == sales_order.id_contact).ToList();

            CollectionViewSource sales_ordersales_order_detailViewSource = ((CollectionViewSource)(FindResource("sales_ordersales_order_detailViewSource")));

            sales_orderViewSource.View.Refresh();
            sales_ordersales_order_detailViewSource.View.Refresh();
            crud_modal.Children.Clear();
            crud_modal.Visibility = Visibility.Collapsed;
        }
Exemple #22
0
 private void DeleteCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     try
     {
         MessageBoxResult result = MessageBox.Show("Are you sure want to Delete?", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             sales_order sales_order = sales_orderViewSource.View.CurrentItem as sales_order;
             //DeleteDetailGridRow
             dgvSalesDetail.CancelEdit();
             sales_order_detail sales_order_detail = e.Parameter as sales_order_detail;
             dbContext.sales_order_detail.Remove(sales_order_detail);
             CollectionViewSource sales_ordersales_order_detailViewSource = FindResource("sales_ordersales_order_detailViewSource") as CollectionViewSource;
             sales_ordersales_order_detailViewSource.View.Refresh();
         }
     }
     catch (Exception ex)
     {
         toolBar.msgError(ex);
     }
 }
Exemple #23
0
        private void cbxCondition_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            sales_order sales_order = (sales_order)sales_orderDataGrid.SelectedItem;

            //Contract
            if (cbxCondition.SelectedItem != null)
            {
                app_condition app_condition = cbxCondition.SelectedItem as app_condition;
                if (app_condition != null)
                {
                    cbxContract.ItemsSource = CurrentSession.Get_Contract().Where(x => x.id_condition == app_condition.id_condition).ToList();
                }

                if (sales_order != null)
                {
                    if (sales_order.id_contract == 0)
                    {
                        cbxContract.SelectedIndex = 0;
                    }
                }
            }
        }
Exemple #24
0
 private void btnDuplicateInvoice_PreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     using (db db = new db())
     {
         sales_order sales_order = sales_orderViewSource.View.CurrentItem as sales_order;
         if (sales_order != null)
         {
             if (sales_order.id_sales_order != 0)
             {
                 var originalEntity = db.sales_invoice.AsNoTracking()
                                      .FirstOrDefault(x => x.id_sales_invoice == sales_order.id_sales_order);
                 db.sales_invoice.Add(originalEntity);
                 sales_orderViewSource.View.Refresh();
                 sales_orderViewSource.View.MoveCurrentToLast();
             }
             else
             {
                 toolBar.msgWarning("Please save before duplicating");
             }
         }
     }
 }
Exemple #25
0
        private void calculate_vat(object sender, EventArgs e)
        {
            sales_order sales_order = (sales_order)sales_orderDataGrid.SelectedItem;

            sales_order.RaisePropertyChanged("GrandTotal");
            if (sales_order != null)
            {
                List <sales_order_detail> sales_order_detail = sales_order.sales_order_detail.ToList();
                if (sales_order_detail.Count > 0)
                {
                    dgvvat.ItemsSource = sales_order_detail
                                         .Join(dbContext.app_vat_group_details, ad => ad.id_vat_group, cfx => cfx.id_vat_group
                                               , (ad, cfx) => new { name = cfx.app_vat.name, value = ad.unit_price * cfx.app_vat.coefficient, id_vat = cfx.app_vat.id_vat, ad })
                                         .GroupBy(a => new { a.name, a.id_vat, a.ad })
                                         .Select(g => new
                    {
                        id_vat = g.Key.id_vat,
                        name   = g.Key.name,
                        value  = g.Sum(a => a.value * a.ad.quantity)
                    }).ToList();
                }
            }
        }
Exemple #26
0
 void filter_sales()
 {
     if (sales_orderViewSource != null)
     {
         if (sales_orderViewSource.View != null)
         {
             if (sales_orderViewSource.View.OfType <sales_order>().Count() > 0)
             {
                 sales_orderViewSource.View.Filter = i =>
                 {
                     sales_order sales_order = (sales_order)i;
                     if (sales_order.sales_order_detail.Sum(x => x.balance) > 0)
                     {
                         return(true);
                     }
                     else
                     {
                         return(false);
                     }
                 };
             }
         }
     }
 }
        /// <summary>
        /// Saves the SO to the DB.  This method is invoked by the SaveCommand.
        /// </summary>
        public void Save()
        {
            try
            {
                sales_order _sales_order;

                using (var dbContext = new MRP4MEEntities())
                {
                    _sales_order = dbContext.sales_order.Find(salesorder.so_number);

                    if (_sales_order != null)
                    { //check for duplicate sales order number when new SO
                        if (isNewSO)
                        {
                            throw new DbUpdateException();
                        }
                    }
                    else
                    { //if sales order is null then it is new sales order
                        _sales_order = new sales_order();
                    }

                    DateTime dateValue = DateTime.Parse(this.RequiredDate.ToString());
                    _sales_order.customer_name = salesorder.customer_name;
                    _sales_order.required_date = DateTime.Parse(dateValue.ToString("yyyy/MM/dd"));
                    _sales_order.so_number     = salesorder.so_number;
                    _sales_order.item_code     = salesorder.item_code;
                    _sales_order.name          = salesorder.name;
                    _sales_order.unit          = salesorder.unit;
                    _sales_order.unit_cost     = Convert.ToDecimal(salesorder.unit_cost);
                    _sales_order.description   = salesorder.description;
                    _sales_order.quantity      = Int32.Parse(salesorder.quantity);
                    if (!String.IsNullOrEmpty(salesorder.quantity_received))
                    {
                        _sales_order.quantity_received = Int32.Parse(salesorder.quantity_received);
                    }

                    if (!String.IsNullOrEmpty(salesorder.back_ordered))
                    {
                        _sales_order.back_ordered = Int32.Parse(salesorder.back_ordered);

                        if (String.IsNullOrEmpty(salesorder.quantity_received))
                        {
                            _sales_order.quantity_received = _sales_order.quantity - _sales_order.back_ordered;
                        }
                    }


                    _sales_order.attachment   = salesorder.attachment;
                    _sales_order.upload_image = salesorder.upload_image;
                    _sales_order.user         = salesorder.user;
                    _sales_order.level        = 0;

                    if (isNewSO)
                    {
                        dbContext.sales_order.Add(_sales_order);
                        dbContext.SaveChanges();
                        dbContext.Entry(_sales_order).State = EntityState.Detached;
                    }
                    else
                    {
                        dbContext.SaveChanges();
                        dbContext.Entry(_sales_order).State = EntityState.Modified;
                        dbContext.Entry(_sales_order).State = EntityState.Detached;
                    }
                }
                ClearForm();

                MessageBox.Show("Sales Order successfully saved.", "MRP4ME");
                //NotifyPropertyChanged("SO");
            }
            catch (DbUpdateException ex)
            {
                //MessageBox.Show("SO Number already exist!" , "MRP4ME");
                AddError(new ValidationError("SONumber", Constraint_Mandatory, " SO Number already exist!"));
                NotifyPropertyChanged("SONumber");
                Tracer.LogUserDefinedValidation("DbUpdateException. " + ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sales Order not saved, please verify data and save again." + ex.Message, "MRP4ME");
            }
        }
Exemple #28
0
        public List <payment_schedual> insert_Schedual(object obj_entity)
        {
            List <payment_schedual> payment_schedualList = new List <payment_schedual>();

            //SALES INVOICE
            if (obj_entity as sales_invoice != null)
            {
                sales_invoice sales_invoice = (sales_invoice)obj_entity;
                foreach (app_contract_detail app_contract_detail in sales_invoice.app_contract.app_contract_detail.Where(x => x.is_order == false))
                {
                    payment_schedual payment_schedual = new payment_schedual();
                    payment_schedual.credit        = 0;
                    payment_schedual.debit         = sales_invoice.GrandTotal * app_contract_detail.coefficient;
                    payment_schedual.id_currencyfx = sales_invoice.id_currencyfx;
                    payment_schedual.sales_invoice = sales_invoice;
                    payment_schedual.trans_date    = sales_invoice.trans_date;
                    payment_schedual.expire_date   = sales_invoice.trans_date.AddDays(app_contract_detail.interval);
                    payment_schedual.status        = entity.Status.Documents_General.Approved;
                    payment_schedual.id_contact    = sales_invoice.id_contact;
                    payment_schedualList.Add(payment_schedual);

                    ///Checks if selected Contract has Promissory Note created.
                    if (sales_invoice.app_contract.is_promissory)
                    {
                        payment_promissory_note payment_promissory_note = new payment_promissory_note();
                        //Dates. Transactional (based on Sales Trans) and Expiry (based on Exp of Payment)...
                        payment_promissory_note.trans_date  = sales_invoice.trans_date;
                        payment_promissory_note.expiry_date = sales_invoice.trans_date.AddDays(app_contract_detail.interval);
                        //Navigational Properties...
                        payment_promissory_note.id_branch   = sales_invoice.id_branch;
                        payment_promissory_note.id_terminal = sales_invoice.id_terminal;
                        payment_promissory_note.id_company  = sales_invoice.id_company;
                        payment_promissory_note.id_contact  = sales_invoice.id_contact;
                        //Values...
                        payment_promissory_note.value         = sales_invoice.GrandTotal * app_contract_detail.coefficient;
                        payment_promissory_note.id_currencyfx = sales_invoice.id_currencyfx;
                        payment_promissory_note.status        = entity.Status.Documents.Pending;

                        //Create Payment to control the Promissory Note as Non-Calculated.
                        payment_schedual payment_schedual_promise = new payment_schedual();
                        //Debit Credit
                        payment_schedual_promise.credit = 0;
                        payment_schedual_promise.debit  = sales_invoice.GrandTotal * app_contract_detail.coefficient;
                        //Nav Properties
                        payment_schedual_promise.id_contact    = sales_invoice.id_contact;
                        payment_schedual_promise.id_currencyfx = sales_invoice.id_currencyfx;
                        payment_schedual_promise.sales_invoice = sales_invoice;
                        //Date
                        payment_schedual_promise.trans_date    = sales_invoice.trans_date;
                        payment_schedual_promise.expire_date   = sales_invoice.trans_date.AddDays(app_contract_detail.interval);
                        payment_schedual_promise.can_calculate = false;
                        //Pending so that we can Approve while Printing.
                        payment_schedual_promise.status = entity.Status.Documents_General.Pending;

                        //Adding Payment Schedual into PromissoryNote
                        payment_promissory_note.payment_schedual.Add(payment_schedual_promise);
                        payment_promissory_noteLIST.Add(payment_promissory_note);
                    }
                }

                return(payment_schedualList);
            }

            //SALES RETURN
            else if (obj_entity as sales_return != null)
            {
                sales_return sales_return = (sales_return)obj_entity;

                payment_schedual payment_schedual = new payment_schedual();
                payment_schedual.debit         = sales_return.GrandTotal;
                payment_schedual.credit        = 0;
                payment_schedual.id_currencyfx = sales_return.id_currencyfx;
                payment_schedual.sales_return  = sales_return;
                payment_schedual.trans_date    = sales_return.trans_date;
                payment_schedual.expire_date   = sales_return.trans_date;
                payment_schedual.status        = entity.Status.Documents_General.Approved;
                payment_schedual.id_contact    = sales_return.id_contact;
                payment_schedual.can_calculate = false;
                payment_schedualList.Add(payment_schedual);

                return(payment_schedualList);
            }

            //PURCHASE RETURN
            else if (obj_entity as purchase_return != null)
            {
                purchase_return purchase_return = (purchase_return)obj_entity;

                payment_schedual payment_schedual = new payment_schedual();
                payment_schedual.credit          = purchase_return.GrandTotal;
                payment_schedual.debit           = 0;
                payment_schedual.id_currencyfx   = purchase_return.id_currencyfx;
                payment_schedual.purchase_return = purchase_return;
                payment_schedual.trans_date      = purchase_return.trans_date;
                payment_schedual.expire_date     = purchase_return.trans_date;
                payment_schedual.status          = entity.Status.Documents_General.Approved;
                payment_schedual.id_contact      = purchase_return.id_contact;
                payment_schedual.can_calculate   = false;
                payment_schedualList.Add(payment_schedual);

                return(payment_schedualList);
            }


            //SALES ORDER
            else if (obj_entity as sales_order != null)
            {
                sales_order sales_order = (sales_order)obj_entity;

                foreach (app_contract_detail app_contract_detail in sales_order.app_contract.app_contract_detail.Where(x => x.is_order))
                {
                    payment_schedual payment_schedual = new payment_schedual();
                    payment_schedual.credit        = 0;
                    payment_schedual.debit         = sales_order.GrandTotal * app_contract_detail.coefficient;
                    payment_schedual.id_currencyfx = sales_order.id_currencyfx;
                    payment_schedual.sales_order   = sales_order;
                    payment_schedual.trans_date    = sales_order.trans_date;
                    payment_schedual.expire_date   = sales_order.trans_date.AddDays(app_contract_detail.interval);
                    payment_schedual.status        = entity.Status.Documents_General.Approved;
                    payment_schedual.id_contact    = sales_order.id_contact;
                    payment_schedualList.Add(payment_schedual);
                }
                return(payment_schedualList);
            }



            //PURCHASE INVOICE
            else if (obj_entity as purchase_invoice != null)
            {
                purchase_invoice purchase_invoice = (purchase_invoice)obj_entity;

                foreach (app_contract_detail app_contract_detail in purchase_invoice.app_contract.app_contract_detail.Where(x => x.is_order == false))
                {
                    payment_schedual payment_schedual = new payment_schedual();
                    payment_schedual.credit           = purchase_invoice.GrandTotal * app_contract_detail.coefficient;
                    payment_schedual.debit            = 0;
                    payment_schedual.id_currencyfx    = purchase_invoice.id_currencyfx;
                    payment_schedual.purchase_invoice = purchase_invoice;
                    payment_schedual.trans_date       = purchase_invoice.trans_date;
                    payment_schedual.expire_date      = purchase_invoice.trans_date.AddDays(app_contract_detail.interval);
                    payment_schedual.status           = entity.Status.Documents_General.Pending;
                    payment_schedual.id_contact       = purchase_invoice.id_contact;
                    payment_schedualList.Add(payment_schedual);
                }
                return(payment_schedualList);
            }


            //PURCHASE ORDER
            else if (obj_entity as purchase_order != null)
            {
                purchase_order purchase_order = (purchase_order)obj_entity;

                foreach (app_contract_detail app_contract_detail in purchase_order.app_contract.app_contract_detail.Where(x => x.is_order))
                {
                    payment_schedual payment_schedual = new payment_schedual();
                    payment_schedual.credit         = purchase_order.GrandTotal * app_contract_detail.coefficient;
                    payment_schedual.debit          = 0;
                    payment_schedual.id_currencyfx  = purchase_order.id_currencyfx;
                    payment_schedual.purchase_order = purchase_order;
                    payment_schedual.trans_date     = purchase_order.trans_date;
                    payment_schedual.expire_date    = purchase_order.trans_date.AddDays(app_contract_detail.interval);
                    payment_schedual.status         = entity.Status.Documents_General.Pending;
                    payment_schedual.id_contact     = purchase_order.id_contact;
                    payment_schedualList.Add(payment_schedual);
                }
                return(payment_schedualList);
            }

            return(null);
        }
Exemple #29
0
        public List <payment_schedual> revert_Schedual(object obj_entity)
        {
            List <payment_schedual> payment_schedualList = new List <payment_schedual>();

            //SALES INVOICE
            if (obj_entity as sales_invoice != null)
            {
                sales_invoice sales_invoice = (sales_invoice)obj_entity;
                if (sales_invoice.payment_schedual != null)
                {
                    foreach (payment_schedual payment in sales_invoice.payment_schedual)
                    {
                        payment_schedualList.AddRange(update_Status(payment));
                    }
                }
            }
            //SALES ORDER
            else if (obj_entity as sales_order != null)
            {
                sales_order sales_order = (sales_order)obj_entity;
                if (sales_order.payment_schedual != null)
                {
                    foreach (payment_schedual payment in sales_order.payment_schedual)
                    {
                        payment_schedualList.AddRange(update_Status(payment));
                    }
                }
            }
            //PURCHASE INVOICE
            else if (obj_entity as purchase_invoice != null)
            {
                purchase_invoice purchase_invoice = (purchase_invoice)obj_entity;
                if (purchase_invoice.payment_schedual != null)
                {
                    foreach (payment_schedual payment in purchase_invoice.payment_schedual)
                    {
                        payment_schedualList.AddRange(update_Status(payment));
                    }
                }
            }
            //PURCHASE ORDER
            else if (obj_entity as purchase_order != null)
            {
                //If function to liberate paid amount
                purchase_order purchase_order = (purchase_order)obj_entity;
                if (purchase_order.payment_schedual != null)
                {
                    foreach (payment_schedual payment in purchase_order.payment_schedual)
                    {
                        payment_schedualList.AddRange(update_Status(payment));
                    }
                }
            }
            //PURCHASE RETURN
            else if (obj_entity as purchase_return != null)
            {
                //If function to liberate paid amount
                purchase_return purchase_return = (purchase_return)obj_entity;
                if (purchase_return.payment_schedual != null)
                {
                    foreach (payment_schedual payment in purchase_return.payment_schedual)
                    {
                        payment_schedualList.AddRange(update_Status(payment));
                    }
                }
            }
            //SALES RETURN
            else if (obj_entity as sales_return != null)
            {
                //If function to liberate paid amount
                sales_return sales_return = (sales_return)obj_entity;
                if (sales_return.payment_schedual != null)
                {
                    foreach (payment_schedual payment in sales_return.payment_schedual)
                    {
                        payment_schedualList.AddRange(update_Status(payment));
                    }
                }
            }

            return(payment_schedualList);
        }