public WasteProtocol(Waste waste) : this() { ProtocolDate = BusinessDomain.GetFormattedDate(waste.Date); ProtocolNumber = waste.FormattedOperationNumber; Note = waste.Note; CompanyRecord company = CompanyRecord.GetDefault(); CompanyName = company.Name; CompanyNumber = company.Bulstat; CompanyCity = company.City; CompanyAddress = company.Address; CompanyTelephone = company.Telephone; CompanyLiablePerson = company.LiablePerson; Location = waste.Location2; bool usePriceIn = !BusinessDomain.LoggedUser.HideItemsPurchasePrice; PriceType priceType = usePriceIn ? PriceType.PurchaseTotal : PriceType.SaleTotal; double vat = waste.VAT; if (BusinessDomain.AppConfiguration.VATIncluded) { Total = Currency.ToString(waste.Total - vat, priceType); Vat = Currency.ToString(vat, priceType); TotalPlusVat = waste.Total; } else { Total = Currency.ToString(waste.Total, priceType); Vat = Currency.ToString(vat, priceType); TotalPlusVat = waste.Total + vat; } int i = 1; foreach (WasteDetail detail in waste.Details) { ProtocolDetails.Add(new ProtocolDetail(i++, detail, usePriceIn)); } TotalQuantity = Quantity.ToString(waste.Details.Sum(d => d.Quantity)); }
public User CommitChanges() { if (BusinessDomain.AppConfiguration.AutoGenerateUserCodes && string.IsNullOrWhiteSpace(code)) { AutoGenerateCode(); } if (!string.IsNullOrEmpty(groupName) && groupId <= 1) { UsersGroup g = GroupBase <UsersGroup> .EnsureByPath(groupName, UsersGroup.Cache); groupId = g.Id; } bool isNew = id < 0; BusinessDomain.DataAccessProvider.AddUpdateUser(this); cache.Set(this); if (isNew) { BusinessDomain.RestrictionTree.ResetLevelRestrictions(id, userLevel); BusinessDomain.RestrictionTree.SaveRestrictions(); } if (lockedLocationIdDirty) { ConfigEntry.SaveValue(LOCKED_LOCATION_KEY, LockedLocationId, id); lockedLocationIdDirty = false; } if (lockedPartnerIdDirty) { ConfigEntry.SaveValue(LOCKED_PARTNER_KEY, LockedPartnerId, id); lockedPartnerIdDirty = false; } if (defaultPartnerIdDirty) { ConfigEntry.SaveValue(DEFAULT_PARTNER_KEY, DefaultPartnerId, id); defaultPartnerIdDirty = false; } if (defaultCompanyIdDirty) { ConfigEntry.SaveValue(DEFAULT_COMPANY_KEY, DefaultCompanyId, id); BusinessDomain.CurrentCompany = CompanyRecord.GetDefault(); defaultCompanyIdDirty = false; } if (hideItemsPurchasePriceDirty) { ConfigEntry.SaveValue(HIDE_ITEMS_PURCHASE_PRICE_KEY, HideItemsPurchasePrice, id); hideItemsPurchasePriceDirty = false; } if (hideItemsAvailabilityDirty) { ConfigEntry.SaveValue(HIDE_ITEMS_AVAILABILITY_KEY, HideItemsAvailability, id); hideItemsAvailabilityDirty = false; } if (allowZeroPricesDirty) { ConfigEntry.SaveValue(ALLOW_ZERO_PRICES_KEY, AllowZeroPrices, id); allowZeroPricesDirty = false; } if (BusinessDomain.LoggedUser.Id == id) { BusinessDomain.LoggedUser = this; } return(this); }