/// <summary> /// Clear through customs according procedure 4051. /// </summary> /// <param name="entities">The entities.</param> /// <param name="good">The good description form.</param> /// <param name="trace">The trace action.</param> /// <exception cref="InputDataValidationException">SAD Required Documents;clear through customs fatal error; true</exception> private static void IPRClearThroughCustoms(Entities entities, SADGood good, NamedTraceLogger.TraceAction trace) { foreach (Clearence _clearance in GetClearanceIds(entities, good, Settings.GetParameter(entities, SettingsEntry.RequiredDocumentFinishedGoodExportConsignmentPattern))) { _clearance.FinishClearingThroughCustoms(entities, good, trace); } }
private static void GetSADDuties(DutiesDescription[] document, Entities edc, SADGood lookup) { if (document.NullOrEmpty <DutiesDescription>()) { return; } List <SADDuties> rows = new List <SADDuties>(); try { foreach (DutiesDescription duty in document) { SADDuties newRow = new SADDuties() { SADDuties2SADGoodID = lookup, Title = String.Format("{0}: {1}", duty.GetDutyType(), duty.GetAmount()), Amount = duty.GetAmount(), DutyType = duty.GetDutyType() }; rows.Add(newRow); } if (rows.Count == 0) { return; } edc.SADDuties.InsertAllOnSubmit(rows); edc.SubmitChanges(); } catch (Exception ex) { throw new IPRDataConsistencyException("GetSADDuties", ex.Message, ex, "Duties analysis problem"); } }
/// <summary> /// Clear through customs according 4071 procedure. /// </summary> /// <param name="entities">The entities.</param> /// <param name="good">The good.</param> /// <exception cref="InputDataValidationException">Create CW Account Failed;CreateCWAccount</exception> private static CWClearanceData CWPrepareClearance(Entities entities, SADGood good) { Clearence _clearance = GetClearanceIds(entities, good, Settings.GetParameter(entities, SettingsEntry.RequiredDocumentSADTemplateDocumentNamePattern)).First <Clearence>(); _clearance.FinishClearingThroughCustoms(good); return(new CWClearanceData(_clearance.Id.Value)); }
/// <summary> /// Analyzes the good. /// </summary> /// <param name="edc">The <see cref="Entities"/> instance.</param> /// <param name="good">The good.</param> /// <param name="_messageType">Type of the _message.</param> protected internal override void AnalizeGood(Entities edc, SADGood good, MessageType _messageType) { base.AnalizeGood(edc, good, _messageType); SADPackage _packagex = good.SADPackage(edc).First(); if (_packagex.Package.ToUpper().Contains("CT")) { CartonsMass = GrossMass - NetMass; } else { CartonsMass = 0; } }
private void AnalizeDutyAndVAT(Entities edc, SADGood good) { string _at = "Started"; try { Duty = 0; VAT = 0; DutyName = string.Empty; VATName = string.Empty; foreach (SADDuties _duty in good.SADDuties(edc)) { _at = "switch " + _duty.DutyType; switch (_duty.DutyType) { //Duty case "A10": case "A00": case "A20": Duty += _duty.Amount.Value; _at = "DutyName"; DutyName += String.Format("{0}={1:F2}; ", _duty.DutyType, _duty.Amount.Value); break; //VAT case "B00": case "B10": case "B20": VAT += _duty.Amount.Value; _at = "VATName"; VATName += String.Format("{0}={1:F2}; ", _duty.DutyType, _duty.Amount.Value); break; default: break; } } _at = "DutyPerUnit"; DutyPerUnit = Duty / NetMass; _at = "VATPerUnit"; VATPerUnit = VAT / NetMass; } catch (Exception _ex) { string _src = String.Format("AnalizeDutyAndVAT error at {0}", _at); throw new IPRDataConsistencyException(_src, _ex.Message, _ex, _src); } }
/// <summary> /// Analyzes the good. /// </summary> /// <param name="edc">The <see cref="Entities"/> instance.</param> /// <param name="good">The good.</param> /// <param name="messageType">Type of the _message.</param> protected internal virtual void AnalizeGood(Entities edc, SADGood good, MessageType messageType) { SADDocumentType _document = good.SADDocumentIndex; switch (messageType) { case MessageType.PZC: GrossMass = _document.GrossMass.HasValue ? _document.GrossMass.Value : good.GrossMass.Value; break; case MessageType.SAD: GrossMass = good.GrossMass.HasValue ? good.GrossMass.Value : _document.GrossMass.Value; break; } GetNetMass(edc, good); }
private static void GetSADGood(GoodDescription[] document, Entities edc, SADDocumentType lookup) { if (document.NullOrEmpty <GoodDescription>()) { return; } try { foreach (GoodDescription _doc in document) { string _description = _doc.GetDescription().SPValidSubstring(); SADGood newRow = new SADGood() { SADDocumentIndex = lookup, Title = String.Format("{0}: {1}", _doc.GetDescription().SPValidSubstring(), _doc.GetPCNTariffCode()), GoodsDescription = _description, PCNTariffCode = _doc.GetPCNTariffCode(), GrossMass = _doc.GetGrossMass(), NetMass = _doc.GetNetMass(), SPProcedure = _doc.GetProcedure(), TotalAmountInvoiced = _doc.GetTotalAmountInvoiced(), ItemNo = _doc.GetItemNo() }; edc.SADGood.InsertOnSubmit(newRow); edc.SubmitChanges(); GetSADDuties(_doc.GetSADDuties(), edc, newRow); GetSADPackage(_doc.GetSADPackage(), edc, newRow); GetSADQuantity(_doc.GetSADQuantity(), edc, newRow); GetSADRequiredDocuments(_doc.GetSADRequiredDocuments(), edc, newRow); } } catch (IPRDataConsistencyException) { throw; } catch (Exception ex) { throw new IPRDataConsistencyException("GetSADGood", ex.Message, ex, "Goods analysis problem"); } }
private static List <Clearence> GetClearanceIds(Entities entities, SADGood good, string pattern) { List <Clearence> _ret = new List <Clearence>(); foreach (SADRequiredDocuments _rdx in good.SADRequiredDocuments(entities)) { if (_rdx.Code != XMLResources.RequiredDocumentConsignmentCode) { continue; } int?_cleranceInt = XMLResources.GetRequiredDocumentFinishedGoodExportConsignmentNumber(_rdx.Number, pattern); if (!_cleranceInt.HasValue) { continue; } if (_cleranceInt.HasValue) { Clearence _clearance = Element.GetAtIndex <Clearence>(entities.Clearence, _cleranceInt.Value); _ret.Add(_clearance); } else { string _template = "Cannot find clearance for the required document code={0} for customs document = {1}/ref={2}"; throw new InputDataValidationException( String.Format(_template, _rdx.Number, good.SADDocumentIndex.DocumentNumber, good.SADDocumentIndex.ReferenceNumber), "SAD Required Documents", "clear through customs fatal error", true); } }// foreach if (_ret.Count == 0) { string _template = "Cannot find required document code={0} for customs document = {1}/ref={2}"; throw new InputDataValidationException( String.Format(_template, XMLResources.RequiredDocumentConsignmentCode, good.SADDocumentIndex.DocumentNumber, good.SADDocumentIndex.ReferenceNumber), "SAD Required Documents", "clear through customs fatal error", true); } return(_ret); }
private static SAD CraeteSAD(Entities entities, CustomsWarehouseDisposal disposal, string masterDocumentName) { SADGood _entrySAD = disposal.CWL_CWDisposal2CustomsWarehouseID.CWL_CW2ClearenceID.Clearence2SadGoodID; List <SADZgloszenieTowarDokumentWymagany> _dcsList = new List <SADZgloszenieTowarDokumentWymagany>(); int _Pos = 1; _dcsList.Add(SADZgloszenieTowarDokumentWymagany.Create(_Pos++, Settings.CustomsProcedureCode9DK8, masterDocumentName, String.Empty)); foreach (SADRequiredDocuments _rdx in _entrySAD.SADRequiredDocuments(entities, false)) { if (Required(_rdx.Code)) { _dcsList.Add(SADZgloszenieTowarDokumentWymagany.Create(_Pos++, _rdx.Code, _rdx.Number, _rdx.Title)); } } decimal _IloscTowaruId = 1; SADZgloszenieTowarIloscTowaru[] _IloscTowaruArray = new SADZgloszenieTowarIloscTowaru[] { SADZgloszenieTowarIloscTowaru.Create(ref _IloscTowaruId, disposal.CW_SettledNetMass.ConvertToDecimal(), disposal.CW_SettledGrossMass.ConvertToDecimal()) }; decimal _Value = disposal.TobaccoValue.ConvertToDecimal(); decimal _SADZgloszenieTowarId = 1; string _CWDocumentNo = disposal.CWL_CWDisposal2CustomsWarehouseID.DocumentNo; string _CustomsProcedure = String.IsNullOrEmpty(disposal.CustomsProcedure) ? disposal.CWL_CWDisposal2DisposalRequestLibraryID.ClearenceProcedure.Value.Convert2String() : disposal.CustomsProcedure; SADZgloszenieTowar[] _good = new SADZgloszenieTowar[] { SADZgloszenieTowar.Create (disposal.GoodsName(entities), disposal.CW_PackageToClear.ConvertToDecimal(), _CWDocumentNo, _Value, ref _SADZgloszenieTowarId, disposal.ProductCode, disposal.ProductCodeTaric, _CustomsProcedure, _dcsList.ToArray(), _IloscTowaruArray) }; SADZgloszenieUC _CustomsOffice = SADZgloszenieUC.Create(Settings.GetParameter(entities, SettingsEntry.DefaultCustomsOffice)); SADZgloszenie _application = SADZgloszenie.Create(_good, _CustomsOffice, Settings.GetParameter(entities, SettingsEntry.RecipientOrganization), Vendor.SenderOrganization(entities)); return(SAD.Create(Settings.GetParameter(entities, SettingsEntry.OrganizationEmail), _application)); }
/// <summary> /// Gets the net mass. /// </summary> /// <param name="edc">The entity data context.</param> /// <param name="good">The good.</param> protected internal override void GetNetMass(Entities edc, SADGood good) { NetMass = good.NetMass.GetValueOrDefault(0); }
/// <summary> /// Gets the net mass. /// </summary> /// <param name="edc">The <see cref="Entities" /> instance</param> /// <param name="good">The good.</param> protected internal override void GetNetMass(Entities edc, SADGood good) { SADQuantity _quantity = good.SADQuantity(edc).FirstOrDefault(); NetMass = _quantity == null ? 0 : _quantity.NetMass.GetValueOrDefault(0); }
/// <summary> /// Gets the net mass. /// </summary> /// <param name="edc">The <see cref="Entities"/> instance</param> /// <param name="good">The good.</param> protected internal abstract void GetNetMass(Entities edc, SADGood good);
private static void GetSADRequiredDocuments(RequiredDocumentsDescription[] document, Entities edc, SADGood entry) { try { if (document.NullOrEmpty <RequiredDocumentsDescription>()) { return; } List <SADRequiredDocuments> rows = new List <SADRequiredDocuments>(); foreach (RequiredDocumentsDescription requiredDocument in document) { SADRequiredDocuments newRow = new SADRequiredDocuments() { SADRequiredDoc2SADGoodID = entry, Title = String.Format("{0}: {1}", requiredDocument.GetCode(), requiredDocument.GetNumber()), Code = requiredDocument.GetCode(), Number = requiredDocument.GetNumber() }; rows.Add(newRow); } if (rows.Count == 0) { return; } edc.SADRequiredDocuments.InsertAllOnSubmit(rows); edc.SubmitChanges(); } catch (Exception ex) { throw new IPRDataConsistencyException("GetSADRequiredDocuments", ex.Message, ex, "Required documents analysis problem"); } }
private static void GetSADQuantity(QuantityDescription[] document, Entities edc, SADGood entry) { if (document.NullOrEmpty <QuantityDescription>()) { return; } List <SADQuantity> rows = new List <SADQuantity>(); try { foreach (QuantityDescription quantity in document) { SADQuantity newRow = new SADQuantity() { SADQuantity2SADGoodID = entry, Title = String.Format("{0}: {1}", quantity.GetNetMass(), quantity.GetUnits()), ItemNo = quantity.GetItemNo(), NetMass = quantity.GetNetMass(), Units = quantity.GetUnits() }; rows.Add(newRow); } if (rows.Count == 0) { return; } edc.SADQuantity.InsertAllOnSubmit(rows); edc.SubmitChanges(); } catch (Exception ex) { throw new IPRDataConsistencyException("GetSADQuantity", ex.Message, ex, "Quantity analysis problem"); } }
private static void GetSADPackage(PackageDescription[] document, Entities edc, SADGood entry) { try { if (document.NullOrEmpty <PackageDescription>()) { return; } List <SADPackage> rows = new List <SADPackage>(); foreach (PackageDescription package in document) { SADPackage newRow = new SADPackage() { SADPackage2SADGoodID = entry, Title = String.Format("{0}: {1}", package.GetItemNo(), package.GetPackage()), ItemNo = package.GetItemNo(), Package = package.GetPackage() }; rows.Add(newRow); } if (rows.Count == 0) { return; } edc.SADPackage.InsertAllOnSubmit(rows); edc.SubmitChanges(); } catch (Exception ex) { throw new IPRDataConsistencyException("GetSADPackage", ex.Message, ex, "Packages analysis problem"); } }