Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using BST.LionMarrodentWorkers.UI.Kontrahenci.Extenders;
- using Soneta.Business;
- using Soneta.CRM;
- using Soneta.Towary;
- using Soneta.Types;
- [assembly: Worker(typeof(CzDiscountExtender))]
- namespace BST.LionMarrodentWorkers.UI.Kontrahenci.Extenders
- {
- public sealed class CzDiscountExtender : ISessionable
- {
- //Context
- [Context] public Kontrahent Counterparty { get; set; }
- [Context] public Session Session { get; set; }
- //Public - get - properties
- public Percent FlatDiscount => Counterparty?.Rabat ?? Percent.Zero;
- public ViewInfo Group => GetGroupDiscounts();
- public ViewInfo Manufacturer => GetManufacturerDiscounts();
- public ViewInfo Individual => GetIndividualDiscounts();
- public ViewInfo Periodic => GetPeriodicDiscounts();
- //Private - methods
- private ViewInfo GetGroupDiscounts()
- {
- ViewInfo vi = new ViewInfo();
- vi.CreateView += (sender, args) =>
- {
- args.View = TowaryModule.GetInstance(args.Session).CenyGrupowe
- .WgKontrahent[Counterparty][x => x.RabatZdefiniowany && x.GrupaTowarowa.Category == "F.CZ_GroupOfGood"]
- .CreateView();
- };
- return vi;
- }
- private ViewInfo GetManufacturerDiscounts()
- {
- ViewInfo vi = new ViewInfo();
- vi.CreateView += (sender, args) =>
- {
- args.View = TowaryModule.GetInstance(args.Session).CenyGrupowe
- .WgKontrahent[Counterparty][x => x.RabatZdefiniowany && x.GrupaTowarowa.Category == "F.CZ_Manufacture"]
- .CreateView();
- };
- return vi;
- }
- private ViewInfo GetIndividualDiscounts()
- {
- ViewInfo vi = new ViewInfo();
- vi.CreateView += (sender, args) =>
- {
- args.View = TowaryModule.GetInstance(Session).CenyIndywidualne
- .WgKontrahent[Counterparty]
- .CreateView();
- };
- return vi;
- }
- private ViewInfo GetPeriodicDiscounts()
- {
- ViewInfo vi = new ViewInfo();
- vi.CreateView += (sender, args) =>
- {
- RowCondition rc = new FieldCondition.Equal("PrzecenaOkresowa.Zatwierdzona", true);
- rc &= new FieldCondition.LessEqual("PrzecenaOkresowa.Okres.From", Date.Today);
- rc &= new FieldCondition.GreaterEqual("PrzecenaOkresowa.Okres.To", Date.Today);
- rc &= new RowCondition.Or(new FieldCondition.Null("PrzecenaOkresowa.Kontrahent", true),
- new FieldCondition.Equal("PrzecenaOkresowa.Kontrahent.Guid", Counterparty.Guid));
- args.View = TowaryModule.GetInstance(Session).PrzecenyOkresTwr.WgTowar[rc].CreateView();
- };
- return vi;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement