Exemplo n.º 1
0
            private List <mTva> getTVA(ClassSync.ClassCloseTicket.CloseTicket c)
            {
                List <mTva> tva = new List <mTva>();

                foreach (ClassTVA.tva tv in ClassTVA.listTVA)
                {
                    mTva mtva = new mTva();

                    mtva.tva = tv;

                    mtva.HT = 0;

                    mtva.TVA = 0;

                    mtva.TTC = 0;

                    foreach (ClassSync.ClassCloseTicket.ChecksTicket check in c.ChecksTicket)
                    {
                        foreach (ClassSync.ClassCloseTicket.PayProducts product in check.PayProducts)
                        {
                            if (product.TVA == tv.val)
                            {
                                //[13:05:34 | Изменены 13:06:00] Rena: HT = TTC - (TTC/(100+TVA)*TVA)
                                //                                      HT = TTC / (1 + TVA/100)


                                // coef = decimal.Round(100 / (product.TVA + 100), 3) * product.Total;

                                //decimal ht = decimal.Round((product.Total - (product.Total / (product.TVA + 100) * product.TVA)), 2);

                                //Rinat  decimal koef = (decimal.Truncate(100 / (product.TVA + 100) * 1000))/1000;

                                //Rinat  decimal ht = decimal.Round( koef * product.Total, 2);

                                decimal ht = (product.Total / (100 + product.TVA)) * 100;

                                mtva.HT  += ht;
                                mtva.TTC += product.Total;
                                mtva.TVA += (product.Total / (100 + product.TVA) * product.TVA);
                            }
                        }
                    }

                    tva.Add(mtva);
                }

                return(tva);
            }
Exemplo n.º 2
0
            //       public List<Paiements> listPaiements = new List<Paiements>();
            public void DrawElm(List <ClassPrintCheck.groupProduct> lProduct, int posX, int posY, out int posXo, out int posYo)
            {
                foreach (ClassTVA.tva t in ClassTVA.listTVA)
                {
                    mTva n = new mTva();
                    n.id  = t.id;
                    n.val = t.val;
                    n.ht  = 0.0m;
                    n.tva = 0.0m;
                    ltva.Add(n);
                }
                foreach (ClassPrintCheck.groupProduct g in lProduct)
                {
                    int sizeLine = 15;

                    elm e = new elm();
                    e.font                       = new Font("Arial", 8, FontStyle.Bold);
                    e.text                       = g.categories;
                    e.rectangle                  = new Rectangle(posX + 10, posY, 270, sizeLine);
                    e.stringFormat               = new StringFormat();
                    e.stringFormat.Alignment     = StringAlignment.Near;
                    e.stringFormat.LineAlignment = StringAlignment.Far;
                    posY += sizeLine;
                    listEl.Add(e);
                    for (int i = 0; i < g.products.Count; i++)
                    {
                        elm emName = new elm();
                        emName.text = g.products[i].name;
                        if (emName.text.Length > 30)
                        {
                            emName.text = emName.text.Substring(0, 30);
                        }
                        emName.font                       = new Font("Arial", 10);
                        emName.rectangle                  = new Rectangle(posX, posY, 225, sizeLine);
                        emName.stringFormat               = new StringFormat();
                        emName.stringFormat.Alignment     = StringAlignment.Near;
                        emName.stringFormat.LineAlignment = StringAlignment.Center;
                        listEl.Add(emName);

                        elm emPrice = new elm();
                        emPrice.text = g.products[i].total.ToString("0.00");

                        emPrice.font                       = new Font("Arial", 10);
                        emPrice.rectangle                  = new Rectangle(posX + 220, posY, 60, sizeLine);
                        emPrice.stringFormat               = new StringFormat();
                        emPrice.stringFormat.Alignment     = StringAlignment.Far;
                        emPrice.stringFormat.LineAlignment = StringAlignment.Center;
                        listEl.Add(emPrice);

                        int indx = ltva.FindIndex(l => l.id == g.products[i].tva);

                        if (indx != -1)
                        {
                            ltva[indx].tva += g.products[i].TvaTotal;
                            ltva[indx].ht  += g.products[i].HT;
                        }

                        posY += sizeLine;

                        if (g.products[i].qty != 1)
                        {
                            elm emQTY = new elm();

                            int iqty = (int)g.products[i].qty;

                            if (iqty - g.products[i].qty != 0.0M)
                            {
                                emQTY.text = g.products[i].qty.ToString("0.000") + "kg x " + g.products[i].price + " €";
                            }
                            else
                            {
                                emQTY.text = " " + iqty.ToString() + "   x   " + g.products[i].price + " €";
                            }


                            emQTY.font = new Font("Arial", 8);

                            emQTY.rectangle                  = new Rectangle(posX + 10, posY - 3, 250, sizeLine);
                            emQTY.stringFormat               = new StringFormat();
                            emQTY.stringFormat.Alignment     = StringAlignment.Near;
                            emQTY.stringFormat.LineAlignment = StringAlignment.Near;
                            listEl.Add(emQTY);
                            posY += 10;
                        }
                    }
                }
                posXo = posX;
                posYo = posY;
            }
