예제 #1
0
 void SetPrefix()
 {
     Broker.DataAccess.Parameter parHasCompanyPrefixes = Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.SE_KORISTAT_PREFIKSI);
     if (parHasCompanyPrefixes != null)
     {
         bool hasCompanyPrefixes = Convert.ToBoolean(parHasCompanyPrefixes.Value);
         if (hasCompanyPrefixes == true)
         {
             lblInsuranceCompanyPrefix.Visible = true;
             tbInsuranceCompanyPrefix.Visible  = true;
             if (ddlInsuranceCompany.SelectedValue != null)
             {
                 InsuranceCompany ic;
                 if (ddlInsuranceCompany.SelectedValue != string.Empty)
                 {
                     ic = InsuranceCompany.Get(Convert.ToInt32(ddlInsuranceCompany.SelectedValue));
                 }
                 else
                 {
                     ddlInsuranceCompany.DataBind();
                     if (ddlInsuranceCompany.Items.Count > 0)
                     {
                         ic = InsuranceCompany.Get(Convert.ToInt32(ddlInsuranceCompany.Items[0].Value));
                     }
                     else
                     {
                         ic = null;
                     }
                 }
                 if (ic != null)
                 {
                     if (ic.Prefix != null)
                     {
                         tbInsuranceCompanyPrefix.Text = ic.Prefix;
                     }
                 }
             }
         }
         else
         {
             lblInsuranceCompanyPrefix.Visible = false;
             tbInsuranceCompanyPrefix.Visible  = false;
         }
     }
     else
     {
         lblInsuranceCompanyPrefix.Visible = false;
         tbInsuranceCompanyPrefix.Visible  = false;
     }
 }
예제 #2
0
    void SetNewPaidValue(List <FinCardSaldo> lst, decimal newValue)
    {
        //previous way
        decimal restValue   = newValue;
        decimal perPolValue = 0;
        int     count       = lst.Count;
        int     i           = 0;

        Broker.DataAccess.Parameter minPercetageForFirstRatePar = Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZADOLZITELEN_PROCENT_ZA_PRVA_RATA);
        decimal minPercetageForFirstRate = Convert.ToDecimal(minPercetageForFirstRatePar.Value);

        foreach (FinCardSaldo fcs in lst)
        {
            TextBox tbNewPayment = gvNewPayments.Rows[i].FindControl("tbNewPayment") as TextBox;
            perPolValue = RateController.Scale5(restValue / count);
            Policy  p                    = Policy.Get(fcs.id);
            decimal policyValue          = p.PolicyItems[0].PremiumValue;
            decimal minValueForFirstRate = RateController.Scale5(policyValue * minPercetageForFirstRate / 100);
            if (perPolValue <= fcs.saldo)
            {
                restValue        -= perPolValue;
                tbNewPayment.Text = perPolValue.ToString();
            }
            else
            {
                restValue        -= fcs.saldo;
                tbNewPayment.Text = fcs.saldo.ToString();
            }
            count--;
            i++;
        }

        //new way
        //decimal restValue = newValue;
        //int count = lst.Count;
        //int i = 0;
        //foreach (FinCardSaldo fcs in lst) {
        //    TextBox tbNewPayment = gvNewPayments.Rows[i].FindControl("tbNewPayment") as TextBox;
        //    if (restValue > fcs.saldo) {
        //        tbNewPayment.Text = fcs.saldo.ToString();
        //        restValue -= fcs.saldo;
        //    } else {
        //        tbNewPayment.Text = restValue.ToString();
        //        break;
        //    }
        //    count--;
        //    i++;
        //}
    }
