Ejemplo n.º 1
0
        public int OpdateringAfSlettet_rsmembership_transaction(int p_trans_id, dbData3060DataContext p_dbData3060)
        {
            int out_trans_id = p_trans_id;
            puls3060_dkEntities dbPuls3060_dk = new puls3060_dkEntities();

            var qry1 = from s1 in dbPuls3060_dk.ecpwt_rsmembership_transactions where s1.id == p_trans_id select s1;
            int c1   = qry1.Count();

            if (c1 == 0)
            {
                var qry2 = from s2 in p_dbData3060.tblrsmembership_transactions where s2.trans_id == p_trans_id select s2;
                try
                {
                    tblrsmembership_transaction t2 = qry2.First();
                    int?subscriber_id = t2.subscriber_id;
                    var qry3          = from s3 in dbPuls3060_dk.ecpwt_rsmembership_membership_subscribers where s3.id == subscriber_id select s3;
                    int c3            = qry3.Count();
                    if (c3 == 1)
                    {
                        ecpwt_rsmembership_transactions t1 = new ecpwt_rsmembership_transactions
                        {
                            user_id      = t2.user_id,
                            user_email   = t2.user_email,
                            user_data    = t2.user_data,
                            type         = t2.type,
                            @params      = t2.@params,
                            date         = t2.date,
                            ip           = t2.ip,
                            price        = t2.price,
                            coupon       = t2.coupon,
                            currency     = t2.currency,
                            hash         = t2.hash,
                            custom       = t2.custom,
                            gateway      = t2.gateway,
                            status       = t2.status,
                            response_log = t2.response_log
                        };
                        dbPuls3060_dk.ecpwt_rsmembership_transactions.Add(t1);
                        dbPuls3060_dk.SaveChanges();

                        ecpwt_rsmembership_transactions rec_trans = (from t in dbPuls3060_dk.ecpwt_rsmembership_transactions where t.custom == t2.custom select t).First();
                        out_trans_id = rec_trans.id;
                    }
                    else
                    {
                        out_trans_id = 0;
                    }
                }
                catch
                {
                    out_trans_id = 0;
                }
            }
            return(out_trans_id);
        }
Ejemplo n.º 2
0
        public MemBogfoeringsKlader konter_paypal_betalinger_fra_rsmembership(puls3060_dkEntities p_dbPuls3060_dk, DateTime Regnskabsaar_Startdato, DateTime Regnskabsaar_Slutdato)
        {
            clsPayPal            objPayPal = new clsPayPal();
            MemBogfoeringsKlader klader    = new MemBogfoeringsKlader();
            int BS1_SidsteNr     = 0;
            var qry_rsmembership = from s in p_dbPuls3060_dk.ecpwt_rsmembership_membership_subscribers
                                   where s.membership_id == 6
                                   join tl in p_dbPuls3060_dk.ecpwt_rsmembership_transactions on s.last_transaction_id equals tl.id
                                   where tl.gateway == "PayPal"
                                   join p in p_dbPuls3060_dk.tblpaypalpayments on tl.hash equals p.paypal_transactions_id into p1
                                   from p in p1.DefaultIfEmpty()
                                   where p.bogfoert == null || p.bogfoert == false
                                   join u in p_dbPuls3060_dk.ecpwt_users on s.user_id equals u.id
                                   select new
            {
                paypal_transaction_id = tl.hash,
                Navn = u.name,
                s.membership_id,
                s.membership_start,
                s.membership_end,
            };
            var arr_rsmembership = qry_rsmembership.ToArray();

            if (arr_rsmembership.Count() > 0)
            {
                foreach (var rsmembership in arr_rsmembership)
                {
                    if (rsmembership.paypal_transaction_id.Length == 0)
                    {
                        continue;
                    }

                    PaymentTransactionSearchResultType paypal_trans = objPayPal.getPayPalTransaction(rsmembership.paypal_transaction_id);

                    if (paypal_trans != null)
                    {
                        decimal   Belob    = decimal.Parse(paypal_trans.GrossAmount.Value.Replace(".", ","));
                        decimal[] arrBeløb = clsPbs602.fordeling(Belob, rsmembership.membership_start, rsmembership.membership_end, Regnskabsaar_Startdato, Regnskabsaar_Slutdato);
                        string    stdate   = string.Format(" {0}-{1}", rsmembership.membership_start.ToString("d.M.yyyy"), rsmembership.membership_end.ToString("d.M.yyyy"));

                        int wBilag = ++BS1_SidsteNr;
                        recBogfoeringsKlader recklade = new recBogfoeringsKlader
                        {
                            Dato             = paypal_trans.Timestamp,
                            Bilag            = wBilag,
                            Tekst            = ("Paypal: " + rsmembership.paypal_transaction_id).PadRight(40, ' ').Substring(0, 40),
                            Afstemningskonto = "PayPal",
                            Belob            = Belob,
                            Kontonr          = null,
                            Faknr            = null,
                            Sagnr            = null
                        };
                        klader.Add(recklade);

                        if (arrBeløb[0] > 0)
                        {
                            recklade = new recBogfoeringsKlader
                            {
                                Dato             = paypal_trans.Timestamp,
                                Bilag            = wBilag,
                                Tekst            = (rsmembership.Navn + stdate).PadRight(40, ' ').Substring(0, 40),
                                Afstemningskonto = "",
                                Belob            = arrBeløb[0],
                                Kontonr          = 1800,
                                Faknr            = null,
                                Sagnr            = null
                            };
                            klader.Add(recklade);
                        }

                        if (arrBeløb[1] > 0)
                        {
                            recklade = new recBogfoeringsKlader
                            {
                                Dato             = paypal_trans.Timestamp,
                                Bilag            = wBilag,
                                Tekst            = (rsmembership.Navn + stdate).PadRight(40, ' ').Substring(0, 40),
                                Afstemningskonto = "",
                                Belob            = arrBeløb[1],
                                Kontonr          = 64200,
                                Faknr            = null,
                                Sagnr            = null
                            };
                            klader.Add(recklade);
                        }

                        recklade = new recBogfoeringsKlader
                        {
                            Dato             = paypal_trans.Timestamp,
                            Bilag            = wBilag,
                            Tekst            = ("PayPal Gebyr").PadRight(40, ' ').Substring(0, 40),
                            Afstemningskonto = "PayPal",
                            Belob            = decimal.Parse(paypal_trans.FeeAmount.Value.Replace(".", ",")),
                            Kontonr          = 9950,
                            Faknr            = null,
                            Sagnr            = null
                        };
                        klader.Add(recklade);

                        tblpaypalpayment rec_paypalpayments = (from p in p_dbPuls3060_dk.tblpaypalpayments where p.paypal_transactions_id == rsmembership.paypal_transaction_id select p).FirstOrDefault();
                        if (rec_paypalpayments == null)
                        {
                            rec_paypalpayments = new tblpaypalpayment
                            {
                                paypal_transactions_id = rsmembership.paypal_transaction_id,
                                bogfoert = true
                            };
                            p_dbPuls3060_dk.tblpaypalpayments.Add(rec_paypalpayments);
                        }
                        else
                        {
                            rec_paypalpayments.bogfoert = true;
                        }
                        p_dbPuls3060_dk.SaveChanges();
                    }
                }
            }



            return(klader);
        }
