Example #1
0
 protected void btnPaymentsPerFacture_Click(object sender, EventArgs e)
 {
     if (GXGridView1SelectedValue > 0)
     {
         Broker.DataAccess.Facture f = Broker.DataAccess.Facture.Get(GXGridView1SelectedValue);
         if (f.DocumentSubType.Code != DocumentSubType.FAKTURA_PROVIZIJA)
         {
             mvMain.SetActiveView(viewPayments);
             GridViewMainFinCard.DataBind();
             dvFacturePreviewForPayments.DataBind();
             SetSaldoValues();
             btnNew.CssClass                = "novZapis";
             btnPreview.CssClass            = "osvezi";
             btnReport.CssClass             = "izvestaj";
             btnSearch.CssClass             = "prebaraj";
             btnFactureItems.CssClass       = "prikaz";
             btnChangeStatus.CssClass       = "promeniStatus";
             btnAttachments.CssClass        = "dokumenti";
             btnPaymentsPerFacture.CssClass = "plakanja_Active";
         }
         else
         {
             RegisterStartupScript("myAlert", "<script>alert('Фактурата не е кон клиент!')</script>");
         }
     }
 }
Example #2
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string factureNumber = tbFactureNumber.Text;

        try {
            Broker.DataAccess.Facture f = Broker.DataAccess.Facture.GetByNumber(factureNumber);

            if (f != null)
            {
                UpdateTextBoxes(f);
                lblFeedback.Text = string.Empty;
                gvFactureItemsPreview.DataBind();
                btnGenerate.Enabled     = true;
                tbInsuranceCompany.Text = f.InsuranceCompany.ShortName;
            }
            else
            {
                lblFeedback.Text = "Не е пронајдена фактура!";
            }
            GridViewPayments.DataBind();
        } catch (Exception ex) {
            lblFeedback.Text    = "Изберете фактура!";
            btnGenerate.Enabled = false;
            btnInsert.Enabled   = false;
        }
    }
Example #3
0
 public static void ValidateUpdateFactureNumber(int factureID, string factureNumber)
 {
     Broker.DataAccess.Facture facture = new Broker.DataAccess.Facture();
     facture.FactureNumber = factureNumber;
     facture.ID            = factureID;
     facture.TestBeforeUpdate();
 }
Example #4
0
 protected void btnPrintAnex_Click(object sender, EventArgs e)
 {
     if (FactureID > 0)
     {
         Broker.DataAccess.Facture f = Broker.DataAccess.Facture.Get(FactureID);
         PrintFactures.PrintAnex(f);
     }
 }
Example #5
0
 protected void btnUpdateFactureStatus_Click(object sender, EventArgs e)
 {
     if (dvChangeStatus.SelectedValue != null)
     {
         int factureID = Convert.ToInt32(dvChangeStatus.SelectedValue);
         Broker.DataAccess.Facture f = Broker.DataAccess.Facture.Get(factureID);
         DropDownList ddlStatuses    = (DropDownList)dvChangeStatus.FindControl("ddlStatuses");
         f.StatusID = Convert.ToInt32(ddlStatuses.SelectedValue);
         Broker.DataAccess.Facture.Table.Context.SubmitChanges();
         GXGridView1.DataBind();
         mvMain.SetActiveView(viewGrid);
     }
 }
Example #6
0
    protected void odsPaidPayments_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        string factureNumber = tbFactureNumber.Text;

        try {
            Broker.DataAccess.Facture f = Broker.DataAccess.Facture.GetByNumber(factureNumber);

            if (f != null)
            {
                e.InputParameters.Clear();
                e.InputParameters.Add("factureID", f.ID.ToString());
            }
        } catch (Exception ex) {
        }
    }
Example #7
0
        public static List <PolicyItem> GetForFacture(Facture f, int insuranceCompanyID)
        {
            List <PolicyItem> pList = new List <PolicyItem>();

            List <Payment> paymentList = Payment.GetByDateAndInsuranceCompany(f.FromDate, f.ToDate, insuranceCompanyID);

            foreach (Payment pay in paymentList)
            {
                if (!pList.Contains(pay.Rate.PolicyItem))
                {
                    pList.Add(pay.Rate.PolicyItem);
                }
            }
            return(pList);
        }