예제 #3
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        DistributionDocType ddt = DistributionDocType.GetByCode(DistributionDocType.POVRATNICA);
        List <Distribution> addedDistributions = new List <Distribution>();
        string endNumber   = tbEndNumber.Text;
        string startNumber = tbStartNumber.Text;
        long   count       = Convert.ToInt64(endNumber) - Convert.ToInt64(startNumber);
        List <Distribution> lstDistributions = new List <Distribution>();
        bool hasErrors = false;

        for (int i = 0; i <= count; i++)
        {
            Distribution d = new Distribution();
            d.Date               = DateTime.Today;
            d.BranchID           = null;
            d.InsuranceCompanyID = int.Parse(ddlInsuranceCompany.SelectedValue);
            d.InsuranceSubTypeID = int.Parse(ddlInsuranceSubType.SelectedValue);
            d.UserID             = Broker.DataAccess.User.GetFirstSEAdminUser().ID;
            string number = (Convert.ToInt64(tbStartNumber.Text) + i).ToString();
            for (int j = 0; j < (endNumber.Length - Convert.ToInt64(number).ToString().Length); j++)
            {
                number = "0" + number;
            }
            Broker.DataAccess.Parameter parHasPrefix = Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.SE_KORISTAT_PREFIKSI);
            if (parHasPrefix != null)
            {
                bool hasPrefix = Convert.ToBoolean(parHasPrefix.Value);
                if (hasPrefix == true)
                {
                    string prefix = tbInsuranceCompanyPrefix.Text;
                    number = prefix + number;
                }
            }
            d.PolicyNumber         = number;
            d.IsUsed               = false;
            d.DistributionStatusID = DistributionStatuse.GetByCode(DistributionStatuse.VRATENA).ID;
            d.ValidateNumberForPovratnica(this.PageUser.BranchID);
            if (d.ValidationErrors.Count > 0)
            {
                hasErrors = true;
                break;
            }
            else
            {
                lstDistributions.Add(d);
            }
        }
        if (hasErrors == false)
        {
            DistributionDocument dd = DistributionDocument.GetByDocumentNumber(tbDocumentNumber.Text);
            if (dd == null)
            {
                dd          = new DistributionDocument();
                dd.BranchID = this.PageUser.BranchID;
                dd.DistributionDocTypeID = ddt.ID;
                dd.DocumentDate          = DateTime.Today;
                dd.DocumentNumber        = tbDocumentNumber.Text;
                dd.DocumentStatusID      = DistributionDocumentStatuse.GetByCode(DistributionDocumentStatuse.ZA_PRIMANjE).ID;
                dd.Description           = tbDescription.Text;
                dd.Insert();
            }
            //Add routes
            DistributionRoute dr = new DistributionRoute();
            dr.Date = DateTime.Today;
            dr.DistributionDocumentID = dd.ID;
            dr.FromNumber             = startNumber;
            dr.ToNumber           = endNumber;
            dr.FromUserID         = this.PageUser.ID;
            dr.ToUserID           = Broker.DataAccess.User.GetFirstSEAdminUser().ID;
            dr.InsuranceCompanyID = Convert.ToInt32(ddlInsuranceCompany.SelectedValue);
            dr.InsuranceSubTypeID = Convert.ToInt32(ddlInsuranceSubType.SelectedValue);
            dr.Insert();
            //Update distributions
            foreach (Distribution distr in lstDistributions)
            {
                Distribution dis = Distribution.Table.Where(c => c.InsuranceCompanyID == distr.InsuranceCompanyID && c.InsuranceSubTypeID == c.InsuranceSubTypeID &&
                                                            c.PolicyNumber == distr.PolicyNumber).SingleOrDefault();
                dis.BranchID             = null;
                dis.DistributionStatusID = DistributionStatuse.GetByCode(DistributionStatuse.VRATENA).ID;
                dis.UserID = Broker.DataAccess.User.GetFirstSEAdminUser().ID;
                Distribution.Table.Context.SubmitChanges();
                DistributionDocumentItem ddi = new DistributionDocumentItem();
                ddi.DistributionDocumentID = dd.ID;
                ddi.DistributionID         = dis.ID;
                ddi.Insert();
                addedDistributions.Add(dis);
            }
            btnPrintDocument.Enabled = true;
            lblError.Text            = "";
            lblError.Visible         = false;
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = "Полисата е искористена или не постои како потврдена во филијала!!";
        }

        gvNewDistrirutions.DataSource = addedDistributions;
        gvNewDistrirutions.DataBind();
        gvDistributions.DataBind();
    }
