protected override PaymentRuleEntity entityFromReader(SqlDataReader reader)
        {
            int            supplierId  = (int)reader["Supplier"];
            int            customerId  = (int)reader["Customer"];
            SupplierEntity supplier    = SupplierMapper.Read(supplierId);
            CustomerEntity customer    = CustomerMapper.Read(customerId);
            BookingType    bookingType = (BookingType)Enum.Parse(typeof(BookingType), reader["BookingType"].ToString());
            decimal        percentage  = (decimal)reader["Percentage"];
            int            daysOffset  = (int)reader["DaysOffset"];
            BaseDate       baseDate    = (BaseDate)Enum.Parse(typeof(BaseDate), reader["BaseDate"].ToString());
            PaymentType    paymentType = (PaymentType)Enum.Parse(typeof(PaymentType), reader["PaymentType"].ToString());

            PaymentRuleEntity paymentRuleEntity = new PaymentRuleEntity(supplier, customer, bookingType, percentage,
                                                                        daysOffset, baseDate, paymentType);

            int      paymentRuleId = (int)reader["PaymentRuleId"];
            DateTime lastModified  = (DateTime)reader["LastModified"];
            bool     deleted       = (bool)reader["Deleted"];

            paymentRuleEntity.Id           = paymentRuleId;
            paymentRuleEntity.LastModified = lastModified;
            paymentRuleEntity.Deleted      = deleted;

            supplier.AddPaymentRule(paymentRuleEntity);

            return(paymentRuleEntity);
        }
Example #2
0
        internal APartyEntity Read(int id)
        {
            // check if supplier, if not get customer and return
            APartyEntity party = SupplierMapper.Read(id);

            if (party == null)
            {
                party = CustomerMapper.Read(id);
            }

            return(party);
        }
Example #3
0
        protected override BookingEntity entityFromReader(SqlDataReader reader)
        {
            //Sets data from the database to corresponding data type for usage in the program.
            int         supplierId        = (int)reader["Supplier"];
            int         customerId        = (int)reader["Customer"];
            string      note              = (string)reader["Note"];
            string      sale              = (string)reader["Sale"];
            int         bookingNumber     = (int)reader["BookingNumber"];
            DateTime    startDate         = (DateTime)reader["StartDate"];
            DateTime    endDate           = (DateTime)reader["EndDate"];
            BookingType type              = (BookingType)Enum.Parse(typeof(BookingType), reader["Type"].ToString());
            decimal     iVAExempt         = (decimal)reader["IVAExempt"];
            decimal     iVASubject        = (decimal)reader["IVASubject"];
            decimal     service           = (decimal)reader["Service"];
            decimal     iVA               = (decimal)reader["IVA"];
            decimal     productRetention  = (decimal)reader["ProductRetention"];
            decimal     supplierRetention = (decimal)reader["supplierRetention"];
            decimal     transferAmount    = (decimal)reader["TransferAmount"];

            int      id           = (int)reader["BookingId"];
            DateTime lastModified = (DateTime)reader["LastModified"];
            bool     deleted      = (bool)reader["Deleted"];

            SupplierEntity supplier = SupplierMapper.Read(supplierId);
            CustomerEntity customer = CustomerMapper.Read(customerId);

            BookingEntity bookingEntity = new BookingEntity(supplier, customer, sale, bookingNumber,
                                                            startDate, endDate);

            //Uses the data to make it into an booking object.
            bookingEntity.Note              = note;
            bookingEntity.Id                = id;
            bookingEntity.LastModified      = lastModified;
            bookingEntity.Deleted           = deleted;
            bookingEntity.Type              = type;
            bookingEntity.IVAExempt         = iVAExempt;
            bookingEntity.IVA               = iVA;
            bookingEntity.IVASubject        = iVASubject;
            bookingEntity.Service           = service;
            bookingEntity.ProductRetention  = productRetention;
            bookingEntity.SupplierRetention = supplierRetention;
            bookingEntity.TransferAmount    = transferAmount;

            return(bookingEntity);
        }