Example #8
0
 void BrokerageInFactureChangeStatusPreview()
 {
     if (GXGridView1SelectedValue > 0)
     {
         Broker.DataAccess.Facture f   = Broker.DataAccess.Facture.Get(GXGridView1SelectedValue);
         DataControlField          dcf = dvChangeStatus.Fields[3];
         if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_PROVIZIJA)
         {
             dcf.Visible = true;
         }
         else if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_KLIENT || f.DocumentSubType.Code == DocumentSubType.GRUPNA_FAKTURA)
         {
             dcf.Visible = false;
         }
     }
 }
Example #9
0
 void BrokerageInFactureItemsPreview()
 {
     if (GXGridView1SelectedValue > 0)
     {
         Broker.DataAccess.Facture f     = Broker.DataAccess.Facture.Get(GXGridView1SelectedValue);
         DataControlField          dcf   = DetailsViewFacturePreview.Fields[3];
         DataControlField          dcfGV = GridViewFactureItems.Columns[4];
         if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_PROVIZIJA)
         {
             dcf.Visible   = true;
             dcfGV.Visible = true;
         }
         else if (f.DocumentSubType.Code == DocumentSubType.FAKTURA_KLIENT || f.DocumentSubType.Code == DocumentSubType.GRUPNA_FAKTURA)
         {
             dcf.Visible   = false;
             dcfGV.Visible = false;
         }
     }
 }
Example #10
0
        public static void DeleteExtend(Payment entityToDelete)
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            string firstQuery         = @"DELETE FROM PaymentsPerInsSubTypes WHERE PaymentID = " + entityToDelete.ID;

            dc.ExecuteCommand(firstQuery);
            string query = @"DELETE FROM Payments WHERE ID = " + entityToDelete.ID;

            dc.ExecuteCommand(query);
            Rate    r = Rate.Get(entityToDelete.RateID);
            decimal oldRatePaidValue = r.PaidValue;
            decimal newRatePaidValue = oldRatePaidValue - entityToDelete.Value;
            string  valuePaid        = newRatePaidValue.ToString();

            valuePaid = valuePaid.Replace(',', '.');
            string queryRate = "Update Rates Set PaidValue = " + valuePaid + " Where ID = " + r.ID;

            dc.ExecuteCommand(queryRate);
            Facture.UpdatePaidStatusForFactureExtend(r.PolicyItemID);
        }
Example #11
0
        public static string DeletePolicy(int piID)
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            string       retString    = "Полисата е избришана.";
            PolicyItem   pi           = PolicyItem.Get(piID);
            Distribution d            = Distribution.GetByNumberAndSubTypeAndCompany(pi.InsuranceSubTypeID, pi.PolicyNumber, pi.Policy.InsuranceCompanyID);
            Policy       p            = Policy.Get(pi.PolicyID);
            List <RollBackDistributionItem> listRDI = RollBackDistributionItem.Table.Where(c => c.PolicyItemID == pi.ID).ToList();

            if (listRDI.Count > 0)
            {
                retString = "Полисата е раздолжена и не може да се брише!";
                return(retString);
            }

            List <Rate> lstRates = Rate.GetByPolicyItemID(pi.ID);

            if (lstRates.Count > 0)
            {
                List <Payment> lstPayments = Payment.GetByRateID(lstRates[0].ID);
                if (lstPayments.Count > 0)
                {
                    if (lstPayments[0].IsFactured)
                    {
                        retString = "Полисата е фактурирана за брокеража и не може да се брише!";
                        return(retString);
                    }
                }
                foreach (Rate r in lstRates)
                {
                    List <Payment> lstP = Payment.GetByRateID(r.ID);
                    foreach (Payment pay in lstP)
                    {
                        List <PaymentsPerInsSubType> lstPPIST = PaymentsPerInsSubType.GetByPayment(pay.ID);
                        foreach (PaymentsPerInsSubType ppist in lstPPIST)
                        {
                            string queryppist = @"DELETE FROM PaymentsPerInsSubTypes WHERE ID = " + ppist.ID;
                            dc.ExecuteCommand(queryppist);
                            //ppist.Delete();
                        }
                        string queryppay = @"DELETE FROM Payments WHERE ID = " + pay.ID;
                        dc.ExecuteCommand(queryppay);
                        //pay.Delete();
                    }
                    string queryr = @"DELETE FROM Rates WHERE ID = " + r.ID;
                    dc.ExecuteCommand(queryr);
                    //r.Delete();
                }
                string querypei = @"DELETE FROM PolicyExtendInformations WHERE PolicyItemID = " + pi.ID;
                dc.ExecuteCommand(querypei);
                Broker.DataAccess.Facture facture = PolicyItemFactureItem.GetByPolicyItemID(pi.ID);
                if (facture != null)
                {
                    List <Broker.DataAccess.FactureItem> listFI = FactureItem.GetByFacture(facture.ID);
                    foreach (FactureItem fi in listFI)
                    {
                        string querypifi = @"DELETE FROM PolicyItemFactureItems WHERE FactureItemID = " + fi.ID;
                        dc.ExecuteCommand(querypifi);
                        string queryfi = @"DELETE FROM FactureItems WHERE ID = " + fi.ID;
                        dc.ExecuteCommand(queryfi);
                    }
                    string queryf = @"DELETE FROM Factures WHERE ID = " + facture.ID;
                    dc.ExecuteCommand(queryf);
                }

                string querypi = @"DELETE FROM PolicyItems WHERE ID = " + pi.ID;
                dc.ExecuteCommand(querypi);
                //pi.Delete();
                string queryp = @"DELETE FROM Policies WHERE ID = " + p.ID;
                dc.ExecuteCommand(queryp);
                //p.Delete();
                string queryd = @"UPDATE Distributions SET IsUsed = 0 WHERE ID = " + d.ID;
                dc.ExecuteCommand(queryd);
                //d.IsUsed = false;
                //Distribution.Table.Context.SubmitChanges();
            }

            return(retString);
        }