예제 #4
0
        public static void PrintFacture(Broker.DataAccess.Facture f)
        {
            string brokerName = BrokerHouseInformation.GetBrokerHouseName();

            if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_PROVIZIJA || f.DocumentSubType.Code == DocumentSubType.IZLEZNA_FAKTURA_ZA_PROVZIJA_ZA_ZIVOTNO_OSUGURUVANjE)
            {
                PDFCreators creator = new PDFCreators(true, 25, 25, 15, 15);
                creator.SetDocumentHeaderFooter();
                creator.OpenPDF();
                creator.GetContentByte();
                creator.AddJDBLogoForFactures(10, 775);
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_PROVIZIJA)
                {
                    creator.SetTitleLeft8("   Жиро-сметка :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA_ZA_OSIG_KOMPANII).Value);
                }
                else if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_KLIENT)
                {
                    creator.SetTitleLeft8("   Жиро-сметка :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA).Value);
                }
                creator.SetTitleLeft8("   Депонент :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.DEPONENT).Value);
                creator.SetTitleLeft8("   ЕДБ :   " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.EDB).Value + "       " + "Матичен број :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.MATICEN_BROJ).Value);

                creator.SetTitleLeft8("  ");
                if (f.Discard)
                {
                    creator.SetTitleCenterForFactureNumber("СТОРНИРАНА Ф-ра бр. " + f.FactureNumber);
                }
                else
                {
                    creator.SetTitleCenterForFactureNumber("Фактура бр. " + f.FactureNumber);
                }
                string internalCode = "";
                try
                {
                    FinansovoDataClassesDataContext fdc = new FinansovoDataClassesDataContext();
                    List <Client> listCLients           = fdc.Clients.Where(c => c.EMBG == f.Client.EMBG).ToList();
                    if (listCLients.Count > 0)
                    {
                        internalCode = listCLients[0].Code;
                    }
                }
                catch { }
                if (internalCode != string.Empty)
                {
                    creator.SetTitleLeftWithFontSize10(internalCode);
                }
                creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Name).ToUpper());
                creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Address).ToUpper());
                //creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Place.Municipality.Name).ToUpper());
                creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Place.Name).ToUpper());
                creator.SetTitleLeft10("Датум на фактура: " + f.DateOfCreation.ToShortDateString());
                creator.SetTitleLeft10("Рок на плаќање: " + f.DateOfPayment.ToShortDateString());
                //creator.SetTitleLeft8("Период: " + f.FromDate.ToShortDateString() + " - " + f.ToDate.ToShortDateString());

                string[]   headers          = { "Ред. бр.", "Опис", "Количина", "Премија", "Брокеража" };
                float[]    widthPercentages = { 8, 45, 15, 17, 15 };
                TypeCode[] typeCodes        = { TypeCode.Int32, TypeCode.String, TypeCode.Int32, TypeCode.Decimal, TypeCode.Decimal };
                creator.CreateTable_Facture(headers.Length, headers, widthPercentages);
                object[] values;
                foreach (FactureItem fi in f.FactureItems)
                {
                    values    = new object[headers.Length];
                    values[0] = fi.Number.ToString();
                    values[1] = fi.Description;
                    values[2] = fi.Count.ToString();
                    values[3] = String.Format("{0:#,0.00}", fi.PremiumValue);
                    values[4] = String.Format("{0:#,0.00}", fi.BrokerageValue);
                    creator.AddDataRowForFactures(values, headers.Length, typeCodes);
                }
                values    = new object[headers.Length];
                values[0] = "";
                values[1] = "";
                values[2] = "";
                values[3] = "Вкупно";
                values[4] = String.Format("{0:#,0.00}", f.BrokerageValue);
                creator.AddDataRowForFactures(values, headers.Length, typeCodes);
                creator.AddTable();
                creator.SetTitleLeftBold14(" ");
                creator.SetTitleLeftItalic10("Со букви: " + NumberToTextController.Konvertiranje(f.BrokerageValue));
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("Ве молиме фактурираниот износ да го платите до назначениот рок на плаќање.");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("Доколку износот за фактурата не биде платен до наведениот датум, се пресметува затезна камата од денот на стасаност до денот на плаќањето.");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("Согласно со член 23, точка 6 од Законот за ДДВ дејноста осигурување е ослободена од плаќање данок без право на одбиток на претходниот данок.");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("                          Фактурирал                                              Примил                                                           Одобрил");
                creator.SetTitleLeft10("                    _________________                            __________________                                  ____________________");

                creator.AddPage();
                creator.SetTitleCenterForFactureNumber("Спецификација за фактура бр. " + f.FactureNumber);
                string[]   headersSpecifications          = { "Ред. бр.", "Број на полиса", "Почеток", "Истек", "Дата на издавање", "Премија" };
                float[]    widthPercentagesSpecifications = { 10, 20, 19, 19, 19, 13 };
                TypeCode[] typeCodesSpecifications        = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal };
                object[]   valuesSpecifications;
                foreach (FactureItem fi in f.FactureItems)
                {
                    creator.SetTitleLeft10Bold(fi.InsuranceSubType.Description);
                    creator.CreateTable_Facture(headersSpecifications.Length, headersSpecifications, widthPercentagesSpecifications);
                    if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_PROVIZIJA)
                    {
                        List <PolicyItemFactureItem> pifiList = PolicyItemFactureItem.GetByFactureItemID(fi.ID);
                        int ordinalNumber = 1;
                        foreach (PolicyItemFactureItem pifi in pifiList)
                        {
                            valuesSpecifications    = new object[6];
                            valuesSpecifications[0] = ordinalNumber;
                            valuesSpecifications[1] = pifi.PolicyItem.PolicyNumber;
                            valuesSpecifications[2] = pifi.PolicyItem.Policy.StartDate.ToShortDateString();
                            valuesSpecifications[3] = pifi.PolicyItem.Policy.EndDate.ToShortDateString();
                            valuesSpecifications[4] = pifi.PolicyItem.Policy.ApplicationDate.ToShortDateString();
                            valuesSpecifications[5] = pifi.PolicyItem.PremiumValue;
                            creator.AddDataRowForFacturesExtend(valuesSpecifications, headersSpecifications.Length, typeCodesSpecifications, headersSpecifications, widthPercentagesSpecifications);
                            ordinalNumber++;
                        }
                    }
                    if (f.DocumentSubType.Code == DocumentSubType.IZLEZNA_FAKTURA_ZA_PROVZIJA_ZA_ZIVOTNO_OSUGURUVANjE)
                    {
                        List <LifePolicyFactureItem> pifiList = LifePolicyFactureItem.GetByFactureItemID(fi.ID);
                        int ordinalNumber = 1;
                        foreach (LifePolicyFactureItem pifi in pifiList)
                        {
                            valuesSpecifications    = new object[6];
                            valuesSpecifications[0] = ordinalNumber;
                            valuesSpecifications[1] = pifi.LifePolicy.PolicyNumber;
                            valuesSpecifications[2] = pifi.LifePolicy.StartDate.ToShortDateString();
                            valuesSpecifications[3] = pifi.LifePolicy.EndDate.ToShortDateString();
                            valuesSpecifications[4] = pifi.LifePolicy.ApplicationDate.ToShortDateString();
                            valuesSpecifications[5] = pifi.LifePolicy.TotalPremumValue;
                            creator.AddDataRowForFacturesExtend(valuesSpecifications, headersSpecifications.Length, typeCodesSpecifications, headersSpecifications, widthPercentagesSpecifications);
                            ordinalNumber++;
                        }
                    }
                    creator.AddTable();
                    creator.SetTitleCenterForFactureNumber(" ");
                }

                creator.FinishPDF_FileName("Factura" + f.FactureNumber);
            }
            if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_KLIENT)
            {
                PDFCreators creator = new PDFCreators(true, 25, 25, 15, 15);
                creator.SetDocumentHeaderFooter();
                creator.OpenPDF();
                creator.GetContentByte();
                creator.AddJDBLogoForFactures(10, 775);
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8("   Жиро-сметка :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA).Value);
                creator.SetTitleLeft8("   Депонент :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.DEPONENT).Value);
                creator.SetTitleLeft8("   ЕДБ :   " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.EDB).Value + "       " + "Матичен број :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.MATICEN_BROJ).Value);
                creator.SetTitleLeft8("  ");
                if (f.Discard)
                {
                    creator.SetTitleCenterForFactureNumber("СТОРНИРАНА Ф-ра бр. " + f.FactureNumber);
                }
                else
                {
                    creator.SetTitleCenterForFactureNumber("Фактура бр. " + f.FactureNumber);
                }
                string internalCode = "";
                try
                {
                    FinansovoDataClassesDataContext fdc = new FinansovoDataClassesDataContext();
                    List <Client> listCLients           = fdc.Clients.Where(c => c.EMBG == f.Client.EMBG).ToList();
                    if (listCLients.Count > 0)
                    {
                        internalCode = listCLients[0].Code;
                    }
                }
                catch { }
                if (internalCode != string.Empty)
                {
                    creator.SetTitleLeftWithFontSize10(internalCode);
                }
                creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Name).ToUpper());
                creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Address).ToUpper());
                creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Place.Municipality.Name).ToUpper());
                creator.SetTitleLeft10("Датум на фактура: " + f.DateOfCreation.ToShortDateString());
                creator.SetTitleLeft10("Рок на плаќање: " + f.DateOfPayment.ToShortDateString());
                //creator.SetTitleLeft8("Период: " + f.FromDate.ToShortDateString() + " - " + f.ToDate.ToShortDateString());

                string[]   headers          = { "Ред. бр.", "Број на полиса", "Осиг. комапнија", "Тип на осигурување", "Премија" };
                float[]    widthPercentages = { 8, 17, 30, 30, 15 };
                TypeCode[] typeCodes        = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal };
                creator.CreateTable_Facture(headers.Length, headers, widthPercentages);
                object[] values;

                foreach (FactureItem fi in f.FactureItems)
                {
                    List <PolicyItemFactureItem> pifi = PolicyItemFactureItem.GetByFactureItemID(fi.ID);
                    values    = new object[headers.Length];
                    values[0] = fi.Number.ToString();
                    values[1] = pifi[0].PolicyItem.PolicyNumber;
                    values[2] = pifi[0].PolicyItem.Policy.InsuranceCompany.ShortName;
                    values[3] = pifi[0].PolicyItem.InsuranceSubType.ShortDescription;
                    values[4] = String.Format("{0:#,0.00}", fi.PremiumValue) + " ДЕН.";
                    creator.AddDataRowForFactures(values, headers.Length, typeCodes);
                }
                values    = new object[headers.Length];
                values[0] = "";
                values[1] = "";
                values[2] = "";
                values[3] = "Вкупно";
                values[4] = String.Format("{0:#,0.00}", f.TotalCost) + " ДЕН.";
                creator.AddDataRowForFactures(values, headers.Length, typeCodes);
                creator.AddTable();
                creator.SetTitleLeftBold14(" ");
                creator.SetTitleLeftItalic10("Со букви: " + NumberToTextController.Konvertiranje(f.TotalCost));
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("Ве молиме фактурираниот износ да го платите до назначениот рок на плаќање.");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("Доколку износот за фактурата не биде платен до наведениот датум, се пресметува затезна камата од денот на стасаност до денот на плаќањето.");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("Согласно со член 23, точка 6 од Законот за ДДВ дејноста осигурување е ослободена од плаќање данок без право на одбиток на претходниот данок.");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("                          Фактурирал                                              Примил                                                          Одобрил");
                creator.SetTitleLeft10("                    _________________                            __________________                                  ____________________");

                Broker.DataAccess.Parameter pSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT = Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.SE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT);
                bool fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT = true;
                if (pSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT != null)
                {
                    if (Convert.ToBoolean(pSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT.Value) == false)
                    {
                        fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT = false;
                    }
                }
                if (fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT)
                {
                    string facItemDescriptionStart = "Полиса - ";
                    creator.AddPage();
                    foreach (FactureItem fi in f.FactureItems)
                    {
                        string polNumber = fi.Description.Substring(facItemDescriptionStart.Length);
                        creator.SetTitleLeft10(facItemDescriptionStart + polNumber);
                        string[]   headersRates          = { "Рата бр.", "Дата за плаќање", "Износ" };
                        float[]    widthPercentagesRates = { 15, 50, 35 };
                        TypeCode[] typeCodesRates        = { TypeCode.Int32, TypeCode.String, TypeCode.Decimal };
                        creator.CreateTable_Facture(headersRates.Length, headersRates, widthPercentagesRates);
                        PolicyItem  pi    = PolicyItem.GetByNumberAndInsuranceSubType(polNumber, fi.InsuranceSubTypeID, (int)fi.Facture.InsuranceCompanyID);
                        List <Rate> rates = Rate.GetByPolicyItemID(pi.ID);
                        rates = rates.OrderBy(c => c.Number).ToList();
                        foreach (Rate r in rates)
                        {
                            object[] valuesRates = new object[headersRates.Length];
                            valuesRates[0] = r.Number;
                            valuesRates[1] = r.Date.ToShortDateString();
                            valuesRates[2] = String.Format("{0:#,0.00}", r.Value);
                            creator.AddDataRowForFactures(valuesRates, headersRates.Length, typeCodes);
                        }
                        creator.AddTable();
                    }
                }
                creator.FinishPDF_FileName("Factura" + f.FactureNumber);
            }
            if (f.DocumentSubType.Code == DocumentSubType.GRUPNA_FAKTURA)
            {
                PDFCreators creator = new PDFCreators(true, 25, 25, 15, 15);
                creator.SetDocumentHeaderFooter();
                creator.OpenPDF();
                creator.GetContentByte();
                creator.AddJDBLogoForFactures(10, 775);
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8("   Жиро-сметка :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.ZIRO_SMETKA).Value);
                creator.SetTitleLeft8("   Депонент :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.DEPONENT).Value);
                creator.SetTitleLeft8("   ЕДБ :   " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.EDB).Value + "       " + "Матичен број :  " + Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.MATICEN_BROJ).Value);
                creator.SetTitleLeft8("  ");
                if (f.Discard)
                {
                    creator.SetTitleCenterForFactureNumber("СТОРНИРАНА Фактура бр. " + f.FactureNumber);
                }
                else
                {
                    creator.SetTitleCenterForFactureNumber("Фактура бр. " + f.FactureNumber);
                }
                string internalCode = "";
                try
                {
                    FinansovoDataClassesDataContext fdc = new FinansovoDataClassesDataContext();
                    List <Client> listCLients           = fdc.Clients.Where(c => c.EMBG == f.Client.EMBG).ToList();
                    if (listCLients.Count > 0)
                    {
                        internalCode = listCLients[0].Code;
                    }
                }
                catch { }
                if (internalCode != string.Empty)
                {
                    creator.SetTitleLeftWithFontSize10(internalCode);
                }
                creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Name).ToUpper());
                creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Address).ToUpper());
                creator.SetTitleLeftWithFontSize10(ConvertToMacedonian.ConvertToMACEDONIAN(f.Client.Place.Municipality.Name).ToUpper());
                creator.SetTitleLeft10("Датум на фактура: " + f.DateOfCreation.ToShortDateString());
                creator.SetTitleLeft10("Рок на плаќање: " + f.DateOfPayment.ToShortDateString());
                string[]   headers          = { "Ред. бр.", "Број на полиса", "Осиг. компанија", "Тип на осигурување", "Премија" };
                float[]    widthPercentages = { 8, 17, 30, 30, 15 };
                TypeCode[] typeCodes        = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal };
                creator.CreateTable_Facture(headers.Length, headers, widthPercentages);
                object[] values;
                foreach (FactureItem fi in f.FactureItems)
                {
                    List <PolicyItemFactureItem> pifi = PolicyItemFactureItem.GetByFactureItemID(fi.ID);
                    values    = new object[headers.Length];
                    values[0] = fi.Number.ToString();
                    values[1] = pifi[0].PolicyItem.PolicyNumber;
                    values[2] = pifi[0].PolicyItem.Policy.InsuranceCompany.ShortName;
                    values[3] = pifi[0].PolicyItem.InsuranceSubType.ShortDescription;
                    values[4] = String.Format("{0:#,0.00}", fi.PremiumValue) + " ДЕН.";
                    creator.AddDataRowForFactures(values, headers.Length, typeCodes);
                }
                values    = new object[headers.Length];
                values[0] = "";
                values[1] = "";
                values[2] = "";
                values[3] = "Вкупно";
                values[4] = String.Format("{0:#,0.00}", f.TotalCost) + " ДЕН.";
                creator.AddDataRowForFactures(values, headers.Length, typeCodes);
                creator.AddTable();
                creator.SetTitleLeftBold14(" ");
                creator.SetTitleLeftItalic10("Со букви: " + NumberToTextController.Konvertiranje(f.TotalCost));
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("Ве молиме фактурираниот износ да го платите до назначениот рок на плаќање.");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("Доколку износот за фактурата не биде платен до наведениот датум, се пресметува затезна камата од денот на стасаност до денот на плаќањето.");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("Согласно со член 23, точка 6 од Законот за ДДВ дејноста осигурување е ослободена од плаќање данок без право на одбиток на претходниот данок.");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft8(" ");
                creator.SetTitleLeft10("                          Фактурирал                                              Примил                                                          Одобрил");
                creator.SetTitleLeft10("                    _________________                            __________________                                  ____________________");

                bool fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT = true;
                if (Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.SE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT) != null)
                {
                    fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT = Boolean.Parse(Broker.DataAccess.Parameter.GetByCode(Broker.DataAccess.Parameter.SE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT).Value);
                }


                if (fpSE_PECATI_SPECIFIKACIJA_NA_F_RA_ZA_KLIENT)
                {
                    string facItemDescriptionStart = "Полиса бр. ";
                    creator.AddPage();
                    foreach (FactureItem fi in f.FactureItems)
                    {
                        string polNumber = fi.Description.Substring(facItemDescriptionStart.Length);
                        creator.SetTitleLeft10(facItemDescriptionStart + polNumber);
                        string[]   headersRates          = { "Рата бр.", "Дата за плаќање", "Износ" };
                        float[]    widthPercentagesRates = { 15, 50, 35 };
                        TypeCode[] typeCodesRates        = { TypeCode.Int32, TypeCode.String, TypeCode.Decimal };
                        creator.CreateTable_Facture(headersRates.Length, headersRates, widthPercentagesRates);
                        PolicyItem  pi    = PolicyItem.GetByNumberAndInsuranceSubType(polNumber, fi.InsuranceSubTypeID, (int)fi.Facture.InsuranceCompanyID);
                        List <Rate> rates = Rate.GetByPolicyItemID(pi.ID);
                        rates = rates.OrderBy(c => c.Number).ToList();
                        foreach (Rate r in rates)
                        {
                            object[] valuesRates = new object[headersRates.Length];
                            valuesRates[0] = r.Number;
                            valuesRates[1] = r.Date.ToShortDateString();
                            valuesRates[2] = String.Format("{0:#,0.00}", r.Value);
                            creator.AddDataRowForFactures(valuesRates, headersRates.Length, typeCodes);
                        }
                        creator.AddTable();
                    }
                }



                creator.FinishPDF_FileName("Factura" + f.FactureNumber);
            }
        }