private void CreateReceipt() { Money tourBasePPS = this.StrategyInfo.Service.Detail.PricePerPerson; int index = 0; if (tourBasePPS != null) { bool isConfirmed = this.StrategyInfo.Service.CostDetails.IsConfirmed; foreach (TourCostDetail detail in this.StrategyInfo.Service.CostDetails) { this.StrategyInfo.CostDetail = detail; TourReceiptItem item = new TourReceiptItem(); Int32 quantity = isConfirmed ? detail.ParticipantsCount : detail.SignUpCount; item.Index = index; item.ParentIndex = -1; item.PricePerPerson = tourBasePPS; item.Quantity = quantity; item.Description = detail.CostGroup.Name; if (item.Total.Value != 0.0M) { this.StrategyInfo.Service.Bill.Items.Add(item); } foreach (TourCostRule rule in detail.CostGroup.Rules) { this.StrategyInfo.Rule = rule; if (this.ruleValidator.Matches(this.StrategyInfo)) { item = new TourReceiptItem(); item.ParentIndex = index; item.Index = ++index; item.Description = rule.Name + " (" + rule.Formula.ToString() + ")"; item.Quantity = rule.IsPerPerson ? quantity : 1; item.PricePerPerson = rule.GetTotal(tourBasePPS); if (item.Total.Value != 0.0M) { this.StrategyInfo.Service.Bill.Items.Add(item); } } } index++; } } }
public bool UpdateReceipt() { if (this.calculating) { return(false); } this.calculating = true; bool res = true; // Prevent event firing again while changing list Detach(); try { // Clear old items int count = this.StrategyInfo.Service.Bill.Items.Count; for (int i = 0; i < count; i++) { TourReceiptItem item = this.StrategyInfo.Service.Bill.Items[0]; if (!item.IsCustom) { res = this.StrategyInfo.Service.Bill.Delete(item); if (!res) { break; } } } // recalculate if (res) { CreateReceipt(); } CalculateTotal(); } catch (Exception ex) { } // attach back to tour Attach(); this.calculating = false; return(res); }