Example #12
0
 public static void ValidateInsertFactureNumber(string factureNumber)
 {
     Broker.DataAccess.Facture facture = new Broker.DataAccess.Facture();
     facture.FactureNumber = factureNumber;
     facture.TestBeforeInsert();
 }
Example #13
0
        public static List <PolicyItem> GetForFactureCash(Facture f, int insuranceCompanyID)
        {
            List <PolicyItem> pList = Table.Where(p => p.Policy.ApplicationDate >= f.FromDate && p.Policy.ApplicationDate <= f.ToDate && p.Policy.InsuranceCompanyID == insuranceCompanyID).ToList();

            return(pList);
        }
Example #14
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        DateTime startDate     = DateTime.Parse(tbStartDate.Text);
        DateTime endDate       = DateTime.Parse(tbEndDate.Text);
        DateTime dateOfPayment = DateTime.Now.AddDays(15);

        if (tbDateOfPayment.Text.Trim() != string.Empty)
        {
            DateTime.TryParse(tbDateOfPayment.Text, out dateOfPayment);
        }
        InsuranceCompany company = InsuranceCompany.Get(int.Parse(ddlInsuranceCompanies.SelectedValue));

        Broker.DataAccess.User u = this.PageUser;

        DateTime fromDate = DateTime.Parse(tbStartDate.Text);
        DateTime toDate   = DateTime.Parse(tbEndDate.Text);

        if (rblInsuranceLifeType.SelectedValue == "NoLife")
        {
            //List<PolicyItem> piList = PolicyItem.GetFromPreivousMonths(fromDate, company.ID);
            List <FactureInfo>    lastFactureInfos = listNewFactureInfos;
            GridViewRowCollection displayedRows    = gvNewPolicies.Rows;
            foreach (GridViewRow gvRow in displayedRows)
            {
                CheckBox    cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox;
                int         factureInfoID    = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value);
                FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listNewFactureInfos = lastFactureInfos;
            lastFactureInfos    = listFactureInfos;
            displayedRows       = gvOldPolicies.Rows;
            foreach (GridViewRow gvRow in displayedRows)
            {
                CheckBox    cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox;
                int         factureInfoID    = Convert.ToInt32(gvOldPolicies.DataKeys[gvRow.RowIndex].Value);
                FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listFactureInfos = lastFactureInfos;


            List <PolicyItem>  policiesToRemove = new List <PolicyItem>();
            List <FactureInfo> listOldPolicies  = (List <FactureInfo>)listFactureInfos;
            foreach (FactureInfo fi in listOldPolicies)
            {
                if (!fi.IsForFacturing)
                {
                    policiesToRemove.Add(PolicyItem.Get(fi.ID));
                }
            }
            List <FactureInfo> listNewPolicies = (List <FactureInfo>)listNewFactureInfos;
            foreach (FactureInfo fi in listNewPolicies)
            {
                if (!fi.IsForFacturing)
                {
                    PolicyItem pi = PolicyItem.Get(fi.ID);
                    if (!policiesToRemove.Contains(pi))
                    {
                        policiesToRemove.Add(pi);
                    }
                }
            }



            Broker.DataAccess.Facture f = Broker.DataAccess.Facture.Generate(startDate, endDate, company, u, dateOfPayment, policiesToRemove);
            // f.Insert();

            //int number = 1;
            //List<FactureItem> fiList = new List<FactureItem>();
            //List<FactureItem.FactureItemGrouped> factureItemGroupedList = FactureItem.GetFactureItemsForCompany(company.ID, startDate, endDate);
            //foreach (FactureItem.FactureItemGrouped fifig in factureItemGroupedList) {
            //    FactureItem fi = new FactureItem();
            //    fi.PremiumValue = fifig.TotalValue;
            //    fi.Count = fifig.PaymentsCount;
            //    fi.FactureID = f.ID;
            //    fi.InsuranceSubTypeID = fifig.InsuranceSubTypeID;
            //    fi.Number = number;
            //    ++number;
            //    fi.Description = InsuranceSubType.Get(fifig.InsuranceSubTypeID).ShortDescription;
            //    fi.Insert();
            //    fiList.Add(fi);
            //}

            //List<PolicyItem> pItemList = PolicyItem.GetForFacture(f, company.ID);
            //PolicyItemFactureItem.InsertForFacture(fiList, pItemList);


            //List<FactureItem> fiListCash = new List<FactureItem>();
            //List<FactureItem.FactureItemGrouped> factureItemGroupedCashList = FactureItem.GetForCashPayments(company.ID, startDate, endDate);
            //foreach (FactureItem.FactureItemGrouped fifig in factureItemGroupedCashList) {
            //    FactureItem fi = new FactureItem();
            //    fi.PremiumValue = fifig.TotalValue;
            //    fi.Count = fifig.PaymentsCount;
            //    fi.FactureID = f.ID;
            //    fi.InsuranceSubTypeID = fifig.InsuranceSubTypeID;
            //    fi.Number = number;
            //    ++number;
            //    fi.Description = InsuranceSubType.Get(fifig.InsuranceSubTypeID).ShortDescription;
            //    fi.Insert();
            //    fiListCash.Add(fi);
            //}

            //List<PolicyItem> pItemListCash = PolicyItem.GetForFactureCash(f, company.ID);
            //PolicyItemFactureItem.InsertForFacture(fiListCash, pItemListCash);
            if (f != null)
            {
                lblError.Visible = false;
                odsFacturePreview.SelectParameters.Clear();
                odsFacturePreview.SelectParameters.Add("id", f.ID.ToString());
                odsFactureItems.SelectParameters.Clear();
                odsFactureItems.SelectParameters.Add("factureID", f.ID.ToString());
                mvMain.SetActiveView(viewFactureItems);
            }
            else
            {
                lblError.Visible   = true;
                lblError.Font.Bold = true;
                lblError.Text      = "Не постојат нефактурирани износи";
            }
        }
        else if (rblInsuranceLifeType.SelectedValue == "Life")
        {
            List <FactureInfo>    lastFactureInfos = listNewFactureInfos;
            GridViewRowCollection displayedRows    = gvNewPolicies.Rows;
            foreach (GridViewRow gvRow in displayedRows)
            {
                CheckBox    cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox;
                int         factureInfoID    = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value);
                FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listNewFactureInfos = lastFactureInfos;
            lastFactureInfos    = listFactureInfos;
            displayedRows       = gvOldPolicies.Rows;
            foreach (GridViewRow gvRow in displayedRows)
            {
                CheckBox    cbIsForFacturing = gvRow.FindControl("cbIsForFacturing") as CheckBox;
                int         factureInfoID    = Convert.ToInt32(gvOldPolicies.DataKeys[gvRow.RowIndex].Value);
                FactureInfo fi = lastFactureInfos.Where(facInfo => facInfo.ID == factureInfoID).SingleOrDefault();
                fi.IsForFacturing = cbIsForFacturing.Checked;
            }
            listFactureInfos = lastFactureInfos;
            List <LifePolicy>  policiesToRemove = new List <LifePolicy>();
            List <FactureInfo> listOldPolicies  = (List <FactureInfo>)listFactureInfos;
            foreach (FactureInfo fi in listOldPolicies)
            {
                if (!fi.IsForFacturing)
                {
                    policiesToRemove.Add(LifePolicy.Get(fi.ID));
                }
            }
            List <FactureInfo> listNewPolicies = (List <FactureInfo>)listNewFactureInfos;
            foreach (FactureInfo fi in listNewPolicies)
            {
                if (!fi.IsForFacturing)
                {
                    LifePolicy pi = LifePolicy.Get(fi.ID);
                    if (!policiesToRemove.Contains(pi))
                    {
                        policiesToRemove.Add(pi);
                    }
                }
            }



            Broker.DataAccess.Facture f = Broker.DataAccess.Facture.GenerateForLife(startDate, endDate, company, u, dateOfPayment, policiesToRemove);

            if (f != null)
            {
                lblError.Visible = false;
                odsFacturePreview.SelectParameters.Clear();
                odsFacturePreview.SelectParameters.Add("id", f.ID.ToString());
                odsFactureItems.SelectParameters.Clear();
                odsFactureItems.SelectParameters.Add("factureID", f.ID.ToString());
                mvMain.SetActiveView(viewFactureItems);
            }
            else
            {
                lblError.Visible   = true;
                lblError.Font.Bold = true;
                lblError.Text      = "Не постојат нефактурирани износи";
            }
        }
    }