Exemplo n.º 3
0
            public print(ClassSync.ClassCloseTicket.CloseTicketG G, List <ClassSync.ClassCloseTicket.CloseTicket> C)
            {
                DateTime dt = G.DateClose;

                string date = dt.ToShortDateString();

                string time = dt.ToShortTimeString();

                int X        = 0;
                int Y        = 134;
                int H        = size;
                int W        = 280;
                int sizeLine = 12;
                elm n        = new elm();

                n.rectangle = new Rectangle(X, Y, W, H);
                n.stringFormat.Alignment     = StringAlignment.Center;
                n.stringFormat.LineAlignment = StringAlignment.Near;
                n.text = "Date : " + date + "  -  Heure : " + time;
                E.Add(n);
                Y += H;

                List <mTotal> M = new List <mTotal>();

                List <List <mTva> > TotalCaseTVA = new List <List <mTva> >();

                foreach (var e in C.OrderBy(l => l.NameTicket))
                {
                    elm nl1 = new elm();
                    nl1.font      = new Font("Arial", 12, FontStyle.Bold);
                    nl1.rectangle = new Rectangle(X, Y + 15, W, H);
                    nl1.stringFormat.Alignment = StringAlignment.Center;
                    nl1.text = e.NameTicket.ToUpper();
                    E.Add(nl1);
                    Y += H + 15;

                    elm nlzv = new elm();
                    nlzv.rectangle = new Rectangle(X, Y, 300, H);
                    nlzv.text      = "**********************************************************";
                    E.Add(nlzv);
                    Y += H;

                    elm nl2 = new elm();
                    nl2.rectangle = new Rectangle(X, Y - 10, W, H);
                    nl2.stringFormat.Alignment = StringAlignment.Center;
                    nl2.text = e.DateClose.ToShortDateString();
                    E.Add(nl2);
                    Y += H;

                    List <ClassCheck.localTypesPay> LTP = getTypePay(e);

                    decimal sumMoney = LTP.Sum(l => l.value);

                    foreach (var l in LTP)
                    {
                        elm eNamePay = new elm();
                        eNamePay.rectangle = new Rectangle(X, Y, 120, H);
                        eNamePay.stringFormat.Alignment = StringAlignment.Near;
                        eNamePay.text = l.type.Name;
                        E.Add(eNamePay);

                        elm eValTTC = new elm();
                        eValTTC.rectangle = new Rectangle(X + 120, Y, 80, H);
                        eValTTC.stringFormat.Alignment = StringAlignment.Far;
                        eValTTC.text = l.value.ToString("C");
                        E.Add(eValTTC);

                        elm eProc = new elm();
                        eProc.rectangle = new Rectangle(X + 200, Y, 80, H);
                        eProc.stringFormat.Alignment = StringAlignment.Far;
                        eProc.text = (l.value / sumMoney).ToString("P");
                        E.Add(eProc);
                        Y += H;
                    }


                    elm nl4 = new elm();
                    nl4.font      = new Font("Arial", 9, FontStyle.Bold);
                    nl4.rectangle = new Rectangle(X, Y, 120, H);
                    nl4.stringFormat.Alignment = StringAlignment.Near;
                    nl4.text = "TOTAL";
                    E.Add(nl4);

                    elm nsumMoney = new elm();
                    nsumMoney.font      = new Font("Arial", 9, FontStyle.Bold);
                    nsumMoney.rectangle = new Rectangle(X + 120, Y, 80, H);
                    nsumMoney.stringFormat.Alignment = StringAlignment.Far;
                    nsumMoney.text = sumMoney.ToString("C");
                    E.Add(nsumMoney);

                    elm nsumProc = new elm();
                    nsumProc.font      = new Font("Arial", 9, FontStyle.Bold);
                    nsumProc.rectangle = new Rectangle(X + 200, Y, 80, H);
                    nsumProc.stringFormat.Alignment = StringAlignment.Far;
                    nsumProc.text = 1.ToString("P");
                    E.Add(nsumProc);
                    Y += H;

                    elm TiTVA = new elm();
                    TiTVA.font      = new Font("Arial", 10, FontStyle.Bold);
                    TiTVA.rectangle = new Rectangle(X, Y + 10, W, H);
                    TiTVA.stringFormat.Alignment = StringAlignment.Center;
                    TiTVA.text = "*** TVA ***";
                    E.Add(TiTVA);
                    Y += H + 10;

                    elm nl5 = new elm();
                    nl5.font      = new Font("Arial", 9);
                    nl5.rectangle = new Rectangle(X, Y, W, H);
                    nl5.stringFormat.Alignment     = StringAlignment.Near;
                    nl5.stringFormat.LineAlignment = StringAlignment.Near;
                    nl5.text = "  TAUX               HT              TVA                 TTC";
                    E.Add(nl5);
                    Y += H;


                    decimal HT  = 0.0m;
                    decimal TVA = 0.0m;
                    decimal TTC = 0.0m;

                    List <mTva> CaseTva = getTVA(e);

                    TotalCaseTVA.Add(CaseTva);

                    foreach (mTva m in CaseTva)
                    {
                        elm eNameTVA = new elm();
                        eNameTVA.rectangle = new Rectangle(X, Y, 45, sizeLine);
                        eNameTVA.stringFormat.Alignment     = StringAlignment.Far;
                        eNameTVA.stringFormat.LineAlignment = StringAlignment.Near;
                        eNameTVA.text = m.tva.val + "%";
                        E.Add(eNameTVA);

                        elm eHT = new elm();
                        eHT.rectangle = new Rectangle(X + 50, Y, 80, sizeLine);
                        eHT.stringFormat.Alignment     = StringAlignment.Far;
                        eHT.stringFormat.LineAlignment = StringAlignment.Near;
                        eHT.text = m.HT.ToString("C");
                        E.Add(eHT);

                        elm eTVA = new elm();
                        eTVA.rectangle = new Rectangle(X + 130, Y, 70, sizeLine);
                        eTVA.stringFormat.Alignment     = StringAlignment.Far;
                        eTVA.stringFormat.LineAlignment = StringAlignment.Near;
                        eTVA.text = m.TVA.ToString("C");
                        E.Add(eTVA);

                        elm eTTC = new elm();
                        eTTC.rectangle = new Rectangle(X + 200, Y, 80, sizeLine);
                        eTTC.stringFormat.Alignment     = StringAlignment.Far;
                        eTTC.stringFormat.LineAlignment = StringAlignment.Near;
                        eTTC.text = m.TTC.ToString("C");
                        E.Add(eTTC);

                        Y   += H;
                        HT  += m.HT;
                        TVA += m.TVA;
                        TTC += m.TTC;
                    }

                    elm eTotal = new elm();
                    eTotal.font      = new Font("Arial", 9, FontStyle.Bold);
                    eTotal.rectangle = new Rectangle(X, Y, 50, sizeLine);
                    eTotal.stringFormat.Alignment     = StringAlignment.Near;
                    eTotal.stringFormat.LineAlignment = StringAlignment.Near;
                    eTotal.text = "TOTAL";
                    E.Add(eTotal);

                    elm eTht = new elm();
                    eTht.font      = new Font("Arial", 9, FontStyle.Bold);
                    eTht.rectangle = new Rectangle(X + 50, Y, 80, sizeLine);
                    eTht.stringFormat.Alignment     = StringAlignment.Far;
                    eTht.stringFormat.LineAlignment = StringAlignment.Near;
                    eTht.text = HT.ToString("C");
                    E.Add(eTht);

                    elm eTTVA = new elm();
                    eTTVA.font      = new Font("Arial", 9, FontStyle.Bold);
                    eTTVA.rectangle = new Rectangle(X + 130, Y, 70, sizeLine);
                    eTTVA.stringFormat.Alignment     = StringAlignment.Far;
                    eTTVA.stringFormat.LineAlignment = StringAlignment.Near;
                    eTTVA.text = TVA.ToString("C");
                    E.Add(eTTVA);

                    elm eTTTC = new elm();
                    eTTTC.font      = new Font("Arial", 9, FontStyle.Bold);
                    eTTTC.rectangle = new Rectangle(X + 200, Y, 80, sizeLine);
                    eTTTC.stringFormat.Alignment     = StringAlignment.Far;
                    eTTTC.stringFormat.LineAlignment = StringAlignment.Near;
                    eTTTC.text = TTC.ToString("C");
                    E.Add(eTTTC);
                    Y += H;

                    mTotal mt = new mTotal();
                    mt.count    = decimal.ToInt32(e.ChecksTicket.Sum(l => l.PayProducts.Sum(la => la.QTY)));
                    mt.sr_total = mt.count != 0 ? TTC / mt.count : 0;
                    mt.name     = e.NameTicket;
                    mt.total    = sumMoney;
                    M.Add(mt);
                }

                if (C.Count > 1)
                {
                    elm TGLOB = new elm();
                    TGLOB.font      = new Font("Arial", 12, FontStyle.Bold);
                    TGLOB.rectangle = new Rectangle(X, Y + 15, W, H);
                    TGLOB.stringFormat.Alignment     = StringAlignment.Center;
                    TGLOB.stringFormat.LineAlignment = StringAlignment.Near;
                    TGLOB.text = "TOTAL GLOBAL";
                    E.Add(TGLOB);
                    Y += H + 15;

                    elm nlzvzz = new elm();
                    nlzvzz.rectangle = new Rectangle(X, Y, 300, H);
                    nlzvzz.text      = "**********************************************************";
                    E.Add(nlzvzz);
                    Y += H;


                    List <ClassCheck.localTypesPay> LTPG = getTypePay(G);

                    decimal sumMoneyG = LTPG.Sum(l => l.value);

                    foreach (var l in LTPG)
                    {
                        elm eNamePay = new elm();
                        eNamePay.rectangle = new Rectangle(X, Y, 120, H);
                        eNamePay.stringFormat.Alignment = StringAlignment.Near;
                        eNamePay.text = l.type.Name;
                        E.Add(eNamePay);

                        elm eValTTC = new elm();
                        eValTTC.rectangle = new Rectangle(X + 120, Y, 80, H);
                        eValTTC.stringFormat.Alignment = StringAlignment.Far;
                        eValTTC.text = l.value.ToString("C");
                        E.Add(eValTTC);

                        elm eProc = new elm();
                        eProc.rectangle = new Rectangle(X + 200, Y, 80, H);
                        eProc.stringFormat.Alignment = StringAlignment.Far;
                        eProc.text = (l.value / sumMoneyG).ToString("P");
                        E.Add(eProc);
                        Y += H;
                    }

                    elm nl4 = new elm();
                    nl4.font      = new Font("Arial", 9, FontStyle.Bold);
                    nl4.rectangle = new Rectangle(X, Y, 120, H);
                    nl4.stringFormat.Alignment = StringAlignment.Near;
                    nl4.text = "TOTAL";
                    E.Add(nl4);

                    elm nsumMoney = new elm();
                    nsumMoney.font      = new Font("Arial", 9, FontStyle.Bold);
                    nsumMoney.rectangle = new Rectangle(X + 120, Y, 80, H);
                    nsumMoney.stringFormat.Alignment = StringAlignment.Far;
                    nsumMoney.text = sumMoneyG.ToString("C");
                    E.Add(nsumMoney);

                    elm nProc100 = new elm();
                    nProc100.font      = new Font("Arial", 9, FontStyle.Bold);
                    nProc100.rectangle = new Rectangle(X + 200, Y, 80, H);
                    nProc100.stringFormat.Alignment = StringAlignment.Far;
                    nProc100.text = 1.ToString("P");
                    E.Add(nProc100);
                    Y += H;

                    decimal GHT  = 0.0m;
                    decimal GTVA = 0.0m;
                    decimal GTTC = 0.0m;

                    List <mTva> tvaS = new List <mTva>();

                    foreach (List <mTva> m in TotalCaseTVA)
                    {
                        foreach (mTva ntva in m)
                        {
                            int indx = tvaS.FindIndex(l => l.tva == ntva.tva);

                            if (indx == -1)
                            {
                                mTva j = new mTva();

                                j.HT = ntva.HT;

                                j.TTC = ntva.TTC;

                                j.tva = ntva.tva;

                                j.TVA = ntva.TVA;

                                tvaS.Add(j);
                            }
                            else
                            {
                                tvaS[indx].HT  += ntva.HT;
                                tvaS[indx].TTC += ntva.TTC;
                                tvaS[indx].TVA += ntva.TVA;
                            }
                        }
                    }

                    elm TiTVA = new elm();
                    TiTVA.font      = new Font("Arial", 10, FontStyle.Bold);
                    TiTVA.rectangle = new Rectangle(X, Y + 10, W, H);
                    TiTVA.stringFormat.Alignment = StringAlignment.Center;
                    TiTVA.text = "*** TVA ***";
                    E.Add(TiTVA);
                    Y += H + 10;

                    elm nl5hed = new elm();
                    nl5hed.font      = new Font("Arial", 9);
                    nl5hed.rectangle = new Rectangle(X, Y, W, H);
                    nl5hed.stringFormat.Alignment     = StringAlignment.Near;
                    nl5hed.stringFormat.LineAlignment = StringAlignment.Near;
                    nl5hed.text = "  TAUX               HT              TVA                 TTC";
                    E.Add(nl5hed);
                    Y += H;

                    foreach (mTva m in tvaS)
                    {
                        elm eNameTVA = new elm();
                        eNameTVA.rectangle = new Rectangle(X, Y, 45, sizeLine);
                        eNameTVA.stringFormat.Alignment     = StringAlignment.Far;
                        eNameTVA.stringFormat.LineAlignment = StringAlignment.Near;
                        eNameTVA.text = m.tva.val + "%";
                        E.Add(eNameTVA);

                        elm eHT = new elm();
                        eHT.rectangle = new Rectangle(X + 50, Y, 80, sizeLine);
                        eHT.stringFormat.Alignment     = StringAlignment.Far;
                        eHT.stringFormat.LineAlignment = StringAlignment.Near;
                        eHT.text = m.HT.ToString("C");
                        E.Add(eHT);

                        elm eTVA = new elm();
                        eTVA.rectangle = new Rectangle(X + 130, Y, 70, sizeLine);
                        eTVA.stringFormat.Alignment     = StringAlignment.Far;
                        eTVA.stringFormat.LineAlignment = StringAlignment.Near;
                        eTVA.text = m.TVA.ToString("C");
                        E.Add(eTVA);

                        elm eTTC = new elm();
                        eTTC.rectangle = new Rectangle(X + 200, Y, 80, sizeLine);
                        eTTC.stringFormat.Alignment     = StringAlignment.Far;
                        eTTC.stringFormat.LineAlignment = StringAlignment.Near;
                        eTTC.text = m.TTC.ToString("C");
                        E.Add(eTTC);

                        Y    += H;
                        GHT  += m.HT;
                        GTVA += m.TVA;
                        GTTC += m.TTC;
                    }

                    elm eTotal = new elm();
                    eTotal.font      = new Font("Arial", 9, FontStyle.Bold);
                    eTotal.rectangle = new Rectangle(X, Y, 50, sizeLine);
                    eTotal.stringFormat.Alignment     = StringAlignment.Near;
                    eTotal.stringFormat.LineAlignment = StringAlignment.Near;
                    eTotal.text = "TOTAL";
                    E.Add(eTotal);

                    elm eTht = new elm();
                    eTht.font      = new Font("Arial", 9, FontStyle.Bold);
                    eTht.rectangle = new Rectangle(X + 50, Y, 80, sizeLine);
                    eTht.stringFormat.Alignment     = StringAlignment.Far;
                    eTht.stringFormat.LineAlignment = StringAlignment.Near;
                    eTht.text = GHT.ToString("C");
                    E.Add(eTht);

                    elm eTTVA = new elm();
                    eTTVA.font      = new Font("Arial", 9, FontStyle.Bold);
                    eTTVA.rectangle = new Rectangle(X + 130, Y, 70, sizeLine);
                    eTTVA.stringFormat.Alignment     = StringAlignment.Far;
                    eTTVA.stringFormat.LineAlignment = StringAlignment.Near;
                    eTTVA.text = GTVA.ToString("C");
                    E.Add(eTTVA);

                    elm eTTTC = new elm();
                    eTTTC.font      = new Font("Arial", 9, FontStyle.Bold);
                    eTTTC.rectangle = new Rectangle(X + 200, Y, 80, sizeLine);
                    eTTTC.stringFormat.Alignment     = StringAlignment.Far;
                    eTTTC.stringFormat.LineAlignment = StringAlignment.Near;
                    eTTTC.text = GTTC.ToString("C");
                    E.Add(eTTTC);
                }


                elm TSTAT = new elm();

                TSTAT.font      = new Font("Arial", 12, FontStyle.Bold);
                TSTAT.rectangle = new Rectangle(X, Y + 15, W, H);
                TSTAT.stringFormat.Alignment     = StringAlignment.Center;
                TSTAT.stringFormat.LineAlignment = StringAlignment.Near;
                TSTAT.text = "STATISTIQUES";
                E.Add(TSTAT);
                Y += H + 15;

                elm nlzvz = new elm();

                nlzvz.rectangle = new Rectangle(X, Y, 300, H);
                nlzvz.text      = "**********************************************************";
                E.Add(nlzvz);
                Y += H;

                elm nl8 = new elm();

                nl8.font      = new Font("Arial", 9);
                nl8.rectangle = new Rectangle(X, Y, W, H);
                nl8.stringFormat.Alignment     = StringAlignment.Near;
                nl8.stringFormat.LineAlignment = StringAlignment.Near;
                nl8.text = "Description             QTY           Moyen             %";
                E.Add(nl8);
                Y += H;

                decimal sumM = M.Sum(l => l.total);

                foreach (mTotal m in M)
                {
                    elm nl9 = new elm();
                    nl9.rectangle = new Rectangle(X, Y, 60, H);
                    nl9.stringFormat.Alignment = StringAlignment.Near;
                    nl9.text = m.name;
                    E.Add(nl9);

                    elm nlcount = new elm();
                    nlcount.rectangle = new Rectangle(X + 60, Y, 80, H);
                    nlcount.stringFormat.Alignment = StringAlignment.Far;
                    nlcount.text = m.count.ToString();
                    E.Add(nlcount);

                    elm nlctt = new elm();
                    nlctt.rectangle = new Rectangle(X + 140, Y, 70, H);
                    nlctt.stringFormat.Alignment = StringAlignment.Far;
                    nlctt.text = m.sr_total.ToString("C");
                    E.Add(nlctt);

                    elm nlsrd = new elm();
                    nlsrd.rectangle = new Rectangle(X + 210, Y, 70, H);
                    nlsrd.stringFormat.Alignment = StringAlignment.Far;
                    nlsrd.text = (sumM == 0 ? 0 : (m.total / sumM)).ToString("P");
                    E.Add(nlsrd);

                    Y += H;
                }

                if (C.Count > 0)
                {
                    elm nl10 = new elm();
                    nl10.rectangle = new Rectangle(X, Y, 60, H);
                    nl10.stringFormat.Alignment = StringAlignment.Near;
                    nl10.text = "TOTAL";
                    E.Add(nl10);


                    elm nl10Tot = new elm();
                    nl10Tot.rectangle = new Rectangle(X + 60, Y, 80, H);
                    nl10Tot.stringFormat.Alignment = StringAlignment.Far;
                    nl10Tot.text = M.Sum(l => l.count).ToString();
                    E.Add(nl10Tot);


                    elm nl10mSum = new elm();
                    nl10mSum.rectangle = new Rectangle(X + 140, Y, 70, H);
                    nl10mSum.stringFormat.Alignment = StringAlignment.Far;
                    nl10mSum.text = Math.Round(M.Sum(l => l.sr_total), 2).ToString("C");
                    E.Add(nl10mSum);


                    elm nl10_100 = new elm();
                    nl10_100.rectangle = new Rectangle(X + 210, Y, 70, H);
                    nl10_100.stringFormat.Alignment = StringAlignment.Far;
                    nl10_100.text = 1.ToString("P");
                    E.Add(nl10_100);
                    Y += H;
                }


                Y += H + 20;
            }
