public ReportClass GetWorkDeliveryList(OutputDeliveryList list, ExpedienteList expedients)
        {
            if (list.Count == 0)
            {
                return(null);
            }

            OutputDeliveryListRpt doc = new OutputDeliveryListRpt();

            List <OutputDeliveryPrint> pList = new List <OutputDeliveryPrint>();

            foreach (OutputDeliveryInfo item in list)
            {
                pList.Add(OutputDeliveryPrint.New(item, expedients.GetItem(item.OidHolder)));
            }

            doc.SetDataSource(pList);

            FormatHeader(doc);

            ((TextObject)doc.Section2.ReportObjects["IDHolder_LB"]).Text          = Library.Store.Resources.Labels.WORK_ID;
            ((TextObject)doc.Section2.ReportObjects["Holder_LB"]).Text            = Library.Store.Resources.Labels.WORK;
            doc.Section2.ReportObjects["NFactura_LB"].ObjectFormat.EnableSuppress = true;

            return(doc);
        }
示例#2
0
        protected void SelectProducto()
        {
            BatchList lista = BatchList.GetListByFamiliaNoKits(_familia.Oid, false);

            BatchSelectForm form = new BatchSelectForm(this, null, lista);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                _batch     = form.Selected as BatchInfo;
                _expedient = (_batch.OidExpediente == 1) ? _almacen : _expedientes.GetItem(_batch.OidExpediente);
                Datos_Partida.DataSource = _batch;
            }
        }
        protected override void PrintAction()
        {
            PgMng.Reset(5, 1, Face.Resources.Messages.RETRIEVING_DATA, this);

            Library.Invoice.QueryConditions conditions = new Library.Invoice.QueryConditions();

            conditions.Cliente   = TodosCliente_CkB.Checked ? null : _cliente;
            conditions.Serie     = TodosSerie_CkB.Checked ? null : _serie;
            conditions.MedioPago = MedioPago_CB.SelectedValue != null ? (EMedioPago)(long)MedioPago_CB.SelectedValue : EMedioPago.Todos;
            conditions.FechaIni  = FInicial_DTP.Checked ? FInicial_DTP.Value : DateTime.MinValue;
            conditions.FechaFin  = FFinal_DTP.Checked ? FFinal_DTP.Value : DateTime.MaxValue;

            string filter = GetFilterValues();

            PgMng.Grow();

            OutputInvoiceList in_invoices = OutputInvoiceList.GetList(conditions, false);

            PgMng.Grow();
            ProductList products = ProductList.GetList(false);

            PgMng.Grow();
            ExpedienteList expedients = ExpedienteList.GetList(false);

            PgMng.FillUp();

            PgMng.Reset(in_invoices.Count + 2, 1, Face.Resources.Messages.RETRIEVING_DATA, this);

            Dictionary <long, ClientProductList> client_products = new Dictionary <long, ClientProductList>();

            foreach (OutputInvoiceInfo in_invoice in in_invoices)
            {
                in_invoice.LoadChilds(typeof(OutputInvoiceLine), false);

                decimal invoice_cost = 0;

                foreach (OutputInvoiceLineInfo line in in_invoice.ConceptoFacturas)
                {
                    ProductInfo product = products.GetItem(line.OidProducto);

                    if (product.BeneficioCero)
                    {
                        if (!client_products.ContainsKey(in_invoice.OidCliente))
                        {
                            client_products.Add(in_invoice.OidCliente, ClientProductList.GetByClientList(in_invoice.OidCliente, false));
#if TRACE
                            AppControllerBase.AppControler.Timer.Record("Productos del Cliente");
#endif
                        }
                        ProductoClienteInfo product_client = client_products[in_invoice.OidCliente].GetByProducto(line.OidProducto);

                        if (product_client != null)
                        {
                            invoice_cost += product_client.PrecioCompra;
                        }
                        else
                        {
                            invoice_cost += line.Subtotal;
                        }
                    }
                    else
                    {
                        if (line.OidPartida != 0)
                        {
                            ExpedientInfo expedient = expedients.GetItem(line.OidExpediente);

                            if (expedient != null)
                            {
                                if (expedient.Partidas == null)
                                {
                                    expedient.LoadExpenses(Estimated_CB.Checked);
#if TRACE
                                    AppControllerBase.AppControler.Timer.Record("Gastos del Expediente");
#endif
                                }

                                BatchInfo batch = expedient.Partidas.GetItem(line.OidPartida);
                                invoice_cost += line.CantidadKilos * batch.CosteNetoKg;
                            }
                            else
                            {
                                invoice_cost += line.CantidadKilos * product.PrecioCompra;
                            }
                        }
                        else
                        {
                            invoice_cost += (product != null) ? line.CantidadKilos * product.PrecioCompra : 0;
                        }
                    }
                }

                in_invoice.PrecioCoste = invoice_cost;
                in_invoice.Beneficio   = Decimal.Round(in_invoice.BaseImponible - in_invoice.PrecioCoste, 2);
                in_invoice.PBeneficio  = in_invoice.PrecioCoste != 0 ? Decimal.Round(((in_invoice.BaseImponible - in_invoice.PrecioCoste) * 100) / in_invoice.PrecioCoste, 2) : 0;

                PgMng.Grow();
            }

            client_products.Clear();

            PgMng.Grow(Face.Resources.Messages.BUILDING_REPORT);

            OutputInvoiceReportMng reportMng = new OutputInvoiceReportMng(AppContext.ActiveSchema, this.Text, filter);
            ReportClass            rpt       = reportMng.GetBenefitsReport(in_invoices);
            PgMng.FillUp();

            ShowReport(rpt);

            _action_result = DialogResult.Ignore;
        }