Example #15
0
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        string   factureNumber = tbFactureNumber.Text;
        DateTime paidDate      = DateTime.Now;

        DateTime.TryParse(tbDateOfPayment.Text, out paidDate);

        try {
            Broker.DataAccess.Facture f = Broker.DataAccess.Facture.GetByNumber(factureNumber);
            if (f != null)
            {
                foreach (GridViewRow gvRow in GridViewPayments.Rows)
                {
                    decimal newTotValue     = 0;
                    TextBox tbPaidValue     = (TextBox)gvRow.FindControl("tbValue");
                    TextBox tbFactureItemID = (TextBox)gvRow.FindControl("tbFactureItemID");
                    decimal.TryParse(tbPaidValue.Text, out newTotValue);
                    int factureItemID = 0;
                    int.TryParse(tbFactureItemID.Text, out factureItemID);
                    if (factureItemID > 0)
                    {
                        if (newTotValue < FactureCollectedPaidValue.GetPaidValueForFactureItem(factureItemID))
                        {
                            RegisterStartupScript("myAlert", "<script>alert('ВНЕСОВТЕ ПОМАЛ ИЗНОС ОД ТОА ШТО Е ПЛАТЕНО ДО СЕГА!')</script>");
                            return;
                        }
                        if (newTotValue > FactureItem.Get(factureItemID).BrokerageValue)
                        {
                            RegisterStartupScript("myAlert", "<script>alert('ВНЕСОВТЕ ПОГОЛЕМ ИЗНОС ОД ПРЕСМЕТАНАТА БРОКЕРАЖА!')</script>");
                            return;
                        }
                        if (FactureCollectedPaidValue.GetPaidValueForFactureItem(factureItemID) != FactureItem.Get(factureItemID).BrokerageValue)
                        {
                            FactureCollectedPaidValue fcpv = new FactureCollectedPaidValue();
                            fcpv.FactureItemID = factureItemID;
                            fcpv.PaidDate      = paidDate;
                            fcpv.PaidValue     = newTotValue - FactureCollectedPaidValue.GetPaidValueForFactureItem(factureItemID);
                            fcpv.Insert();
                            FactureItem fi = FactureItem.Get(factureItemID);
                            List <PolicyItemFactureItem> lstPIFI = PolicyItemFactureItem.GetByFactureItemID(factureItemID);
                            decimal koef = fcpv.PaidValue / fi.BrokerageValue;
                            List <InsuranceSubType> listAppropriateIST = Broker.DataAccess.ControlAppropriateInsuranceSubType.Table.Select(c => c.InsuranceSubType).ToList();
                            Dictionary <InsuranceSubType, decimal> dic = new Dictionary <InsuranceSubType, decimal>();
                            decimal totValue = 0;
                            foreach (PolicyItem pi in lstPIFI.Select(c => c.PolicyItem).Where(c => c.Policy.Discard == false).ToList())
                            {
                                decimal brokPercentage = 0;
                                if (pi.BrokerageID != null)
                                {
                                    if (pi.Policy.Client.IsLaw)
                                    {
                                        brokPercentage = pi.Brokerage.PercentageForLaws;
                                    }
                                    else
                                    {
                                        brokPercentage = pi.Brokerage.PercentageForPrivates;
                                    }
                                }
                                else if (pi.PacketBrokerageID != null)
                                {
                                    if (pi.Policy.Client.IsLaw)
                                    {
                                        brokPercentage = pi.PacketsInsuranceSubType.BrokeragePecentageForLaws;
                                    }
                                    else
                                    {
                                        brokPercentage = pi.PacketsInsuranceSubType.BrokeragePecentageForPrivates;
                                    }
                                }
                                foreach (InsuranceSubType ist in listAppropriateIST)
                                {
                                    List <Broker.DataAccess.Control> listControls = ControlAppropriateInsuranceSubType.GetByInsuranceSubType(ist.ID);
                                    decimal tmpValue = 0;

                                    foreach (Broker.DataAccess.Control con in listControls)
                                    {
                                        PolicyExtendInformation pei = PolicyExtendInformation.GetByPolicyItemAndControl(pi.ID, con.ID);
                                        if (pei != null)
                                        {
                                            tmpValue += Convert.ToDecimal(pei.Value);
                                        }
                                    }
                                    if (dic.Keys.Contains(ist))
                                    {
                                        dic[ist] += (tmpValue * brokPercentage / 100);
                                    }
                                    else
                                    {
                                        dic.Add(ist, (tmpValue * brokPercentage / 100));
                                    }
                                }
                                //totValue += RateController.Scale5(pi.PremiumValue * brokPercentage / 100);
                                totValue += pi.PremiumValue * brokPercentage / 100;
                            }
                            totValue = RateController.Scale5(totValue);
                            decimal addValue = 0;
                            foreach (KeyValuePair <InsuranceSubType, decimal> kvp in dic)
                            {
                                if (kvp.Value > 0)
                                {
                                    addValue += kvp.Value;
                                    FacCollPaidValuesPerInsSubType fcp = new FacCollPaidValuesPerInsSubType();
                                    fcp.FactureCollectedPaidValueID = fcpv.ID;
                                    fcp.InsuranceSubTypeID          = kvp.Key.ID;
                                    fcp.PaidValue = RateController.Scale5(fcpv.PaidValue * kvp.Value / totValue);
                                    fcp.Insert();
                                }
                            }
                            decimal baseValue = fi.BrokerageValue - addValue;
                            FacCollPaidValuesPerInsSubType fcpBase = new FacCollPaidValuesPerInsSubType();
                            fcpBase.FactureCollectedPaidValueID = fcpv.ID;
                            fcpBase.InsuranceSubTypeID          = fi.InsuranceSubTypeID;
                            fcpBase.PaidValue = RateController.Scale5(fcpv.PaidValue * baseValue / totValue);
                            fcpBase.Insert();
                        }
                    }
                }
            }
            else
            {
                lblFeedback.Text = "Не е пронајдена фактура!";
            }
        } catch (Exception ex) {
            lblFeedback.Text = "Грешка!";
        }
    }
