コード例 #1
0
 public ItemReleaseModel(DateTime date, IMaterialBatch tookFromBatch, Amount tookAmount, TItemDescriptor descriptor)
 {
     Date          = date;
     TookFromBatch = tookFromBatch;
     TookAmount    = tookAmount;
     Descriptor    = descriptor;
 }
コード例 #2
0
        public bool Match(IMaterialBatch batch, IBatchKeyResolver repo)
        {
            EnsureLoaded(repo);

            return(batch.MaterialId == m_materialId &&
                   batch.BatchNumber.Equals(m_batchNumber, StringComparison.InvariantCultureIgnoreCase));
        }
コード例 #3
0
        public Tuple <decimal, BatchPrice> GetPriceOfAmount(IMaterialBatch batch, Amount amount, IBatchPriceBulkProvider provider)
        {
            var batchPrice = GetBatchPrice(batch, provider);

            var totalAmount  = m_conversionHelper.ConvertAmount(new Amount(batchPrice.Batch.Volume, m_unitRepository.GetUnit(batchPrice.Batch.UnitId)), amount.Unit.Id);
            var pricePerUnit = batchPrice.TotalPriceInPrimaryCurrency / totalAmount.Value;

            return(new Tuple <decimal, BatchPrice>(pricePerUnit * amount.Value, batchPrice));
        }
コード例 #4
0
        private MaterialBatchComponent MapToModel(IMaterialBatch entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new MaterialBatchComponent(new MaterialBatchAdapter(entity, m_serviceLocator), this);

            return(model);
        }
コード例 #5
0
        public BatchPrice GetBatchPrice(IMaterialBatch batch, IBatchPriceBulkProvider provider)
        {
            var compos = provider.GetBatchPriceComponents(batch.Id);

            var bp = new BatchPrice(batch);

            foreach (var c in compos)
            {
                bp.AddComponent(c.IsWarning, c.SourceBatchId, c.Text, c.RawValue);
            }

            return(bp);
        }
コード例 #6
0
 public MaterialBatchViewModel(IMaterialBatch batch, ISupplierRepository suppliers)
 {
     Id               = batch.Id;
     MaterialName     = batch.Material.Name;
     Volume           = batch.Volume;
     UnitName         = batch.Unit.Symbol;
     AuthorName       = batch.Author.EMail;
     BatchNumber      = batch.BatchNumber;
     DisplayDt        = StringUtil.FormatDateTime(batch.Created);
     SortDt           = batch.Created.Ticks;
     Price            = batch.Price;
     InvoiceNumber    = batch.InvoiceNr;
     MaterialId       = batch.MaterialId;
     AutomaticBatches = batch.Material.AutomaticBatches;
     SupplierName     = batch.SupplierId == null ? null : suppliers.GetSupplier(batch.SupplierId.Value)?.Name;
     VariableSymbol   = batch.InvoiceVarSymbol;
 }
コード例 #7
0
        private static IEnumerable <string> GetBatchInfo(IMaterialBatch b)
        {
            if (b == null)
            {
                yield break;
            }

            if (!string.IsNullOrWhiteSpace(b.BatchNumber))
            {
                yield return(b.GetUnid());
            }
            else
            {
                yield return($"sysID:{b.Id}");
            }

            if (b.Unit != null)
            {
                yield return($"{b.Volume}{b.Unit.Symbol}");
            }

            if (b.Material != null)
            {
                yield return($"{b.Material.Name}");
            }

            if (!string.IsNullOrWhiteSpace(b.InvoiceNr))
            {
                yield return($"f.:{b.InvoiceNr}");
            }

            if (!string.IsNullOrWhiteSpace(b.InvoiceVarSymbol))
            {
                yield return($"vs.:{b.InvoiceVarSymbol}");
            }

            yield return(b.Created.ToString("dd.MM.yyyy"));
        }
コード例 #8
0
        public MaterialBatchComponent(IMaterialBatch batch, IMaterialBatchRepository batchRepository)
        {
            Batch    = batch;
            IsLocked = batch.LockDt != null && batch.LockDt <= DateTime.Now;
            IsClosed = batch.CloseDt != null && batch.CloseDt <= DateTime.Now;

            ComponentUnit   = batch.Unit;
            ComponentAmount = batch.Volume;

            m_components = new Lazy <List <MaterialBatchComponent> >(() =>
            {
                var result = new List <MaterialBatchComponent>();
                foreach (var component in batch.Components)
                {
                    var componentModel             = batchRepository.GetBatchById(component.ComponentId);
                    componentModel.ComponentAmount = component.Volume;
                    componentModel.ComponentUnit   = component.Unit;
                    result.Add(componentModel);
                }

                return(result);
            });
        }
コード例 #9
0
 protected virtual string GetFormItemNote(IMaterialBatch batch)
 {
     return($"{batch.Material.Name} {batch.GetUnid()}");
 }
コード例 #10
0
 protected abstract void CustomizeFormMapping(IMaterialBatch referenceBatch,
                                              IInvoiceForm form,
                                              IInvoiceFormGenerationContext context);
コード例 #11
0
 protected abstract void CustomizeItemMapping(IInvoiceForm form, IInvoiceFormItem item, IMaterialBatch batch, IInvoiceFormGenerationContext context);
コード例 #12
0
 protected override void CustomizeFormMapping(IMaterialBatch referenceBatch, IInvoiceForm form, IInvoiceFormGenerationContext context)
 {
 }
コード例 #13
0
 public static string GetUnid(this IMaterialBatch batch)
 {
     return($"{batch.BatchNumber}.{batch.Id}");
 }
コード例 #14
0
 public BatchAccountingDate GetBatchAccountingDate(IMaterialBatch batch)
 {
     return(new BatchAccountingDate(batch.Created));
 }
コード例 #15
0
 public void ReleaseBatchAmountCache(IMaterialBatch batch)
 {
     ReleaseBatchAmountCache(batch.Id);
 }
コード例 #16
0
 public static string GetTextInfo(this IMaterialBatch batch)
 {
     return(string.Join(" ", GetBatchInfo(batch)));
 }
コード例 #17
0
 public IInvoiceFormItem NewFormItem(IInvoiceForm form, IMaterialBatch batch, Action <IInvoiceFormItem> setup)
 {
     return(m_invoiceFormsRepository.NewItem(form, batch.Id, setup));
 }
コード例 #18
0
ファイル: BatchPrice.cs プロジェクト: MichalTecl/Elsa
 public BatchPrice(IMaterialBatch batch)
 {
     Batch       = batch;
     BatchNumber = batch.BatchNumber;
 }