public ItemReleaseModel(DateTime date, IMaterialBatch tookFromBatch, Amount tookAmount, TItemDescriptor descriptor) { Date = date; TookFromBatch = tookFromBatch; TookAmount = tookAmount; Descriptor = descriptor; }
public bool Match(IMaterialBatch batch, IBatchKeyResolver repo) { EnsureLoaded(repo); return(batch.MaterialId == m_materialId && batch.BatchNumber.Equals(m_batchNumber, StringComparison.InvariantCultureIgnoreCase)); }
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)); }
private MaterialBatchComponent MapToModel(IMaterialBatch entity) { if (entity == null) { return(null); } var model = new MaterialBatchComponent(new MaterialBatchAdapter(entity, m_serviceLocator), this); return(model); }
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); }
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; }
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")); }
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); }); }
protected virtual string GetFormItemNote(IMaterialBatch batch) { return($"{batch.Material.Name} {batch.GetUnid()}"); }
protected abstract void CustomizeFormMapping(IMaterialBatch referenceBatch, IInvoiceForm form, IInvoiceFormGenerationContext context);
protected abstract void CustomizeItemMapping(IInvoiceForm form, IInvoiceFormItem item, IMaterialBatch batch, IInvoiceFormGenerationContext context);
protected override void CustomizeFormMapping(IMaterialBatch referenceBatch, IInvoiceForm form, IInvoiceFormGenerationContext context) { }
public static string GetUnid(this IMaterialBatch batch) { return($"{batch.BatchNumber}.{batch.Id}"); }
public BatchAccountingDate GetBatchAccountingDate(IMaterialBatch batch) { return(new BatchAccountingDate(batch.Created)); }
public void ReleaseBatchAmountCache(IMaterialBatch batch) { ReleaseBatchAmountCache(batch.Id); }
public static string GetTextInfo(this IMaterialBatch batch) { return(string.Join(" ", GetBatchInfo(batch))); }
public IInvoiceFormItem NewFormItem(IInvoiceForm form, IMaterialBatch batch, Action <IInvoiceFormItem> setup) { return(m_invoiceFormsRepository.NewItem(form, batch.Id, setup)); }
public BatchPrice(IMaterialBatch batch) { Batch = batch; BatchNumber = batch.BatchNumber; }