private static void ExportInvoiceEntry (Entities entities, InvoiceContent invoice, List <CigaretteExportForm> formsList, string documentName, ref int subdocumentNo, int sadConsignmentNumber, NamedTraceLogger.TraceAction trace) { trace("Entering FinishedGoodsFormFactory.ExportInvoiceEntry", 141, Microsoft.SharePoint.Administration.TraceSeverity.Verbose); string _at = "beginning"; Batch batch = invoice.InvoiceContent2BatchIndex; try { bool _closingBatch = batch.FGQuantityAvailable == invoice.Quantity.Value; _at = "FGQuantityAvailable"; batch.FGQuantityAvailable = Convert.ToDouble(Convert.ToDecimal(batch.FGQuantityAvailable.Value) - Convert.ToDecimal(invoice.Quantity.Value)); List <Ingredient> _ingredients = new List <Ingredient>(); _at = "foreach"; foreach (Material _materialIdx in batch.Material(entities, false)) { ExportMaterial(entities, _materialIdx, _ingredients, _closingBatch, invoice, sadConsignmentNumber, trace); } _at = "_exportConsignment"; CigaretteExportForm _form = GetCigaretteExportForm(batch, invoice, _ingredients, documentName, ref subdocumentNo, invoice.InvoiceIndex.ClearenceIndex.ClearenceProcedure.Value); formsList.Add(_form); } catch (ApplicationError _ar) { throw _ar; } catch (Exception _ex) { string _ms = "Cannot proceed with export of Batch: {0} because of error: {1}."; _ms = String.Format(_ms, batch.Batch0, _ex.Message); trace("ApplicationError at FinishedGoodsFormFactory.ExportInvoiceEntry: " + _ms + "StackTrace: " + _ex.StackTrace, 141, TraceSeverity.Verbose); throw new ApplicationError("Batch.Export", _at, _ms, _ex); } }
/// <summary> /// Displays purchase documents that were not found/moved /// </summary> private void DisplayMissingDocsButton_Click(object sender, EventArgs e) { if (InvoiceContent != null) { DisplayMissingDocumentsText(InvoiceContent.Where(d => d.FileWasMoved == false).ToList()); } }
internal static CigaretteExportForm GetCigaretteExportForm(Batch batch, InvoiceContent invoice, List <Ingredient> ingredients, string documentName, ref int subdocumentNo, ClearenceProcedure procedure) { double _portion = invoice.Quantity.Value / batch.FGQuantity.Value; CigaretteExportForm _ret = new CigaretteExportForm(); if (batch == null) { throw new ArgumentNullException("Batch cannot be null"); } if (batch.SKUIndex == null) { throw new ArgumentNullException("SKU in batch cannot be null"); } if (invoice == null) { throw new ArgumentNullException("Invoice cannot be null"); } _ret.DocumentNo = String.Format(GlobalDefinitions.CigaretteExportFormNamePatern, documentName, subdocumentNo++); _ret.DustKg = (batch.Dust.GetValueOrDefault(-1) * _portion).RountMass(); CountExportFormTotals(ingredients, _ret); _ret.Portion = _portion; _ret.CustomsProcedure = Entities.ToString(procedure); _ret.FinishedGoodBatch = batch.Batch0; //TODO Must be calculated depending on commodity or unit. _ret.FinishedGoodQantity = invoice.Quantity.GetValueOrDefault(0); _ret.FinishedGoodUnit = invoice.Units.GetLocalizedString(); _ret.FinishedGoodSKU = batch.SKUIndex.SKU; _ret.FinishedGoodSKUDescription = batch.SKUIndex.Title(); _ret.MaterialTotal = (batch.Tobacco.GetValueOrDefault(-1) * _portion).RountMass(); _ret.ProductFormat = batch.SKUIndex.FormatIndex.Title(); _ret.CTFUsageMin = batch.CFTProductivityRateMin.GetValueOrDefault(-1) * 100; _ret.CTFUsageMax = batch.CFTProductivityRateMax.GetValueOrDefault(-1) * 100; _ret.CTFUsagePerUnitMin = batch.CFTProductivityRateMin.GetValueOrDefault(-1); _ret.CTFUsagePerUnitMax = batch.CFTProductivityRateMax.GetValueOrDefault(-1); _ret.CTFUsagePer1MFinishedGoodsMin = batch.CTFUsageMin.GetValueOrDefault(-1); _ret.CTFUsagePer1MFinishedGoodsMax = batch.CTFUsageMax.GetValueOrDefault(-1); _ret.WasteCoefficient = batch.BatchWasteCooeficiency.GetValueOrDefault(-1) + batch.BatchDustCooeficiency.GetValueOrDefault(-1); switch (batch.ProductType.Value) { case CAS.SmartFactory.IPR.WebsiteModel.Linq.ProductType.Cutfiller: _ret.Product = xml.DocumentsFactory.CigaretteExportForm.ProductType.Cutfiller; break; case CAS.SmartFactory.IPR.WebsiteModel.Linq.ProductType.Cigarette: SKUCigarette _skuCigarette = batch.SKUIndex as SKUCigarette; _ret.BrandDescription = _skuCigarette.Brand; _ret.FamilyDescription = _skuCigarette.Family; _ret.Product = xml.DocumentsFactory.CigaretteExportForm.ProductType.Cigarette; break; default: throw new ApplicationError("InvoiceLib.CigaretteExportForm", "Product", "Wrong ProductType", null); } _ret.SHMentholKg = (batch.SHMenthol.GetValueOrDefault(-1) * _portion).RountMass(); _ret.WasteKg = (batch.Waste.GetValueOrDefault(-1) * _portion).RountMass(); _ret.IPRRestMaterialQantityTotal = _ret.DustKg + _ret.SHMentholKg + _ret.WasteKg; _ret.TobaccoTotal = (_ret.IPTMaterialQuantityTotal + _ret.RegularMaterialQuantityTotal + _ret.IPRRestMaterialQantityTotal).RountMass(); return(_ret); }
/// <summary> /// Moves the purchase invoices to the selected folder /// </summary> private void MovePurchasingInvoicesButton_Click(object sender, EventArgs e) { if (AllProductInvoices != null && InvoiceContent != null && SearchDirectoryPath != "" && MoveFilesDirectoryPath != "") { fileHandler.MoveDocuments(AllProductInvoices, InvoiceContent, SearchDirectoryPath, MoveFilesDirectoryPath); } if (InvoiceContent != null) { DisplayMissingDocumentsText(InvoiceContent.Where(d => d.FileWasMoved == false).ToList()); } }
protected override GenericStateMachineEngine.ActionResult Delete() { try { InvoiceContent _invc = Parent.m_ControlState.InvoiceContent; Parent.m_ControlState.ClearInvoiceContent(); Parent.m_DataContextManagement.DataContext.InvoiceContent.DeleteOnSubmit(_invc); Parent.m_DataContextManagement.DataContext.SubmitChanges(); } catch (Exception ex) { return(GenericStateMachineEngine.ActionResult.Exception(ex, "Delete")); } return(GenericStateMachineEngine.ActionResult.Success); }
private void Show(InvoiceLib invoice, InvoiceContent invoiceContent, Batch batch) { m_InvoiceTextBox.Text = invoice == null?String.Empty.NotAvailable() : invoice.Title; if (invoiceContent != null) { m_InvoiceContentTextBox.Text = invoiceContent.Title; m_InvoiceQuantityTextBox.Text = m_ControlState.InvoiceContent.Quantity.Value.ToString(CultureInfo.CurrentCulture); } else { m_InvoiceContentTextBox.Text = String.Empty.NotAvailable(); m_InvoiceQuantityTextBox.Text = String.Empty; } m_BatchTextBox.Text = batch == null?String.Empty.NotAvailable() : batch.Title; }
/// <summary> /// 下单发票信息 /// </summary> /// <param name="invoiceState">开票方式</param> /// <param name="invoiceType"> /// 发票类型 /// <para>当 <paramref name="invoiceType"/> 为 <see cref="InvoiceType.VAT"/> /// 增值税专用发票时,开票方式 <paramref name="invoiceState"/> 只支持 /// <see cref="InvoiceState.Centralized"/> 集中开票)</para> /// </param> /// <param name="selectedInvoiceTitle">发票类型</param> /// <param name="invoiceContent">发票内容</param> /// <param name="invoicePhone">收票人电话</param> /// <param name="regCompanyName">专票资质公司名称</param> /// <param name="regCode">专票资质纳税人识别号</param> /// <param name="companyName"> /// 发票抬头 /// <para>如果 <paramref name="selectedInvoiceTitle"/> 为 /// <see cref="InvoiceTitle.Company"/> 时此字段必须</para> /// </param> public OrderInvoice( InvoiceState invoiceState, InvoiceType invoiceType, InvoiceTitle selectedInvoiceTitle, InvoiceContent invoiceContent, string invoicePhone, string regCompanyName, string regCode, string companyName = default) { this.KV = new Dictionary <string, string> { { "invoiceState", ((int)invoiceState).ToString() }, { "invoiceType", ((int)invoiceType).ToString() }, { "selectedInvoiceTitle", ((int)selectedInvoiceTitle).ToString() }, { "invoiceContent", ((int)invoiceContent).ToString() }, { "companyName", companyName }, { "invoicePhone", invoicePhone }, { "regCompanyName", regCompanyName }, { "regCode", regCode }, }; }
protected override GenericStateMachineEngine.ActionResult Create() { try { List <string> _errors = new List <string>(); double? _nq = Parent.m_InvoiceQuantityTextBox.TextBox2Double(_errors); if (_errors.Count > 0) { return(ActionResult.NotValidated(_errors[0])); } if (_nq.HasValue && _nq.Value < 0) { return(ActionResult.NotValidated (String.Format(Resources.NegativeValueNotAllowed.GetLocalizedString(), Parent.m_InvoiceQuantityLabel.Text))); } Batch _batch = Parent.m_ControlState.Batch; InvoiceLib _invc = Parent.m_ControlState.Invoice; if (!_batch.Available(_nq.Value)) { string _tmplt = Resources.QuantityIsUnavailable.GetLocalizedString(); return(ActionResult.NotValidated(String.Format(CultureInfo.CurrentCulture, _tmplt, _batch.AvailableQuantity()))); } InvoiceContent _nic = new InvoiceContent() { InvoiceContent2BatchIndex = _batch, InvoiceIndex = _invc, SKUDescription = _batch.SKUIndex.Title, ProductType = _batch.ProductType, Quantity = _nq.Value, InvoiceContentStatus = InvoiceContentStatus.OK, Title = _batch.SKUIndex.Title, Units = _batch.ProductType.Value.Units() }; Parent.m_DataContextManagement.DataContext.InvoiceContent.InsertOnSubmit(_nic); Parent.m_DataContextManagement.DataContext.SubmitChanges(); _nic.CreateTitle(); Parent.m_DataContextManagement.DataContext.SubmitChanges(); } catch (Exception ex) { return(GenericStateMachineEngine.ActionResult.Exception(ex, "Create")); } return(GenericStateMachineEngine.ActionResult.Success); }
private static bool GetXmlContent(InvoiceItemXml[] invoiceEntries, Entities edc, InvoiceLib parent) { List <InvoiceContent> _invcs = new List <InvoiceContent>(); ErrorsList _warnings = new ErrorsList(); bool _result = true; foreach (InvoiceItemXml item in invoiceEntries) { try { InvoiceContent _ic = CreateInvoiceContent(edc, parent, item, _warnings); if (_ic == null) { continue; } _invcs.Add(_ic); _result &= _ic.InvoiceContentStatus.Value == InvoiceContentStatus.OK; if (parent.BillDoc.IsNullOrEmpty()) { parent.BillDoc = item.Bill_doc.ToString(); parent.InvoiceCreationDate = item.Created_on; } } catch (Exception ex) { string _msg = "Cannot create new entry for the invoice No={0}/{1}, SKU={2}, because of error: {3}"; _warnings.Add(new Warnning(String.Format(_msg, item.Bill_doc, item.Item, item.Description, ex.Message), true)); } } if (_warnings.Count > 0) { throw new InputDataValidationException("there are fatal errors in the XML message.", "GetBatchLookup", _warnings); } edc.InvoiceContent.InsertAllOnSubmit(_invcs); edc.SubmitChanges(); foreach (InvoiceContent _ic in _invcs) { _ic.CreateTitle(); } edc.SubmitChanges(); return(_result); }
protected override GenericStateMachineEngine.ActionResult Update() { try { List <string> _errors = new List <string>(); double? _nq = Parent.m_InvoiceQuantityTextBox.TextBox2Double(_errors); if (_errors.Count > 0) { return(ActionResult.NotValidated(_errors[0])); } if (_nq.HasValue && _nq.Value < 0) { return(ActionResult.NotValidated(String.Format(Resources.NegativeValueNotAllowed.GetLocalizedString(), Parent.m_InvoiceQuantityLabel.Text))); } Batch _batch = Parent.Batch; if (!_batch.Available(_nq.Value)) { string _tmplt = Resources.NeBatchQuantityIsUnavailable.GetLocalizedString(); return(ActionResult.NotValidated(String.Format(CultureInfo.CurrentCulture, _tmplt, _batch.AvailableQuantity()))); } InvoiceContent _ic = Parent.m_ControlState.InvoiceContent; _ic.Quantity = _nq; _ic.InvoiceContentStatus = InvoiceContentStatus.OK; if (_ic.InvoiceContent2BatchIndex != _batch) { _ic.InvoiceContent2BatchIndex = _batch; _ic.ProductType = _ic.InvoiceContent2BatchIndex.ProductType; _ic.Units = _ic.InvoiceContent2BatchIndex.ProductType.Value.Units(); _ic.Quantity = _nq; _ic.CreateTitle(); } Parent.m_DataContextManagement.DataContext.SubmitChanges(); } catch (Exception ex) { return(GenericStateMachineEngine.ActionResult.Exception(ex, "Update")); } return(GenericStateMachineEngine.ActionResult.Success); }
public void CigaretteExportFormCollectionConstructorTest() { double _quantity = 1000; double _portion = 0.5; SKUCigarette _sku = new SKUCigarette() { FormatIndex = new Format() { Title = "Format title", CigaretteLenght = "100", FilterLenght = "20" }, Brand = "Slims Menthol ", Family = "Salem", CigaretteLenght = "99.00 mm ", FilterLenght = "27.00 mm", IPRMaterial = true, Menthol = "M", MentholMaterial = true, PrimeMarket = "PL", ProductType = CAS.SmartFactory.IPR.WebsiteModel.Linq.ProductType.Cigarette, SKU = "12419574 ", Title = "SKU SA MXSR 99 CPB 20 5000 05 N PL1" }; Batch _batch = new Batch() { Batch0 = "99999999", BatchLibraryIndex = null, BatchStatus = BatchStatus.Final, CalculatedOveruse = 0, DustCooeficiencyVersion = 1, BatchDustCooeficiency = 1, Dust = 1.1, FGQuantityAvailable = 1000, FGQuantity = _quantity, MaterialQuantity = 5000.1234567, MaterialQuantityPrevious = 0, Overuse = 0, ProductType = CAS.SmartFactory.IPR.WebsiteModel.Linq.ProductType.Cigarette, SHCooeficiencyVersion = 1, BatchSHCooeficiency = 0.01234567, SHMenthol = 1.3, SKU = "SKU1234567890", SKUIndex = _sku, WasteCooeficiencyVersion = 1, Waste = 1.3, BatchWasteCooeficiency = 0.012345678, Title = "Testing batch" }; _batch.Tobacco = _batch.MaterialQuantity.Value - _batch.SHMenthol.Value - _batch.Dust.Value - _batch.Waste.Value; InvoiceContent invoice = new InvoiceContent() { InvoiceContent2BatchIndex = _batch, InvoiceIndex = null, ProductType = CAS.SmartFactory.IPR.WebsiteModel.Linq.ProductType.Cigarette, Quantity = _quantity * _portion, SKUDescription = _batch.SKU, InvoiceContentStatus = InvoiceContentStatus.OK, Title = "Testing Invoice", Units = "kU", }; List <CAS.SmartFactory.xml.DocumentsFactory.CigaretteExportForm.Ingredient> ingridients = new List <CAS.SmartFactory.xml.DocumentsFactory.CigaretteExportForm.Ingredient>(); IPR _ipr1 = new IPR() { AccountBalance = 0, AccountClosed = false, Batch = "TobaccoBatch", Cartons = 0, ClearenceIndex = null, ClosingDate = DateTime.Today, IPR2ConsentTitle = null, Currency = "PLN", CustomsDebtDate = DateTime.Today, DocumentNo = "SADDocumentNomber", Duty = 123.45, DutyName = "DustyName", IPRDutyPerUnit = 67.89, Grade = "GradeName", GrossMass = 12345.67, InvoiceNo = "InvoiceNo", IPRLibraryIndex = null, IPR2JSOXIndex = null, NetMass = 23456.78, OGLValidTo = DateTime.Today + TimeSpan.FromDays(364), IPR2PCNPCN = null, SKU = "IPR Tobacco SKU", TobaccoName = "TobaccoName", TobaccoNotAllocated = 9876.54, IPRUnitPrice = 5.67, Title = "Testing IPR", Value = 89012.34, VAT = 56.78, VATName = "VATName", IPRVATPerUnit = 9.12 }; IPR _ipr2 = new IPR() { AccountBalance = 0, AccountClosed = false, Batch = "TobaccoBatch", Cartons = 0, ClearenceIndex = null, ClosingDate = DateTime.Today, IPR2ConsentTitle = null, Currency = "USD", CustomsDebtDate = DateTime.Today, DocumentNo = "SADDocumentNomber", Duty = 123.45, DutyName = "DustyName", IPRDutyPerUnit = 67.89, Grade = "GradeName", GrossMass = 12345.67, InvoiceNo = "InvoiceNo", IPRLibraryIndex = null, IPR2JSOXIndex = null, NetMass = 23456.78, OGLValidTo = DateTime.Today + TimeSpan.FromDays(364), IPR2PCNPCN = null, SKU = "IPR Tobacco SKU", TobaccoName = "TobaccoName", TobaccoNotAllocated = 9876.54, IPRUnitPrice = 5.67, Title = "Testing IPR", Value = 89012.34, VAT = 56.78, VATName = "VATName", IPRVATPerUnit = 9.12 }; Disposal _disposal1 = new Disposal() { Disposal2BatchIndex = _batch, Disposal2ClearenceIndex = null, ClearingType = CAS.SmartFactory.IPR.WebsiteModel.Linq.ClearingType.PartialWindingUp, CustomsProcedure = "5100", CustomsStatus = CustomsStatus.NotStarted, DisposalStatus = DisposalStatus.TobaccoInCigaretes, DutyAndVAT = 123.4321, DutyPerSettledAmount = 345.6789, IPRDocumentNo = null, InvoiceNo = "InvoiceNomber", Disposal2IPRIndex = _ipr1, JSOXCustomsSummaryIndex = null, Disposal2MaterialIndex = null, SPNo = 7.8, RemainingQuantity = 0, SADDate = new Nullable <DateTime>(), SADDocumentNo = "N/A", SettledQuantity = 9.12, TobaccoValue = 34.567, Title = "Testing disposal", VATPerSettledAmount = 78.901, }; Disposal _disposal2 = new Disposal() { Disposal2BatchIndex = _batch, Disposal2ClearenceIndex = null, ClearingType = CAS.SmartFactory.IPR.WebsiteModel.Linq.ClearingType.PartialWindingUp, CustomsProcedure = "5100", CustomsStatus = CustomsStatus.NotStarted, DisposalStatus = DisposalStatus.TobaccoInCigaretes, DutyAndVAT = 123.4567, DutyPerSettledAmount = 345.67891234, IPRDocumentNo = null, InvoiceNo = "InvoiceNomber", Disposal2IPRIndex = _ipr2, JSOXCustomsSummaryIndex = null, Disposal2MaterialIndex = null, SPNo = 7.8, RemainingQuantity = 0, SADDate = new Nullable <DateTime>(), SADDocumentNo = "N/A", SettledQuantity = 9.12345678, TobaccoValue = 34.56789012, Title = "Testing disposal", VATPerSettledAmount = 78.9012345, }; CutfillerCoefficient _cc = new CutfillerCoefficient { CFTProductivityNormMax = 995, CFTProductivityNormMin = 985, CFTProductivityRateMax = 0.995, CFTProductivityRateMin = 0.985 }; ingridients.Add(CAS.SmartFactory.IPR.Dashboards.Clearance.FinishedGoodsFormFactory.GetIPRIngredient(_disposal1)); ingridients.Add(CAS.SmartFactory.IPR.Dashboards.Clearance.FinishedGoodsFormFactory.GetIPRIngredient(_disposal2)); ingridients.Add(new CAS.SmartFactory.xml.DocumentsFactory.CigaretteExportForm.RegularIngredient("Reg Batch 54321", "Reg SKU 12345", 1234.56789)); //string _masterDocumentName = "CigaretteExportFormCollection"; //string _invoiceNumber = "INV987654"; //int _position = 1; //List<XmlCigaretteExportForm> cigaretteExportFormList = new List<XmlCigaretteExportForm>(); //CigaretteExportForm _cigaretteExportForm = FinishedGoodsFormFactory.GetCigaretteExportForm( _cc, _batch, invoice, 0.5, ingridients, _masterDocumentName, ref _position, ClearenceProcedure._3151 ); //cigaretteExportFormList.Add( _cigaretteExportForm ); //_cigaretteExportForm = FinishedGoodsFormFactory.GetCigaretteExportForm( _cc, _batch, invoice, 0.5, ingridients, _masterDocumentName, ref _position, ClearenceProcedure._4071 ); //cigaretteExportFormList.Add( _cigaretteExportForm ); //CigaretteExportFormCollection target = FinishedGoodsFormFactory.GetCigaretteExportFormCollection( cigaretteExportFormList, _masterDocumentName, _invoiceNumber ); //XmlSerializer _srlzr = new XmlSerializer( typeof( CigaretteExportFormCollection ) ); //XmlWriterSettings _setting = new XmlWriterSettings() //{ // Indent = true, // IndentChars = " ", // NewLineChars = "\r\n" //}; //using ( XmlWriter file = XmlWriter.Create( _masterDocumentName + ".xml", _setting ) ) //{ // file.WriteProcessingInstruction( "xml-stylesheet", "type=\"text/xsl\" href=\"CigaretteExportFormCollection.xslt\"" ); // _srlzr.Serialize( file, target ); // Assert.IsTrue( true, "Success" ); //} }
public InvoiceController(InvoiceContent context) { _context = context; _service = new InvoiceServices(context); }
public InvoiceServices(InvoiceContent context) { _context = context; }
private static void ExportMaterial(Entities entities, Material material, List <Ingredient> formsList, bool closingBatch, InvoiceContent invoiceContent, int sadConsignmentNumber, NamedTraceLogger.TraceAction trace) { trace("Entering FinishedGoodsFormFactory.ExportMaterial", 171, TraceSeverity.Verbose); string _at = "Beginning"; try { if (material.ProductType.Value == IPR.WebsiteModel.Linq.ProductType.IPRTobacco) { List <Disposal> _dspsls = new List <Disposal>(); material.Export(entities, closingBatch, invoiceContent, _dspsls, sadConsignmentNumber, trace); foreach (Disposal _dx in _dspsls) { formsList.Add(GetIPRIngredient(_dx)); } } else if (material.ProductType.Value == IPR.WebsiteModel.Linq.ProductType.Tobacco) { _at = "RegularIngredient"; RegularIngredient _ri = new RegularIngredient(material.Batch, material.SKU, Convert.ToDouble(material.CalculatedQuantity(invoiceContent))); formsList.Add(_ri); } } catch (ApplicationError _ae) { throw _ae; } catch (Exception _ex) { string _ms = "Cannot proceed with export of Material: {0} because of error: {1}."; _ms = String.Format(_ms, material.Material2BatchIndex.Title, _ex.Message); trace("ApplicationError at FinishedGoodsFormFactory.ExportMaterial: " + _ms + "StackTrace: " + _ex.StackTrace, 141, TraceSeverity.Verbose); throw new ApplicationError("Material.Export", _at, _ms, _ex); } }
public PaymentController(InvoiceContent context) { _context = context; }