Example #16
0
 void UpdateTextBoxes(Broker.DataAccess.Facture f)
 {
     tbFactureTotalCost.Text      = String.Format("{0:#,0.00}", f.BrokerageValue);
     tbFactureTotalPaidValue.Text = String.Format("{0:#,0.00}", FactureCollectedPaidValue.GetPaidValueForFacture(f.ID));
     tbFactureForPaidValue.Text   = String.Format("{0:#,0.00}", (Convert.ToDecimal(tbFactureTotalCost.Text) - Convert.ToDecimal(tbFactureTotalPaidValue.Text)));
 }
Example #17
0
    protected void btnGenerate_Click(object sender, EventArgs e)
    {
        string   factureNumber = tbFactureNumber.Text;
        DateTime paidDate      = DateTime.Now;

        DateTime.TryParse(tbDateOfPayment.Text, out paidDate);

        try {
            Broker.DataAccess.Facture f = Broker.DataAccess.Facture.GetByNumber(factureNumber);
            if (f != null)
            {
                decimal newPaymentValue = 0;
                decimal.TryParse(tbValueOfPayment.Text, out newPaymentValue);
                if (newPaymentValue > Convert.ToDecimal(tbFactureForPaidValue.Text))
                {
                    RegisterStartupScript("myAlert", "<script>alert('ИЗНОСОТ КОЈ ГО ВНЕСОВТЕ ЗА ПЛАЌАЊЕ Е ПОГОЛЕМ ОД ПРЕОСТАНАТИОТ ДОЛГ!')</script>");
                    return;
                }
                decimal proValue = RateController.Scale5(newPaymentValue / (decimal)f.FactureItems.Count);
                List <FactureCollectedPaidValue> list = FactureCollectedPaidValue.GetGroupedByFactureID(f.ID);
                if (list.Count > 0)
                {
                    int restColumn = f.FactureItems.Count;
                    foreach (FactureCollectedPaidValue fcpv in list)
                    {
                        if (FactureCollectedPaidValue.GetPaidValueForFactureItem(fcpv.FactureItemID) == fcpv.FactureItem.BrokerageValue)
                        {
                            restColumn--;
                        }
                        proValue      = RateController.Scale5(newPaymentValue / (decimal)restColumn);
                        fcpv.PaidDate = paidDate;
                        if ((fcpv.PaidValue + proValue) > fcpv.FactureItem.BrokerageValue)
                        {
                            fcpv.PaidValue = fcpv.FactureItem.BrokerageValue;
                        }
                        else
                        {
                            fcpv.PaidValue += proValue;
                        }
                    }
                }
                else
                {
                    decimal rest = newPaymentValue;
                    int     i    = 0;
                    foreach (FactureItem fi in f.FactureItems)
                    {
                        proValue = RateController.Scale5(rest / (decimal)(f.FactureItems.Count - i));
                        FactureCollectedPaidValue fcpv = new FactureCollectedPaidValue();
                        fcpv.FactureItemID = fi.ID;
                        fcpv.FactureItem   = fi;
                        fcpv.PaidDate      = paidDate;
                        if (fi.BrokerageValue > (proValue + FactureCollectedPaidValue.GetPaidValueForFactureItem(fi.ID)))
                        {
                            fcpv.PaidValue += proValue;
                        }
                        else
                        {
                            fcpv.PaidValue = fi.BrokerageValue;
                        }
                        rest -= fcpv.PaidValue;
                        list.Add(fcpv);
                        i++;
                    }
                }
                GridViewPayments.DataSourceID = null;
                GridViewPayments.DataSource   = list;
                GridViewPayments.DataBind();
                btnInsert.Enabled = true;
            }
            else
            {
                lblFeedback.Text = "Не е пронајдена фактура!";
            }
        } catch (Exception ex) {
            lblFeedback.Text = "Грешка!";
        }
    }
