Пример #1
0
        private void ProcessProduct(int takeoffRow, IWorksheet soq, ProductWapper product)
        {
            var soqRow = soq.Rows.Last + 1;

            if (!product.Sku.Equals("9000099") && !product.Sku.Equals("9000999"))
            {
                soq.Rows[soqRow].Columns[SOQ.COLUMN.Sku].Value         = product.Sku;
                soq.Rows[soqRow].Columns[SOQ.COLUMN.Description].Value = product.Description;
                soq.Rows[soqRow].Columns[SOQ.COLUMN.Rate].Value        = Equals(product.Retail, 0.0) ? "" : $"{product.Retail:0.00}";

                var discount = GetDouble(product.Discount?.ToString(), 0.0);

                soq.Rows[soqRow].Columns[SOQ.COLUMN.Discount].Value       = Equals(discount, 0.0) ? "" : $"{discount:0.00}";
                soq.Rows[soqRow].Columns[SOQ.COLUMN.NetRate].Value        = "=G" + soqRow + "-H" + soqRow + "*G" + soqRow;
                soq.Rows[soqRow].Columns[SOQ.COLUMN.NetRate].NumberFormat = "0.00";
                soq.Rows[soqRow].Columns[SOQ.COLUMN.Amount].Value         = "=E" + soqRow + "*I" + soqRow;
                soq.Rows[soqRow].Columns[SOQ.COLUMN.Amount].NumberFormat  = "0.00";
            }

            soq.Rows[soqRow].Columns[SOQ.COLUMN.Notes].Value = Worksheet.Rows[takeoffRow].Columns[TAKEOFF.COLUMN.Notes].Value;

            double qty         = GetDouble(Worksheet.Rows[takeoffRow].Columns[TAKEOFF.COLUMN.Quantity].Value?.ToString(), 1.0);
            var    factoredQty = GetDouble((product.MattFactor * qty).ToString(CultureInfo.InvariantCulture), 1 * qty);

            var factoredQtyStr = $"{factoredQty:0.0}";

            soq.Rows[soqRow].Columns[SOQ.COLUMN.FactoredQuantity].Value = factoredQtyStr;
            soq.Rows[soqRow].Columns[SOQ.COLUMN.Unit].Value             = product.SUnit;
        }
Пример #2
0
        public async Task <ProductWapper> GetProductBySkuAsync(string sku)
        {
            var product = await _database.GetRowsAsync("product", new Dictionary <string, dynamic>
            {
                { "sku", sku },
                { "is_deleted", 0 }
            });

            if (product.Count == 0)
            {
                return(null);
            }

            var productWrapper = new ProductWapper(
                new Product
            {
                Id          = product[0]["product_id"],
                Sku         = product[0]["sku"],
                Description = product[0]["description"],
                Retail      = (double)product[0]["retail"],
                Discount    = (double?)(product[0]["discount"] is double?product[0]["discount"] : null),
                Cost        = (double?)(product[0]["cost"] is double?product[0]["cost"] : null),
                Date        = Convert.ToDateTime(product[0]["last_updated"]).Date,
                MUnit       = await GetUnitAsync(product[0], Unit.M),
                SUnit       = await GetUnitAsync(product[0], Unit.S),
                MattFactor  = (double)product[0]["mat_factor"],
                Waste       = (double?)(product[0]["waste"] is double?product[0]["waste"] : null),
                Cover       = (double?)(product[0]["cover"] is double?product[0]["cover"] : null),
                Notes       = product[0]["notes"].ToString(),
                LRate       = (double?)(product[0]["l_rate"] is double?product[0]["l_rate"] : null),
                RoundFactor = (double?)(product[0]["round_factor"] is double?product[0]["round_factor"] : null),
                Retail16    = (double?)(product[0]["retail16"] is double?product[0]["retail16"] : null)
            });

            return(productWrapper);
        }