protected void ddlInsuranceSubTypes_SelectedIndexChanged(object sender, EventArgs e) { odsRates.SelectParameters.Clear(); odsRates.TypeName = "Broker.DataAccess.Rate"; odsRates.DataObjectTypeName = "Broker.DataAccess.Rate"; odsRates.SelectMethod = "GetByPolicyNumberAndInsuranceSubTypeIDAndInsuranceCompanyID"; odsRates.SelectParameters.Add("policyNumber", tbPolicyNumber.Text); odsRates.SelectParameters.Add("insuranceSubTypeID", Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue).ToString()); odsRates.SelectParameters.Add("insuranceCompanyID", Convert.ToInt32(ddlInsuranceCompany.SelectedValue).ToString()); GridViewRates.DataBind(); PolicyItem pi = PolicyItem.GetByNumberAndInsuranceSubType(tbPolicyNumber.Text, Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue), int.Parse(ddlInsuranceCompany.SelectedValue)); odsPaidPayments.SelectParameters.Clear(); odsPaidPayments.SelectParameters.Add("policyItemID", pi.ID.ToString()); GridViewPayments.DataBind(); UpdateTextBoxes(pi); }
protected void btnSearch_Click(object sender, EventArgs e) { int insuranceCompanyID = Convert.ToInt32(ddlInsuranceCompany.SelectedValue); int insuranceTypeID = Convert.ToInt32(ddlInsuranceType.SelectedValue); int insuranceSubTypeID = Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue); string policyNumber = tbPolicyNumber.Text; PolicyItem pi = PolicyItem.GetByNumberAndInsuranceSubType(policyNumber, insuranceSubTypeID, insuranceCompanyID); if (pi != null) { tbStartDate.Text = pi.Policy.StartDate.ToShortDateString(); tbEndDate.Text = pi.Policy.EndDate.ToShortDateString(); tbCoverage.Text = pi.PremiumValue.ToString(); tbOwnerEMBG.Text = pi.Policy.Client1.EMBG; tbOwnerName.Text = pi.Policy.Client1.Name; PolicyItemID = pi.ID; } lblError.Visible = false; lblSuccess.Visible = false; }
protected void btnSearch_Click(object sender, EventArgs e) { int insuranceCompanyID = Convert.ToInt32(ddlInsuranceCompany.SelectedValue); int insuranceTypeID = Convert.ToInt32(ddlInsuranceType.SelectedValue); int insuranceSubTypeID = Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue); string policyNumber = tbPolicyNumber.Text; dvDataSource.SelectParameters.Clear(); dvDataSource.SelectParameters.Add("policyNumber", policyNumber); dvDataSource.SelectParameters.Add("insuranceSubTypeID", insuranceSubTypeID.ToString()); dvDataSource.SelectParameters.Add("insuranceCompanyID", insuranceCompanyID.ToString()); PoliciesDetailsView.DataBind(); PolicyItem pi = PolicyItem.GetByNumberAndInsuranceSubType(policyNumber, insuranceSubTypeID, insuranceCompanyID); if (pi != null) { btnUpdate.Visible = true; CreateChildControls(); } else { btnUpdate.Visible = false; } }
protected void btnGenerate_Click(object sender, EventArgs e) { DateTime inputDate = Convert.ToDateTime(tbDateOfPayment.Text); PolicyItem pi; List <Payment> newPayments = new List <Payment>(); if (ddlInsuranceSubTypes.Items.Count > 0) { pi = PolicyItem.GetByNumberAndInsuranceSubType(tbPolicyNumber.Text, Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue), int.Parse(ddlInsuranceCompany.SelectedValue)); } else { pi = PolicyItem.GetByNumber(tbPolicyNumber.Text, int.Parse(ddlInsuranceCompany.SelectedValue)); } if (inputDate.Date > DateTime.Today) { lblFeedback.Text = "Не е можно внесување на датуми поголеми од денешниот"; } else { lblFeedback.Text = string.Empty; List <Payment> listPayments = Payment.GetByPolicyItemID(pi.ID); newPayments.AddRange(listPayments); decimal paymentTotalValue = 0; foreach (Payment payment in listPayments) { paymentTotalValue += payment.Value; } if (Convert.ToDecimal(tbValueOfPayment.Text) > (pi.PremiumValue - paymentTotalValue)) { lblFeedback.Text = "Поголем износ од преостанатиот износ за плаќање"; } else { lblFeedback.Text = string.Empty; decimal valueFromClient = Convert.ToDecimal(tbValueOfPayment.Text); Broker.DataAccess.PaymentType pt = Broker.DataAccess.PaymentType.Get(Convert.ToInt32(ddlPaymentTypes.SelectedValue)); Rate currentRate = Rate.GetCurrentRateForPayment(pi.ID); while (valueFromClient > 0) { Payment newPayment = new Payment(); newPayment.Date = Convert.ToDateTime(tbDateOfPayment.Text); newPayment.RateID = currentRate.ID; newPayment.Rate = currentRate; newPayment.IsCashReported = false; newPayment.PaymentTypeID = pt.ID; if (pt.Code == Broker.DataAccess.PaymentType.CREDITCARD) { newPayment.BankCreditCardID = BankCreditCard.GetByBankAndCard(Convert.ToInt32(ddlBank.SelectedValue), Convert.ToInt32(ddlCardTypes.SelectedValue)).ID; } newPayment.UserID = this.PageUser.ID; newPayment.BranchID = this.PageUser.BranchID; if (tbBankslipNumber.Text.Trim() != string.Empty) { newPayment.BankslipNumber = tbBankslipNumber.Text; newPayment.BankslipBankID = Convert.ToInt32(ddlBankslipBanks.SelectedValue); } if (valueFromClient >= currentRate.Value) { newPayment.Value = currentRate.Value - Payment.GetPaidValueForRate(currentRate.ID); valueFromClient -= newPayment.Value; currentRate.PaidValue += newPayment.Value; newPayments.Add(newPayment); int currentRateNumber = currentRate.Number; int nextNumber; int maxNumber = Rate.Table.Where(r => r.PolicyItemID == pi.ID).OrderBy(r => r.Number).Select(r => r.Number).ToList().Last(); if (currentRateNumber < maxNumber) { nextNumber = ++currentRateNumber; } else { nextNumber = currentRateNumber; } currentRate = Rate.Table.Where(r => r.PolicyItemID == pi.ID && r.Number == nextNumber).SingleOrDefault(); } else { if (valueFromClient <= (currentRate.Value - currentRate.PaidValue)) { newPayment.Value = valueFromClient; currentRate.PaidValue = valueFromClient; newPayments.Add(newPayment); break; } else { newPayment.Value = (currentRate.Value - currentRate.PaidValue); currentRate.PaidValue = currentRate.PaidValue; newPayments.Add(newPayment); valueFromClient -= newPayment.Value; int currentRateNumber = currentRate.Number; int nextNumber; int maxNumber = Rate.Table.Where(r => r.PolicyItemID == pi.ID).OrderBy(r => r.Number).Select(r => r.Number).ToList().Last(); if (currentRateNumber < maxNumber) { nextNumber = ++currentRateNumber; } else { nextNumber = currentRateNumber; } currentRate = Rate.Table.Where(r => r.PolicyItemID == pi.ID && r.Number == nextNumber).SingleOrDefault(); } } } btnInsert.Enabled = true; } } odsPaidPayments.SelectParameters.Clear(); GridViewPayments.DataSourceID = null; GridViewPayments.DataSource = newPayments; GridViewPayments.DataBind(); }
protected void btnInsert_Click(object sender, EventArgs e) { DateTime inputDate = Convert.ToDateTime(tbDateOfPayment.Text); int insuranceCompanyID = int.Parse(ddlInsuranceCompany.SelectedValue); PolicyItem pi; if (ddlInsuranceSubTypes.Items.Count > 0) { pi = PolicyItem.GetByNumberAndInsuranceSubType(tbPolicyNumber.Text, Convert.ToInt32(ddlInsuranceSubTypes.SelectedValue), insuranceCompanyID); } else { pi = PolicyItem.GetByNumber(tbPolicyNumber.Text, insuranceCompanyID); } if (inputDate.Date > DateTime.Today) { lblFeedback.Text = "Не е можно внесување на датуми поголеми од денешниот"; } else { List <Payment> listPayments = Payment.GetByPolicyItemID(pi.ID); decimal paymentTotalValue = 0; foreach (Payment payment in listPayments) { paymentTotalValue += payment.Value; } if (Convert.ToDecimal(tbValueOfPayment.Text) > (pi.PremiumValue - paymentTotalValue)) { lblFeedback.Text = "Поголем износ од преостанатиот износ за плаќање"; } else { decimal valueFromClient = Convert.ToDecimal(tbValueOfPayment.Text); while (valueFromClient > 0) { Rate currentRate = Rate.GetCurrentRateForPayment(pi.ID); Payment newPayment = new Payment(); newPayment.Date = Convert.ToDateTime(tbDateOfPayment.Text); newPayment.RateID = currentRate.ID; newPayment.IsCashReported = false; Broker.DataAccess.PaymentType pt = Broker.DataAccess.PaymentType.Get(Convert.ToInt32(ddlPaymentTypes.SelectedValue)); newPayment.PaymentTypeID = pt.ID; if (pt.Code == Broker.DataAccess.PaymentType.CREDITCARD) { newPayment.BankCreditCardID = BankCreditCard.GetByBankAndCard(Convert.ToInt32(ddlBank.SelectedValue), Convert.ToInt32(ddlCardTypes.SelectedValue)).ID; } newPayment.UserID = this.PageUser.ID; newPayment.BranchID = this.PageUser.BranchID; if (tbBankslipNumber.Text.Trim() != string.Empty) { newPayment.BankslipNumber = tbBankslipNumber.Text; newPayment.BankslipBankID = Convert.ToInt32(ddlBankslipBanks.SelectedValue); } if (valueFromClient >= currentRate.Value) { newPayment.Value = currentRate.Value - Payment.GetPaidValueForRate(currentRate.ID); newPayment.Insert(); decimal basicValue = newPayment.Value; decimal k = basicValue / newPayment.Rate.PolicyItem.PremiumValue; List <ControlAppropriateInsuranceSubType> listAppropriateIST = Broker.DataAccess.ControlAppropriateInsuranceSubType.Table.ToList(); foreach (ControlAppropriateInsuranceSubType c in listAppropriateIST) { PolicyExtendInformation pei = PolicyExtendInformation.GetByPolicyItemAndControl(pi.ID, c.ControlID); if (pei != null) { decimal peiValue = 0; decimal.TryParse(pei.Value, out peiValue); basicValue -= k * peiValue; if (peiValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = c.InsuranceSubTypeID; ppist.PaidValue = k * peiValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } } } if (basicValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = pi.InsuranceSubTypeID; ppist.PaidValue = basicValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } valueFromClient -= newPayment.Value; currentRate.PaidValue += newPayment.Value; Rate.Table.Context.SubmitChanges(); } else { if (valueFromClient <= (currentRate.Value - currentRate.PaidValue)) { newPayment.Value = valueFromClient; newPayment.Insert(); decimal basicValue = newPayment.Value; decimal k = basicValue / newPayment.Rate.PolicyItem.PremiumValue; List <ControlAppropriateInsuranceSubType> listAppropriateIST = Broker.DataAccess.ControlAppropriateInsuranceSubType.Table.ToList(); foreach (ControlAppropriateInsuranceSubType c in listAppropriateIST) { PolicyExtendInformation pei = PolicyExtendInformation.GetByPolicyItemAndControl(pi.ID, c.ControlID); if (pei != null) { decimal peiValue = 0; decimal.TryParse(pei.Value, out peiValue); basicValue -= k * peiValue; if (peiValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = c.InsuranceSubTypeID; ppist.PaidValue = k * peiValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } } } if (basicValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = pi.InsuranceSubTypeID; ppist.PaidValue = basicValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } currentRate.PaidValue += valueFromClient; Rate.Table.Context.SubmitChanges(); break; } else { newPayment.Value = (currentRate.Value - currentRate.PaidValue); newPayment.Insert(); decimal basicValue = newPayment.Value; decimal k = basicValue / newPayment.Rate.PolicyItem.PremiumValue; List <ControlAppropriateInsuranceSubType> listAppropriateIST = Broker.DataAccess.ControlAppropriateInsuranceSubType.Table.ToList(); foreach (ControlAppropriateInsuranceSubType c in listAppropriateIST) { PolicyExtendInformation pei = PolicyExtendInformation.GetByPolicyItemAndControl(pi.ID, c.ControlID); if (pei != null) { decimal peiValue = 0; decimal.TryParse(pei.Value, out peiValue); basicValue -= k * peiValue; if (peiValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = c.InsuranceSubTypeID; ppist.PaidValue = k * peiValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } } } if (basicValue > 0) { PaymentsPerInsSubType ppist = new PaymentsPerInsSubType(); ppist.PaymentID = newPayment.ID; ppist.InsuranceSubTypeID = pi.InsuranceSubTypeID; ppist.PaidValue = basicValue; ppist.BrokerageValue = ppist.PaidValue * pi.BrokeragePercentage / 100; ppist.Insert(); } //currentRate.PaidValue += valueFromClient; //Rate.Table.Context.SubmitChanges(); currentRate.PaidValue += newPayment.Value; Rate.Table.Context.SubmitChanges(); valueFromClient -= newPayment.Value; } } } Broker.DataAccess.Facture.UpdatePaidStatusForFacture(pi.ID); } } GridViewPayments.DataSource = null; GridViewPayments.DataSourceID = odsPaidPayments.ID; odsPaidPayments.SelectParameters.Clear(); odsPaidPayments.SelectParameters.Add("policyItemID", pi.ID.ToString()); GridViewPayments.DataBind(); GridViewRates.DataSource = null; GridViewRates.DataSourceID = odsRates.ID; odsRates.SelectParameters.Clear(); odsRates.TypeName = "Broker.DataAccess.Rate"; odsRates.DataObjectTypeName = "Broker.DataAccess.Rate"; odsRates.SelectMethod = "GetByPolicyNumberAndInsuranceSubTypeIDAndInsuranceCompanyID"; odsRates.SelectParameters.Add("policyNumber", tbPolicyNumber.Text); odsRates.SelectParameters.Add("insuranceSubTypeID", pi.InsuranceSubType.ID.ToString()); odsRates.SelectParameters.Add("insuranceCompanyID", ddlInsuranceCompany.SelectedValue); //odsRates.SelectMethod = "Broker.DataAccess.PolicyItem.GetByNumberAndInsuranceSubType"; GridViewRates.DataBind(); UpdateTextBoxes(pi); }
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); } }