Example #18
0
        public static void PrintAnex(Policy p)
        {
            List <Rate> ratesForPrint = Rate.GetByPolicyItemID(p.PolicyItems[0].ID);

            Broker.DataAccess.Facture f = PolicyItemFactureItem.GetByPolicyItemID(p.PolicyItems[0].ID);
            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("  ");
            creator.SetTitleLeft8("Договорувач " + p.Client.Name + "                                                                                                             " + "Експозитура " + p.Branch.Name);
            creator.SetTitleLeft8("  ");
            creator.SetTitle("ДОГОВОР " + p.PolicyItems[0].PolicyNumber);
            creator.SetTitle("за плаќање на должна премија за осигурување");
            creator.SetTitle("(плаќање на рати)");
            creator.SetTitleLeft8("  ");
            creator.SetTitleLeft8("  ");
            creator.SetTitleLeft8("1.Премијата за осигурување ќе се плати на рати, како што следи:");
            string[]   headersRates          = { "Реден број", "Рок за плаќање", "Полиса", "Фактура број", "Износ" };
            float[]    widthPercentagesRates = { 10, 25, 25, 20, 20 };
            TypeCode[] typeCodesRates        = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal };
            creator.CreateTable_Facture(headersRates.Length, headersRates, widthPercentagesRates);
            ratesForPrint = ratesForPrint.OrderBy(c => c.Date).ToList();
            int counter = 1;

            foreach (Rate r in ratesForPrint)
            {
                object[] valuesRates = new object[headersRates.Length];
                valuesRates[0] = counter;
                valuesRates[1] = r.Date.ToShortDateString();
                valuesRates[2] = r.PolicyItem.PolicyNumber;
                if (f != null)
                {
                    valuesRates[3] = f.FactureNumber;
                }
                else
                {
                    valuesRates[3] = "";
                }
                valuesRates[4] = String.Format("{0:#,0.00}", r.Value) + " ДЕН.";
                creator.AddDataRowForFactures(valuesRates, headersRates.Length, typeCodesRates);
                counter++;
            }
            object[] values = new object[headersRates.Length];
            values[0] = "";
            values[1] = "";
            values[2] = "";
            values[3] = "Вкупно";
            values[4] = String.Format("{0:#,0.00}", p.PolicyItems[0].PremiumValue) + " ДЕН.";
            creator.AddDataRowForFactures(values, headersRates.Length, typeCodesRates);
            creator.AddTable();
            creator.SetTitleLeft8("2.Доколку настане осигуран случај - штета, независно од тоа што е договорено плаќање на рати, премијата за осигурување стасува за наплата веднаш до висината на надоместокот што треба да се исплати и ќе се наплати по пат на компензација.");
            creator.SetTitleLeft8("3.Ако премијата не се плати во договорените рокови од овој Договор, ќе се пресметува камата.");
            creator.SetTitleLeft8("4.Договорот е составен од три еднообразни примероци, од кои еден за осигуреникот, а два за осигурувачот.");
            creator.SetTitle(" ");
            creator.SetTitle(" ");
            if (f != null)
            {
                creator.SetTitleCenter8("Во " + f.User.Branch.Municipality.Name + " на " + f.DateOfCreation.ToShortDateString());
            }
            else
            {
                creator.SetTitleCenter8("Во " + p.Branch.Municipality.Name + " на " + p.ApplicationDate.ToShortDateString());
            }
            creator.SetTitle(" ");
            creator.SetTitle(" ");
            string brokerName = BrokerHouseInformation.GetBrokerHouseName();

            creator.SetTitleLeft8("         " + brokerName + "                                                                                                                           ДОГОВОРУВАЧ");
            creator.SetTitleLeft8(" ");
            creator.SetTitleLeft8("_________________________                                                                                                           ____________________");
            creator.FinishPDF_FileName("Aneks" + p.PolicyItems[0].PolicyNumber);
        }