Exemplo n.º 4
0
        private static DotLiquid.Hash CreateDocumentContext(string barcode, string head, List <ClassPrintCheck.groupProduct> lProduct, string total, string sumDiscount, List <ClassPrintCheck.Pays> LPay, decimal rendu, string footer, ticketwindow.Class.ClassPrintCheck.infoOfClient InfoOfClient, bool DuplicateF)
        {
            List <mTva> ltva = new List <mTva>();

            foreach (ClassTVA.tva t in ClassTVA.listTVA)
            {
                mTva n = new mTva();
                n.id  = t.id;
                n.val = t.val;
                n.ht  = 0.0m;
                n.tva = 0.0m;
                ltva.Add(n);
            }

            List <dynamic> listGroup = new List <dynamic>();

            foreach (ClassPrintCheck.groupProduct group in lProduct)
            {
                List <dynamic> listProducts = new List <dynamic>();

                foreach (ClassPrintCheck.groupProduct.product product in group.products)
                {
                    listProducts.Add(new
                    {
                        name  = product.name.Length > 30 ? specTransform(product.name.Substring(0, 30)) : specTransform(product.name),
                        total = product.total.ToString("0.00"),
                        qty   = product.qty,
                        price = product.price.ToString("0.00")
                    });

                    int indx = ltva.FindIndex(l => l.id == product.tva);

                    if (indx != -1)
                    {
                        ltva[indx].tva += product.TvaTotal;
                        ltva[indx].ht  += product.HT;
                    }
                }

                listGroup.Add(new
                {
                    categories = specTransform(group.categories),
                    Products   = listProducts
                });
            }

            List <dynamic> listPay = new List <dynamic>();

            foreach (ClassPrintCheck.Pays pay in LPay)
            {
                if (pay.money != 0)
                {
                    listPay.Add(new { name = pay.type.Name, money = pay.money.ToString("0.00") });
                }
            }

            List <dynamic> listTVA = new List <dynamic>();

            decimal totalTva   = 0;
            decimal totalTVAHT = 0;

            foreach (mTva tva in ltva)
            {
                if (tva.tva != 0)
                {
                    listTVA.Add(new { name = tva.val + "%", money = tva.tva.ToString("0.00"), ht = tva.ht.ToString("0.00") });
                    totalTva   += tva.tva;
                    totalTVAHT += tva.ht;
                }
            }

            if (listTVA.Count == 1)
            {
                totalTva   = 0;
                totalTVAHT = 0;
            }

            string numeroTicket = Environment.NewLine + ClassGlobalVar.nameTicket + " - " + DateTime.Now.ToShortDateString() + " - " + DateTime.Now.ToShortTimeString();

            /*      System.Drawing.Image img = new ClassImageBarCode().get_bc(barcode);
             *
             *    var streamMemory = new System.IO.MemoryStream();
             *    img.Save(streamMemory, System.Drawing.Imaging.ImageFormat.Jpeg);
             *    streamMemory.Position = 0;
             *    string path =  @"d:\bc" + barcode.Substring(8, 10) +".jpg";
             *
             *    FileStream fileStream = File.Create(path, (int)streamMemory.Length);
             *
             *    byte[] bytesInStream = new byte[streamMemory.Length];
             *    streamMemory.Read(bytesInStream, 0, bytesInStream.Length);
             *
             *    fileStream.Write(bytesInStream, 0, bytesInStream.Length);
             */
            string incodeBarcode = "*" + barcode + "*";// BarCode.BarcodeConverter128.StringToBarcode(barcode);

            /*
             * incodeBarcode = barcode;
             *
             * if (incodeBarcode.IndexOfAny(new char[] { '<', '>', '&' }) != -1)
             * {
             *
             *
             *  new ClassLog("BARCODE " + barcode + " INCORRECT '<','>'  " + incodeBarcode);
             *
             *  incodeBarcode = barcode;// incodeBarcode.Replace("<", "&lt;").Replace(">", "&gt;");
             * }
             */

            var context = new
            {
                Duplicate     = DuplicateF ? "*** DUPLICATA ***" : null,
                GroupProducts = listGroup,
                Header        = head,
                TotalTTC      = total,
                Pays          = listPay,
                TVA           = listTVA,
                TotalTVA      = totalTva == 0 ? null : totalTva.ToString("0.00"),
                TotalTVAHT    = totalTVAHT == 0 ? null : totalTVAHT.ToString("0.00"),
                BARCODE       = barcode,
                Rendu         = (rendu == 0 ? null : rendu.ToString()),
                Discount      = sumDiscount == "0,00" ? null : sumDiscount,
                Footer        = footer,
                NumeroTicket  = numeroTicket,
                DCBC_name     = InfoOfClient != null ? InfoOfClient.DCBC_name : null,
                DCBC          = InfoOfClient != null?InfoOfClient.DCBC.Substring(0, 5) + "xx-xxx-xx" + InfoOfClient.DCBC.Substring(InfoOfClient.DCBC.Length - 1, 1) : null,
                                    DCBC_BiloPoints     = InfoOfClient != null ? InfoOfClient.DCBC_BiloPoints : null,
                                    DCBC_DobavilePoints = InfoOfClient != null ? InfoOfClient.DCBC_DobavilePoints : null,
                                    DCBC_OstalosPoints  = InfoOfClient != null ? InfoOfClient.DCBC_OstalosPoints : null,
                                    DCBC_OtnayliP       = InfoOfClient != null ? InfoOfClient.DCBC_OtnayliP : null,
                                    IncodeBarcode       = incodeBarcode,
                                    Facture             = ClassProMode.modePro ? "" : null
            };



            return(DotLiquid.Hash.FromAnonymousObject(context));
        }