예제 #1
0
        public string Update()
        {
            CommissionAmount = (CommissionRate * Amount) / 100;
            CommissionAmount = Math.Round((decimal)CommissionAmount);
            VatOnAmount      = Amount + CommissionAmount;
            VatAmount        = (CommissionAmount + Amount) * VatRate / 100;
            VatAmount        = Math.Round((decimal)VatAmount);
            InvoiceAmount    = Amount + CommissionAmount + VatAmount;

            XDocument doc    = XDocument.Load(@"Transactions.xml");
            var       record = from r in doc.Descendants("Transaction")
                               where (int)r.Element("Invoice").Attribute("Id") == InvoiceId
                               select r;

            foreach (XElement r in record)
            {
                r.Element("Invoice").Element("InvoiceNo").Value        = InvoiceNo;
                r.Element("Invoice").Element("InvoiceDate").Value      = XmlConvert.ToString(InvoiceDate, XmlDateTimeSerializationMode.RoundtripKind);
                r.Element("Invoice").Element("CommissionRate").Value   = CommissionRate.ToString();
                r.Element("Invoice").Element("CommissionAmount").Value = CommissionAmount.ToString();
                r.Element("Invoice").Element("VatRate").Value          = VatRate.ToString();
                r.Element("Invoice").Element("VatAmount").Value        = VatAmount.ToString();
                r.Element("Invoice").Element("InvoiceAmount").Value    = InvoiceAmount.ToString();
                r.Element("Invoice").Element("Source").Value           = Source;
                r.Element("Invoice").Element("Destination").Value      = Destination;
                r.Element("Invoice").Element("TruckNo").Value          = TruckNo;
            }
            doc.Save(@"Transactions.xml");
            return("Record Updated");
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (entityId_ != null)
            {
                hash ^= EntityId.GetHashCode();
            }
            if (IataId.Length != 0)
            {
                hash ^= IataId.GetHashCode();
            }
            if (CommissionType != 0)
            {
                hash ^= CommissionType.GetHashCode();
            }
            if (commissionAmount_ != null)
            {
                hash ^= CommissionAmount.GetHashCode();
            }
            if (commissionPercentage_ != null)
            {
                hash ^= CommissionPercentage.GetHashCode();
            }
            if (GivenName.Length != 0)
            {
                hash ^= GivenName.GetHashCode();
            }
            if (FamilyName.Length != 0)
            {
                hash ^= FamilyName.GetHashCode();
            }
            if (BusinessAddress1.Length != 0)
            {
                hash ^= BusinessAddress1.GetHashCode();
            }
            if (BusinessAddress2.Length != 0)
            {
                hash ^= BusinessAddress2.GetHashCode();
            }
            if (BusinessCity.Length != 0)
            {
                hash ^= BusinessCity.GetHashCode();
            }
            if (BusinessState.Length != 0)
            {
                hash ^= BusinessState.GetHashCode();
            }
            if (BusinessZip.Length != 0)
            {
                hash ^= BusinessZip.GetHashCode();
            }
            if (BusinessNation.Length != 0)
            {
                hash ^= BusinessNation.GetHashCode();
            }
            if (BusinessPhoneNumber.Length != 0)
            {
                hash ^= BusinessPhoneNumber.GetHashCode();
            }
            if (BusinessFaxNumber.Length != 0)
            {
                hash ^= BusinessFaxNumber.GetHashCode();
            }
            if (BusinessEmailAddress.Length != 0)
            {
                hash ^= BusinessEmailAddress.GetHashCode();
            }
            return(hash);
        }
 public void MergeFrom(TravelAgent other)
 {
     if (other == null)
     {
         return;
     }
     if (other.entityId_ != null)
     {
         if (entityId_ == null)
         {
             entityId_ = new global::HOLMS.Types.Booking.Indicators.TravelAgentIndicator();
         }
         EntityId.MergeFrom(other.EntityId);
     }
     if (other.IataId.Length != 0)
     {
         IataId = other.IataId;
     }
     if (other.CommissionType != 0)
     {
         CommissionType = other.CommissionType;
     }
     if (other.commissionAmount_ != null)
     {
         if (commissionAmount_ == null)
         {
             commissionAmount_ = new global::HOLMS.Types.Primitive.MonetaryAmount();
         }
         CommissionAmount.MergeFrom(other.CommissionAmount);
     }
     if (other.commissionPercentage_ != null)
     {
         if (commissionPercentage_ == null)
         {
             commissionPercentage_ = new global::HOLMS.Types.Primitive.FixedPointRatio();
         }
         CommissionPercentage.MergeFrom(other.CommissionPercentage);
     }
     if (other.GivenName.Length != 0)
     {
         GivenName = other.GivenName;
     }
     if (other.FamilyName.Length != 0)
     {
         FamilyName = other.FamilyName;
     }
     if (other.BusinessAddress1.Length != 0)
     {
         BusinessAddress1 = other.BusinessAddress1;
     }
     if (other.BusinessAddress2.Length != 0)
     {
         BusinessAddress2 = other.BusinessAddress2;
     }
     if (other.BusinessCity.Length != 0)
     {
         BusinessCity = other.BusinessCity;
     }
     if (other.BusinessState.Length != 0)
     {
         BusinessState = other.BusinessState;
     }
     if (other.BusinessZip.Length != 0)
     {
         BusinessZip = other.BusinessZip;
     }
     if (other.BusinessNation.Length != 0)
     {
         BusinessNation = other.BusinessNation;
     }
     if (other.BusinessPhoneNumber.Length != 0)
     {
         BusinessPhoneNumber = other.BusinessPhoneNumber;
     }
     if (other.BusinessFaxNumber.Length != 0)
     {
         BusinessFaxNumber = other.BusinessFaxNumber;
     }
     if (other.BusinessEmailAddress.Length != 0)
     {
         BusinessEmailAddress = other.BusinessEmailAddress;
     }
 }
        public string Update()
        {
            //Rounding off for direct costings

            if (this.PostageCost.HasValue)
            {
                this.PostageCost = Math.Round((decimal)this.PostageCost);
            }
            if (this.JafferyActualCost.HasValue)
            {
                this.JafferyActualCost = Math.Round((decimal)this.JafferyActualCost);
            }
            if (this.SampleCuttingCost.HasValue)
            {
                this.SampleCuttingCost = Math.Round((decimal)this.SampleCuttingCost);
            }
            if (this.GodownRentCost.HasValue)
            {
                this.GodownRentCost = Math.Round((decimal)this.GodownRentCost);
            }
            if (this.StockInsuranceCost.HasValue)
            {
                this.StockInsuranceCost = Math.Round((decimal)this.StockInsuranceCost);
            }
            if (this.FreightCost.HasValue)
            {
                this.FreightCost = Math.Round((decimal)this.FreightCost);
            }

            //Calculation and Rounding for calculated costings

            this.CommissionAmount = (this.CommissionRate * this.AmountAndVat) / 100;
            if (this.CommissionAmount.HasValue)
            {
                this.CommissionAmount = Math.Round((decimal)this.CommissionAmount);
            }
            this.CharityAmount = (this.CharityRate * this.AmountAndVat) / 100;
            if (this.CharityAmount.HasValue)
            {
                this.CharityAmount = Math.Round((decimal)this.CharityAmount);
            }
            this.BrokerageAmount = (this.BrokerageRate * this.AmountAndVat) / 100;
            if (this.BrokerageAmount.HasValue)
            {
                this.BrokerageAmount = Math.Round((decimal)this.BrokerageAmount);
            }
            this.CottonDeliveryExpAmount = this.CottonDeliveryExpRate * this.Bales;
            if (this.CottonDeliveryExpAmount.HasValue)
            {
                this.CottonDeliveryExpAmount = Math.Round((decimal)this.CottonDeliveryExpAmount);
            }
            this.MarkingAmount = this.MarkingRate * this.Bales;
            if (this.MarkingAmount.HasValue)
            {
                this.MarkingAmount = Math.Round((decimal)this.MarkingAmount);
            }
            this.CartagePlatformAmount = this.CartagePlatformRate * this.Bales;
            if (this.CartagePlatformAmount.HasValue)
            {
                this.CartagePlatformAmount = Math.Round((decimal)this.CartagePlatformAmount);
            }
            this.StackingAmount = this.StackingRate * this.Bales;
            if (this.StackingAmount.HasValue)
            {
                this.StackingAmount = Math.Round((decimal)this.StackingAmount);
            }
            this.KatlaExpAmount = this.KatlaExpRate * this.Bales;
            if (this.KatlaExpAmount.HasValue)
            {
                this.KatlaExpAmount = Math.Round((decimal)this.KatlaExpAmount);
            }
            this.CartageFactoryAmount = this.CartageFactoryRate * this.Bales;
            if (this.CartageFactoryAmount.HasValue)
            {
                this.CartageFactoryAmount = Math.Round((decimal)this.CartageFactoryAmount);
            }
            this.StationExpAmount = this.StationExpRate * this.Bales;
            if (this.StationExpAmount.HasValue)
            {
                this.StationExpAmount = Math.Round((decimal)this.StationExpAmount);
            }
            this.TruckLoadingAmount = this.TruckLoadingRate * this.Bales;
            if (this.TruckLoadingAmount.HasValue)
            {
                this.TruckLoadingAmount = Math.Round((decimal)this.TruckLoadingAmount);
            }
            this.BankChargeAmount = this.BankChargeCost;
            if (this.BankChargeAmount.HasValue)
            {
                this.BankChargeAmount = Math.Round((decimal)this.BankChargeAmount);
            }
            if (this.CarringChargesFrom != null && this.CarringChargesTo != null)
            {
                DateTime d1 = (DateTime)this.CarringChargesFrom;
                DateTime d2 = (DateTime)this.CarringChargesTo;
                TimeSpan t1 = d2.Subtract(d1);
                this.CarringChargesFor = t1.Days;
            }
            this.CarringChargesAmount = this.CarringChargesOn * this.CarringChargesFor * this.CarringChargesRate / 3000;
            if (CarringChargesAmount.HasValue)
            {
                this.CarringChargesAmount = Math.Round((decimal)this.CarringChargesAmount);
            }

            //AmountAndVat


            //Debit Note Total
            this.DebitNoteTotal = (this.CommissionAmount ?? 0) + (this.CharityAmount ?? 0) + (this.BrokerageAmount ?? 0) + (this.PostageCost ?? 0) +
                                  (this.CottonDeliveryExpAmount ?? 0) + (this.JafferyActualCost ?? 0) + (this.MarkingAmount ?? 0) + (this.SampleCuttingCost ?? 0) +
                                  (this.CartagePlatformAmount ?? 0) + (this.StackingAmount ?? 0) + (this.KatlaExpAmount ?? 0) + (this.CartageFactoryAmount ?? 0) +
                                  (this.StationExpAmount ?? 0) + (this.TruckLoadingAmount ?? 0) + (this.BankChargeAmount ?? 0) + (this.GodownRentCost ?? 0) +
                                  (this.StockInsuranceCost ?? 0) + (this.FreightCost ?? 0) + (this.CarringChargesAmount ?? 0);

            //Update XML
            XDocument doc    = XDocument.Load(@"Transactions.xml");
            var       record = from r in doc.Descendants("Transaction")
                               where (int)r.Element("DebitNote").Attribute("Id") == DebitNoteId
                               select r;

            foreach (XElement r in record)
            {
                r.Element("DebitNote").Element("DebitNoteNo").Value             = DebitNoteNo;
                r.Element("DebitNote").Element("DebitNoteDate").Value           = XmlConvert.ToString(DebitNoteDate, XmlDateTimeSerializationMode.RoundtripKind);
                r.Element("DebitNote").Element("CommissionRate").Value          = CommissionRate.ToString();
                r.Element("DebitNote").Element("CommissionAmount").Value        = CommissionAmount.ToString();
                r.Element("DebitNote").Element("CharityRate").Value             = CharityRate.ToString();
                r.Element("DebitNote").Element("CharityAmount").Value           = CharityAmount.ToString();
                r.Element("DebitNote").Element("BrokerageRate").Value           = BrokerageRate.ToString();
                r.Element("DebitNote").Element("BrokerageAmount").Value         = BrokerageAmount.ToString();
                r.Element("DebitNote").Element("Postage").Value                 = Postage;
                r.Element("DebitNote").Element("PostageCost").Value             = PostageCost.ToString();
                r.Element("DebitNote").Element("CottonDeliveryExpRate").Value   = CottonDeliveryExpRate.ToString();
                r.Element("DebitNote").Element("CottonDeliveryExpAmount").Value = CottonDeliveryExpAmount.ToString();
                r.Element("DebitNote").Element("JafferyActual").Value           = JafferyActual;
                r.Element("DebitNote").Element("JafferyActualCost").Value       = JafferyActualCost.ToString();
                r.Element("DebitNote").Element("MarkingRate").Value             = MarkingRate.ToString();
                r.Element("DebitNote").Element("MarkingAmount").Value           = MarkingAmount.ToString();
                r.Element("DebitNote").Element("SampleCutting").Value           = SampleCutting;
                r.Element("DebitNote").Element("SampleCuttingCost").Value       = SampleCuttingCost.ToString();
                r.Element("DebitNote").Element("PostageCost").Value             = PostageCost.ToString();
                r.Element("DebitNote").Element("CartagePlatformRate").Value     = CartagePlatformRate.ToString();
                r.Element("DebitNote").Element("CartagePlatformAmount").Value   = CartagePlatformAmount.ToString();
                r.Element("DebitNote").Element("StackingRate").Value            = StackingRate.ToString();
                r.Element("DebitNote").Element("StackingAmount").Value          = StackingAmount.ToString();
                r.Element("DebitNote").Element("KatlaExp").Value                = KatlaExp;
                r.Element("DebitNote").Element("KatlaExpRate").Value            = KatlaExpRate.ToString();
                r.Element("DebitNote").Element("KatlaExpAmount").Value          = KatlaExpAmount.ToString();
                r.Element("DebitNote").Element("CartageFactoryRate").Value      = CartageFactoryRate.ToString();
                r.Element("DebitNote").Element("CartageFactoryAmount").Value    = CartageFactoryAmount.ToString();
                r.Element("DebitNote").Element("StationExpRate").Value          = StationExpRate.ToString();
                r.Element("DebitNote").Element("StationExpAmount").Value        = StationExpAmount.ToString();
                r.Element("DebitNote").Element("TruckLoadingRate").Value        = TruckLoadingRate.ToString();
                r.Element("DebitNote").Element("TruckLoadingAmount").Value      = TruckLoadingAmount.ToString();
                r.Element("DebitNote").Element("BankChargeCost").Value          = BankChargeCost.ToString();
                r.Element("DebitNote").Element("BankChargeAmount").Value        = BankChargeAmount.ToString();
                r.Element("DebitNote").Element("GodownRentFrom").Value          = GodownRentFrom.HasValue? XmlConvert.ToString(GodownRentFrom.Value, XmlDateTimeSerializationMode.RoundtripKind) : "";
                r.Element("DebitNote").Element("GodownRentTo").Value            = GodownRentTo.HasValue ? XmlConvert.ToString(GodownRentTo.Value, XmlDateTimeSerializationMode.RoundtripKind) : "";
                r.Element("DebitNote").Element("GodownRentCost").Value          = GodownRentCost.ToString();
                r.Element("DebitNote").Element("StockInsurance").Value          = StockInsurance;
                r.Element("DebitNote").Element("StockInsuranceCost").Value      = StockInsuranceCost.ToString();
                r.Element("DebitNote").Element("FreightFrom").Value             = FreightFrom;
                r.Element("DebitNote").Element("FreightTo").Value               = FreightTo;
                r.Element("DebitNote").Element("FreightCost").Value             = FreightCost.ToString();
                r.Element("DebitNote").Element("CarringChargesOn").Value        = CarringChargesOn.ToString();
                r.Element("DebitNote").Element("CarringChargesFrom").Value      = CarringChargesFrom.HasValue ? XmlConvert.ToString(CarringChargesFrom.Value, XmlDateTimeSerializationMode.RoundtripKind) : "";
                r.Element("DebitNote").Element("CarringChargesTo").Value        = CarringChargesTo.HasValue ? XmlConvert.ToString(CarringChargesTo.Value, XmlDateTimeSerializationMode.RoundtripKind) : "";
                r.Element("DebitNote").Element("CarringChargesFor").Value       = CarringChargesFor.ToString();
                r.Element("DebitNote").Element("CarringChargesRate").Value      = CarringChargesRate.ToString();
                r.Element("DebitNote").Element("CarringChargesAmount").Value    = CarringChargesAmount.ToString();
                r.Element("DebitNote").Element("AmountAndVat").Value            = AmountAndVat.ToString();
                r.Element("DebitNote").Element("DebitNoteTotal").Value          = DebitNoteTotal.ToString();
            }
            doc.Save(@"Transactions.xml");
            return("Record Updated");
        }