/// <summary> /// Exports the specified entities. /// </summary> /// <param name="entities">The entities.</param> /// <param name="closingBatch">if set to <c>true</c> [closing batch].</param> /// <param name="invoiceContent">Content of the invoice.</param> /// <param name="disposals">The disposals.</param> /// <param name="sadConsignmentNumber">The sad consignment number.</param> /// <param name="trace">The trace.</param> /// <exception cref="CAS.SmartFactory.IPR.WebsiteModel.InputDataValidationException">internal error: it is impossible to mark as exported the material;Material export;false</exception> /// <exception cref="CAS">internal error: it is impossible to mark as exported the material; Material export; false</exception> public void Export(Entities entities, bool closingBatch, InvoiceContent invoiceContent, List <Disposal> disposals, int sadConsignmentNumber, NamedTraceLogger.TraceAction trace) { trace("Entering Material.Export", 251, TraceSeverity.Verbose); decimal _quantity = this.CalculatedQuantity(invoiceContent); foreach (Disposal _disposalX in this.GetListOfDisposals(entities)) { if (!closingBatch && _quantity == 0) { break; } _disposalX.Export(entities, ref _quantity, closingBatch, invoiceContent, sadConsignmentNumber, _disposal => _disposal.Disposal2IPRIndex.RecalculateLastStarted(entities, _disposal, trace)); disposals.Add(_disposalX); } if (closingBatch || _quantity == 0) { return; } string _error = String.Format( "There are {0} kg of material {1}/Id={2} that cannot be found for invoice {3}/Content Id={4}.", _quantity, this.Batch, this.Id, invoiceContent.InvoiceIndex.BillDoc, invoiceContent.Id.Value); trace("InputDataValidationException at Material.Export: " + _error, 265, TraceSeverity.High); throw new InputDataValidationException("internal error: it is impossible to mark as exported the material", "Material export", _error, false); }
internal void ClearThroughCustom(InvoiceContent value, Action <Disposal> reCalculate) { if (value == null) { throw new ArgumentNullException("value", "At ClearThroughCustom value cannot be null"); } this.Disposal2InvoiceContentIndex = value; this.Clearance = value.InvoiceIndex.ClearenceIndex; this.CustomsStatus = Linq.CustomsStatus.Started; this.InvoiceNo = value.InvoiceIndex.BillDoc; reCalculate(this); }
/// <summary> /// Creates the title. /// </summary> /// <param name="invoice">The invoice.</param> public static void CreateTitle(this InvoiceContent invoice) { string _tmplt = "{0}/{1} SKU:{2}/Batch:{3}"; string _sku = "N/A"; string _batch = "N/A"; if (invoice.InvoiceContent2BatchIndex != null) { _batch = invoice.InvoiceContent2BatchIndex.Batch0; if (invoice.InvoiceContent2BatchIndex.SKUIndex != null) { _sku = invoice.InvoiceContent2BatchIndex.SKUIndex.SKU; } } invoice.Title = String.Format(_tmplt, invoice.Id.Value, invoice.InvoiceIndex.BillDoc, _sku, _batch); }
internal void AddDisposal(Entities edc, DisposalEnum kind, ref decimal toDispose, Material material, InvoiceContent invoiceContent, NamedTraceLogger.TraceAction trace) { trace("Entering IPR.AddDisposal", 421, TraceSeverity.Verbose); Disposal _dsp = AddDisposal(edc, kind, ref toDispose); _dsp.Material = material; _dsp.ClearThroughCustom(invoiceContent, _x => { }); SADGood _sg = invoiceContent.InvoiceIndex.ClearenceIndex.Clearence2SadGoodID; if (_sg != null) { _dsp.FinishClearingThroughCustoms(edc, _sg, trace); } }
internal void AddNewDisposals(Entities edc, Linq.DisposalEnum _kind, ref decimal _toDispose, InvoiceContent invoiceContent, SharePoint.Logging.NamedTraceLogger.TraceAction trace) { trace("Entering Material.AddNewDisposals", 421, TraceSeverity.Verbose); foreach (IPR _iprx in this.Accounts2Dispose) { if (_iprx.TobaccoNotAllocated <= 0) { continue; } _iprx.AddDisposal(edc, _kind, ref _toDispose, this, invoiceContent, trace); if (_toDispose <= 0) { break; } } }
/// <summary> /// Get portion of calculated tobacco quantity. /// </summary> /// <param name="invoice">The invoice.</param> /// <returns> /// Returns portion of calculated tobacco quantity. i.e. after removing compensation wast, dust, SHMethol, etc. /// </returns> public decimal CalculatedQuantity(InvoiceContent invoice) { return((this.Tobacco.Value * invoice.Quantity.Value / this.Material2BatchIndex.FGQuantity.Value).Round2Double()); }
/// <summary> /// Exports the specified entities. /// </summary> /// <param name="entities">The entities.</param> /// <param name="quantity">The quantity.</param> /// <param name="closingBatch">if set to <c>true</c> the batch is to be closed.</param> /// <param name="invoiceContent">Content of the invoice.</param> /// <param name="sadConsignmentNumber">The sad consignment number.</param> /// <param name="reCalculate">The recalculate delegate is used to adjust VAT, duty and value for last started disposal.</param> /// <exception cref="ApplicationError">if any internal exception has to be cough.</exception> internal void Export(Entities entities, ref decimal quantity, bool closingBatch, InvoiceContent invoiceContent, int sadConsignmentNumber, Action <Disposal> reCalculate) { string _at = "Starting"; try { if (!closingBatch) { if (quantity < this.SettledQuantityDec) { _at = "_newDisposal"; Disposal _newDisposal = new Disposal(Disposal2IPRIndex, DisposalStatus.Value, this.SettledQuantityDec - quantity); _newDisposal.Material = this.Disposal2MaterialIndex; this.SettledQuantityDec = quantity; quantity = 0; _at = "InsertOnSubmit"; entities.Disposal.InsertOnSubmit(_newDisposal); reCalculate = x => { }; } else { quantity -= this.SettledQuantityDec; } } _at = "ClearThroughCustom"; this.ClearThroughCustom(invoiceContent, reCalculate); this.SadConsignmentNo = SADConsignment.DocumentNumber(entities, sadConsignmentNumber); } catch (Exception _ex) { throw new ApplicationError(@"CAS.SmartFactory.IPR.WebsiteModel.Linq.Disposal.Export", _at, _ex.Message, _ex); } }