Example #1
0
 internal void FinishClearThroughCustoms(Entities edc, SADGood sadGood, NamedTraceLogger.TraceAction traceEvent)
 {
     traceEvent("Starting CustomsWarehouseDisposal.FinishClearThroughCustoms for sadGood:" + sadGood.Title, 100, TraceSeverity.Verbose);
     if (this.CustomsStatus.Value == Linq.CustomsStatus.Finished)
     {
         return;
     }
     try
     {
         List <CustomsWarehouseDisposal> _Finished = (from _dsp in this.CWL_CWDisposal2CustomsWarehouseID.CustomsWarehouseDisposal(edc, false)
                                                      where _dsp.CustomsStatus.Value == Linq.CustomsStatus.Finished
                                                      select _dsp).ToList <CustomsWarehouseDisposal>();
         if (_Finished.Count <CustomsWarehouseDisposal>() == 0)
         {
             this.SPNo = 1;
         }
         else
         {
             this.SPNo = _Finished.Max <CustomsWarehouseDisposal>(dspsl => dspsl.SPNo.Value) + 1;
         }
         AssignSADGood(edc, sadGood, traceEvent);
         decimal _balance = CalculateRemainingQuantity();
         if (_balance == 0)
         {
             this.CW_RemainingPackage      = 0;
             this.CW_RemainingTobaccoValue = 0;
             this.ClearingType             = Linq.ClearingType.TotalWindingUp;
         }
         else
         {
             double _value = _Finished.Sum <CustomsWarehouseDisposal>(x => x.TobaccoValue.Value);
             double _pckgs = _Finished.Sum <CustomsWarehouseDisposal>(x => x.CW_PackageToClear.Value);
             this.CW_RemainingPackage      = this.CWL_CWDisposal2CustomsWarehouseID.CW_PackageUnits - _pckgs - this.CW_PackageToClear;
             this.CW_RemainingTobaccoValue = this.CWL_CWDisposal2CustomsWarehouseID.Value - _value - this.TobaccoValue;
             this.ClearingType             = Linq.ClearingType.PartialWindingUp;
         }
         CheckCNConsistency(traceEvent);
         this.CustomsStatus = Linq.CustomsStatus.Finished;
     }
     catch (Exception ex)
     {
         traceEvent("Exception at CustomsWarehouseDisposal.FinishClearThroughCustoms for sadGood:" + ex.Message, 133, TraceSeverity.High);
         throw;
     }
     traceEvent("Finished CustomsWarehouseDisposal.FinishClearThroughCustoms", 136, TraceSeverity.Verbose);
 }
Example #2
0
        private void AssignSADGood(Entities edc, SADGood sadGood, NamedTraceLogger.TraceAction traceEvent)
        {
            traceEvent("Starting CustomsWarehouseDisposal.AssignSADGood", 167, TraceSeverity.Verbose);
            this.SADDate       = sadGood.SADDocumentIndex.CustomsDebtDate;
            this.SADDocumentNo = sadGood.SADDocumentIndex.DocumentNumber;
            //TODO check consistency and generate warning.
            this.CustomsProcedure = sadGood.SPProcedure;
            if (this.TobaccoValue != sadGood.TotalAmountInvoiced)
            {
                string _msg = "Total Amount Invoiced value is not equal as requested to clear through customs";
                traceEvent("Finishing CustomsWarehouseDisposal.AssignSADGood: " + _msg, 167, TraceSeverity.High);
                throw new ArgumentOutOfRangeException("TotalAmountInvoiced", _msg);
            }
            decimal _vat    = 0;
            decimal _duties = 0;

            foreach (SADDuties _sdc in sadGood.SADDuties(edc, false))
            {
                switch (Settings.DutyKind(_sdc.DutyType))
                {
                case Settings.DutyKindEnum.VAT:
                    _vat += _sdc.Amount.DecimalValue();
                    break;

                case Settings.DutyKindEnum.Duty:
                    _duties += _sdc.Amount.DecimalValue();
                    break;

                case Settings.DutyKindEnum.ExciseDuty:
                    throw new NotImplementedException();
                }
            }
            this.DutyPerSettledAmount = _duties.DoubleValue();
            this.VATPerSettledAmount  = _vat.DoubleValue();
            this.DutyAndVAT           = (_vat + _duties).DoubleValue();
            traceEvent("Finishing CustomsWarehouseDisposal.AssignSADGood", 167, TraceSeverity.Verbose);
        }