public void MergeFrom(RspCommissionRateMsg other) { if (other == null) { return; } if (other.commissionRate_ != null) { if (commissionRate_ == null) { CommissionRate = new global::Evelynn.Base.Response.CommissionRateField(); } CommissionRate.MergeFrom(other.CommissionRate); } if (other.error_ != null) { if (error_ == null) { Error = new global::Evelynn.Base.Response.ErrorField(); } Error.MergeFrom(other.Error); } if (other.RequestId != 0) { RequestId = other.RequestId; } if (other.IsLast != false) { IsLast = other.IsLast; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
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 string SaveCommission(CommissionRate cr, int userId) { if (db.CommissionRate.Where(c => c.id != cr.id && c.end_date > cr.begin_date && c.begin_date < cr.end_date && c.product_type == cr.product_type).Count() > 0) { return("此时间段与之前设置的时间段有重叠,保存失败"); } try { if (cr.id != 0) { //更新,将旧的删除 CommissionRate existed = db.CommissionRate.Single(c => c.id == cr.id); BackupData bd = new BackupData(); bd.user_id = userId; bd.sys_no = "佣金率维护"; bd.op_date = DateTime.Now; bd.main_data = SomeUtils.ModelToString <CommissionRate>(existed); bd.secondary_data = SomeUtils.ModelsToString <CommissionRateDetail>(existed.CommissionRateDetail.ToList()); db.BackupData.InsertOnSubmit(bd); db.CommissionRateDetail.DeleteAllOnSubmit(existed.CommissionRateDetail); db.CommissionRate.DeleteOnSubmit(existed); } db.CommissionRate.InsertOnSubmit(cr); db.SubmitChanges(); } catch (Exception ex) { return(ex.Message); } return(""); }
public override int GetHashCode() { int hash = 1; if (commissionRate_ != null) { hash ^= CommissionRate.GetHashCode(); } if (error_ != null) { hash ^= Error.GetHashCode(); } if (RequestId != 0) { hash ^= RequestId.GetHashCode(); } if (IsLast != false) { hash ^= IsLast.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public JsonResult SaveCommission(FormCollection fc) { CommissionRate cr = new CommissionRate(); string details = fc.Get("commissionRateDetails"); SomeUtils.SetFieldValueToModel(fc, cr); cr.CommissionRateDetail.AddRange(JsonConvert.DeserializeObject <List <CommissionRateDetail> >(fc.Get("commissionRateDetails"))); if (cr.id == 0) { cr.create_date = DateTime.Now; } cr.update_date = DateTime.Now; cr.user_name = currentUser.realName; string result = new CommissionSv().SaveCommission(cr, currentUser.userId); if (!string.IsNullOrEmpty(result)) { return(Json(new ResultModel() { suc = false, msg = result }, "text/html")); } return(Json(new ResultModel() { suc = true, msg = "保存成功" }, "text/html")); }
} // end Parameterized constructor /// <summary> /// To override the ToString method so object property values are returned /// </summary> /// <returns>The string containing the object property values</returns> public override string ToString() { return "\r\n" + FirstName.ToString() + " " + LastName.ToString() + ":\r\n\t" + "Type: " + EmpType.ToString().ToLowerInvariant() + "\r\n\t" + "ID: " + EmpID.ToString() + "\r\n\t" + "Monthly Salary: " + MonthlySalary.ToString("C") + "\r\n\t" + "Commission Rate: " + CommissionRate.ToString("C") + "\n"; } // end method ToString()
public void CommissionRates_WhenNotEqual_HaveDifferentHashCodes() { // Arrange var rate1 = new CommissionRate(new CommissionRateValue(0.01m)); var rate2 = new CommissionRate(new CommissionRateValue(0.02m)); // Act var hashCodesEqual = rate1.GetHashCode() == rate2.GetHashCode(); // Assert hashCodesEqual.Should().BeFalse(); }
public void CommissionRates_AreNotEqual() { // Arrange var rate1 = new CommissionRate(new CommissionRateValue(0.01m)); var rate2 = new CommissionRate(new CommissionRateValue(0.02m)); // Act var areEqual = rate1 == rate2; // Assert areEqual.Should().BeFalse(); }
public void CommissionRates_WhenEqual_HaveSameHashCode() { // Arrange var rate1 = new CommissionRate(new CommissionRateValue(0.01m)); var rate2 = new CommissionRate(new CommissionRateValue(0.01m)); // Act var hashCodesEqual = rate1.GetHashCode() == rate2.GetHashCode(); // Assert hashCodesEqual.Should().BeTrue(); }
public ActionResult CreateCommission() { CommissionRate cr = new CommissionRate(); cr.id = 0; cr.user_name = currentUser.realName; cr.create_date = DateTime.Now; ViewData["commission"] = cr; ViewData["commissionDetails"] = new List <CommissionRateDetail>(); return(View()); }
} // End public override double CalculateEarnings() //************************************************ // Overridden ToString() //************************************************ public override string ToString() { // Begin public override string ToString() string outputStr = ""; outputStr += "Employee Name: " + FirstName + " " + MiddleInit + " " + LastName + "\n"; outputStr += "Union Status: " + IsUnion.ToString() + "\n"; outputStr += "Employee Number: " + EmpNum.ToString() + "\n"; outputStr += "Commission Rate: " + CommissionRate.ToString("f2") + "\n"; outputStr += "Weekly Sales: " + WeeklySales.ToString("c") + "\n"; outputStr += "Gross Pay: " + grossPay.ToString("c") + "\n"; return(outputStr); } // End public override string ToString()
public void CreateNew_CreatesCommissionEmployee() { // Arrange EmployeeId employeeId = new EmployeeId("foo"); Name name = new Name("fee", null, "fo", null, null); FakeAddress address = new FakeAddress(new FakeName(), "l1", "city", "country"); CommissionRate rate = new CommissionRate(new CommissionRateValue(0.03m)); Money salary = new Money(new FakeCurrency(), new MoneyValue(100000m)); // Act var employee = CommissionEmployee.CreateNew(employeeId, name, address, rate, salary); // Assert employee.EmployeeId.Should().Be(employeeId); employee.Name.Should().Be(name); employee.Address.Should().Be(address); employee.Rate.Should().Be(rate); employee.Salary.Should().Be(salary); }
public void MergeFrom(QryCommissionRateMsg other) { if (other == null) { return; } if (other.commissionRate_ != null) { if (commissionRate_ == null) { CommissionRate = new global::Evelynn.Base.Query.QryCommissionRateField(); } CommissionRate.MergeFrom(other.CommissionRate); } if (other.RequestId != 0) { RequestId = other.RequestId; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public string RemoveCommission(int id, int userId) { try { CommissionRate existed = db.CommissionRate.Single(c => c.id == id); BackupData bd = new BackupData(); bd.user_id = userId; bd.sys_no = "删除佣金率"; bd.op_date = DateTime.Now; bd.main_data = SomeUtils.ModelToString <CommissionRate>(existed); bd.secondary_data = SomeUtils.ModelsToString <CommissionRateDetail>(existed.CommissionRateDetail.ToList()); db.BackupData.InsertOnSubmit(bd); db.CommissionRateDetail.DeleteAllOnSubmit(existed.CommissionRateDetail); db.CommissionRate.DeleteOnSubmit(existed); db.SubmitChanges(); } catch (Exception ex) { return(ex.Message); } return(""); }
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"); }