Example #19
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);
            }
        }
Example #20
0
        public static void UpdateExtend(Payment oldEntity, Payment newEntity)
        {
            DataClassesDataContext dc = new DataClassesDataContext();
            string value = newEntity.Value.ToString();

            value = value.Replace(',', '.');
            decimal k = 1;

            if (oldEntity.Value != 0)
            {
                k = newEntity.Value / oldEntity.Value;
            }
            string Kvalue = k.ToString();

            Kvalue = Kvalue.Replace(',', '.');
            string firstQuery = @"UPDATE PaymentsPerInsSubTypes SET PaidValue = " + Kvalue + " * paidvalue, brokeragevalue = " + Kvalue + " * brokeragevalue WHERE PaymentID = " + newEntity.ID;

            dc.ExecuteCommand(firstQuery);
            string query = @"Update Payments SET Value = " + value + " , Date = '" + newEntity.Date.Year + - +newEntity.Date.Month + - +newEntity.Date.Day + "' , PaymentTypeID = " + newEntity.PaymentTypeID;

            if (newEntity.BankslipNumber != string.Empty)
            {
                if (newEntity.BankslipNumber != null)
                {
                    query += @", BankslipNumber = '" + newEntity.BankslipNumber + "'";
                }
                if (newEntity.BankslipBankID != null)
                {
                    query += @", BankslipBankID = " + newEntity.BankslipBankID;
                }
                else
                {
                    query += @", BankslipBankID = null";
                }
            }
            else
            {
                query += @", BankslipNumber = '" + newEntity.BankslipNumber + "'";
                if (newEntity.BankslipBankID != null)
                {
                    query += @", BankslipBankID = " + newEntity.BankslipBankID;
                }
                else
                {
                    query += @", BankslipBankID = null";
                }
            }
            if (newEntity.BankCreditCardID != null)
            {
                query += @", BankCreditCardID = " + newEntity.BankCreditCardID;
            }
            else
            {
                query += @", BankCreditCardID = null";
            }
            query += @" WHERE ID = " + newEntity.ID;
            Rate    r = Rate.Get(newEntity.RateID);
            decimal oldRatePaidValue = r.PaidValue;
            decimal newRatePaidValue = oldRatePaidValue + (newEntity.Value - oldEntity.Value);
            string  valuePaid        = newRatePaidValue.ToString();

            valuePaid = valuePaid.Replace(',', '.');
            string queryRate = "Update Rates Set PaidValue = " + valuePaid + " Where ID = " + r.ID;

            dc.ExecuteCommand(query);
            dc.ExecuteCommand(queryRate);
            Facture.UpdatePaidStatusForFactureExtend(r.PolicyItemID);
        }