Esempio n. 1
0
 public void EnsureCompatibleUnit(IExtendedMaterialModel material, IMaterialUnit unit)
 {
     if (!m_conversionHelper.AreCompatible(material.NominalUnit.Id, unit.Id))
     {
         throw new InvalidOperationException($"Jednotku '{unit.Symbol}' nelze použít pro materiál '{material.Name}'");
     }
 }
Esempio n. 2
0
 public MaterialComponent(IMaterialUnit unit, IExtendedMaterialModel material, decimal amount, int?compositionId)
 {
     Unit          = unit;
     Material      = material;
     Amount        = amount;
     CompositionId = compositionId;
 }
Esempio n. 3
0
 public CompositionViewModel(IExtendedMaterialModel material, decimal amount, IMaterialUnit unit, int depth)
 {
     Material = material;
     Amount   = amount;
     Unit     = unit;
     Depth    = depth;
 }
Esempio n. 4
0
 private IMaterialThreshold CreateFakeThreshold(IExtendedMaterialModel material, Amount amount)
 {
     return(new DefaultThreshold()
     {
         Material = material.Adaptee,
         MaterialId = material.Id,
         Unit = amount.Unit,
         UnitId = amount.Unit.Id,
         ThresholdQuantity = amount.Value * 2m
     });
 }
Esempio n. 5
0
        private MaterialSetupInfo MapMaterialInfo(IExtendedMaterialModel material, List <string> takenNames = null)
        {
            var model = new MaterialSetupInfo
            {
                MaterialId                = material.Id,
                PreferredUnitSymbol       = material.Adaptee.NominalUnit.Symbol,
                IsManufactured            = material.IsManufactured,
                MaterialName              = material.Name,
                RequiresInvoice           = material.RequiresInvoice,
                RequiresPrice             = material.RequiresInvoice,
                AutomaticBatches          = material.AutomaticBatches,
                RequiresSupplierReference = material.RequiresSupplierReference,
                Autofinalization          = material.Autofinalization,
                CanBeDigital              = material.CanBeDigital
            };

            if (material.AutomaticBatches)
            {
                var baseName      = $"{StringUtil.ConvertToBaseText(material.Name, '_', '_', 3)}_{DateTime.Now:yyyyMMdd}";
                var versionedName = baseName;

                if (takenNames != null && !takenNames.Contains(versionedName))
                {
                    model.AutoBatchNr = versionedName;
                }
                else
                {
                    for (var i = 1;; i++)
                    {
                        var e =
                            m_database.SelectFrom <IMaterialBatch>()
                            .Where(b => b.BatchNumber == versionedName)
                            .Take(1)
                            .Execute()
                            .FirstOrDefault();
                        if (e == null)
                        {
                            break;
                        }

                        versionedName = $"{baseName}.{i}";
                    }

                    model.AutoBatchNr = versionedName;
                }

                takenNames?.Add(versionedName);
            }

            return(model);
        }
Esempio n. 6
0
 public MaterialInfo(IExtendedMaterialModel m)
 {
     Id   = m.Id;
     Name = m.Name;
 }
Esempio n. 7
0
 public MaterialCompositionInfo(IExtendedMaterialModel m)
     : base(m)
 {
 }