Ejemplo n.º 3
0
        public int betalinger_til_rsmembership(dbData3060DataContext p_dbData3060, puls3060_dkEntities p_dbPuls3060_dk)
        {
            int saveBetid = 0;
            var rsmbrshp  = from bl in p_dbData3060.tblbetlins
                            where (bl.pbstranskode == "0236" || bl.pbstranskode == "0297")
                            join b in p_dbData3060.tblbets on bl.betid equals b.id
                            where b.rsmembership == null || b.rsmembership == false
                            join p in p_dbData3060.tblfrapbs on b.frapbsid equals p.id
                            orderby p.id, b.id, bl.id
                select new
            {
                Frapbsid = p.id,
                p.leverancespecifikation,
                Betid    = b.id,
                Betlinid = bl.id,
                bl.betalingsdato,
                bl.indbetalingsdato,
                bl.indbetalingsbelob,
                bl.faknr,
                bl.debitorkonto
            };

            int AntalBetalinger = rsmbrshp.Count();

            Program.Log(string.Format("betalinger_til_rsmembership - AntalBetalinger {0}", AntalBetalinger));
            if (rsmbrshp.Count() > 0)
            {
                clsPbsHelper objPbsHelperd = new clsPbsHelper();
                foreach (var b in rsmbrshp)
                {
                    if (saveBetid != b.Betid) // ny gruppe
                    {
                        saveBetid = b.Betid;
                        var rec_bet = (from ub in p_dbData3060.tblbets where ub.id == b.Betid select ub).First();
                        rec_bet.rsmembership = true;
                    }

                    // Do somthing here
                    var qry = from f in p_dbData3060.tblfaks
                              where f.faknr == b.faknr
                              join m in p_dbData3060.tblrsmembership_transactions on f.id equals m.id
                              select new tblmembershippayment
                    {
                        rsmembership_transactions_id = m.trans_id,
                    };
                    if (qry.Count() == 1)
                    {
                        tblmembershippayment rec_membershippayment = qry.First();
                        //*********************************************************
                        int new_rsmembership_transactions_id = objPbsHelperd.OpdateringAfSlettet_rsmembership_transaction(rec_membershippayment.rsmembership_transactions_id, p_dbData3060);
                        Program.Log(string.Format("betalinger_til_rsmembership - transactions_id {0} --> {1}", rec_membershippayment.rsmembership_transactions_id, p_dbData3060, new_rsmembership_transactions_id));
                        rec_membershippayment.rsmembership_transactions_id = new_rsmembership_transactions_id;
                        //*********************************************************
                        p_dbPuls3060_dk.tblmembershippayments.Add(rec_membershippayment);
                        p_dbPuls3060_dk.SaveChanges();
                        Program.Log(string.Format("betalinger_til_rsmembership - faknr {0} betalt", b.faknr));
                    }
                }
                p_dbData3060.SubmitChanges();
            }
            return(AntalBetalinger);
        }