//Totals, with TotalDelivery and TotalChange private void PrintMasterTotals() { try { //Init DataTable DataRow dataRow = null; DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("Label", typeof(string))); dataTable.Columns.Add(new DataColumn("Value", typeof(string))); //Add Row : Discount if (_documentFinanceMasterList[0].Discount > 0.0m) { dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0} (%)", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_discount_customer")); /* IN009211 */ dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].Discount); dataTable.Rows.Add(dataRow); } //Add Row : TotalDiscount if (_documentFinanceMasterList[0].TotalDiscount > 0.0m) { dataRow = dataTable.NewRow(); dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_total_discount"); /* IN009211 */ dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalDiscount * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); } /* #TODO IN009214 */ //Add Row : Discount PaymentCondition //WIP Always 0 //Add Row : TotalNet dataRow = dataTable.NewRow(); dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_totalnet"); /* IN009211 */ //dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalGross * _documentFinanceMasterList[0].ExchangeRate); dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalNet * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); //Add Row : TotalTax dataRow = dataTable.NewRow(); dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_totaltax"); /* IN009211 */ dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalTax * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); //Add Row : TotalFinal dataRow = dataTable.NewRow(); dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_documentfinance_totalfinal"); dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalFinal * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); //If Simplified Invoice, Payment Method MONEY and has Total Change, add it if (new Guid(_documentFinanceMasterList[0].DocumentType) == SettingsApp.XpoOidDocumentFinanceTypeSimplifiedInvoice && _documentFinanceMasterList[0].PaymentMethodToken == "MONEY" && _documentFinanceMasterList[0].TotalChange > 0 ) { //Blank Row, to separate from Main Totals dataRow = dataTable.NewRow(); dataRow[0] = string.Empty; dataRow[1] = string.Empty; dataTable.Rows.Add(dataRow); //TotalDelivery dataRow = dataTable.NewRow(); dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total_deliver"); dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalDelivery * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); //TotalChange dataRow = dataTable.NewRow(); dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total_change"); dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalChange * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); } /* IN009055 - related to IN005976 for Mozambique deployment */ if (SettingsApp.XpoOidConfigurationCountryMozambique.Equals(SettingsApp.ConfigurationSystemCountry.Oid)) { cfg_configurationcurrency defaultCurrencyForExchangeRate = (cfg_configurationcurrency)FrameworkUtils.GetXPGuidObject( GlobalFramework.SessionXpo, typeof(cfg_configurationcurrency), SettingsApp.XpoOidConfigurationCurrencyUSDollar); dataRow = dataTable.NewRow(); dataRow[0] = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_printer_thermal_total_default_currency"), defaultCurrencyForExchangeRate.Acronym); dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalFinal * defaultCurrencyForExchangeRate.ExchangeRate);/* TO DO : IN009055 - this causes total equals 0,00 when low product price */ dataTable.Rows.Add(dataRow); } //Configure Ticket Column Properties List <TicketColumn> columns = new List <TicketColumn>(); columns.Add(new TicketColumn("Label", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Left)); columns.Add(new TicketColumn("Value", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Right)); //TicketTable(DataTable pDataTable, List<TicketColumn> pColumnsProperties, int pTableWidth) TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormalBold); //Custom Print Loop, to Print all Table Rows, and Detect Rows to Print in DoubleHeight (TotalChange(4) and Total(7)) List <string> table = ticketTable.GetTable(); WriteLineTextMode rowTextMode; //Dynamic Print All, some Rows ommited/bold(Table Header, TotalDocument,TotalChange) for (int i = 1; i < table.Count; i++) { //Prepare TextMode Based on Row rowTextMode = (i == 5 || i == 8) ? WriteLineTextMode.DoubleHeightBold : WriteLineTextMode.Bold; //Print Row _thermalPrinterGeneric.WriteLine(table[i], rowTextMode); } //Line Feed _thermalPrinterGeneric.LineFeed(); } catch (Exception ex) { _log.Debug("void PrintMasterTotals() :: Thermal Printer: " + ex.Message, ex); throw ex; } }
public bool PrintWorkSessionMovement(sys_configurationprinters pPrinter, pos_worksessionperiod pWorkSessionPeriod, SplitCurrentAccountMode pSplitCurrentAccountMode) { bool result = false; if (pPrinter != null) { sys_configurationprinters printer = pPrinter; sys_configurationprinterstemplates template = (sys_configurationprinterstemplates)FrameworkUtils.GetXPGuidObject(typeof(sys_configurationprinterstemplates), SettingsApp.XpoOidConfigurationPrintersTemplateWorkSessionMovement); string splitCurrentAccountFilter = string.Empty; string fileTicket = template.FileTemplate; switch (pSplitCurrentAccountMode) { case SplitCurrentAccountMode.All: break; case SplitCurrentAccountMode.NonCurrentAcount: //Diferent from DocumentType CC splitCurrentAccountFilter = string.Format("AND DocumentType <> '{0}'", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput); break; case SplitCurrentAccountMode.CurrentAcount: //Only DocumentType CC splitCurrentAccountFilter = string.Format("AND DocumentType = '{0}'", SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput); break; } try { //Shared Where for details and totals Queries string sqlWhere = string.Empty; if (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day) { sqlWhere = string.Format("PeriodParent = '{0}'{1}", pWorkSessionPeriod.Oid, splitCurrentAccountFilter); } else { sqlWhere = string.Format("Period = '{0}'{1}", pWorkSessionPeriod.Oid, splitCurrentAccountFilter); } //Shared for Both Modes if (sqlWhere != string.Empty) { sqlWhere = string.Format(" AND {0}", sqlWhere); } //Format to Display Vars string dateCloseDisplay = (pWorkSessionPeriod.SessionStatus == WorkSessionPeriodStatus.Open) ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_in_progress") : pWorkSessionPeriod.DateEnd.ToString(SettingsApp.DateTimeFormat); //Get Session Period Details Hashtable resultHashTable = ProcessWorkSessionPeriod.GetSessionPeriodSummaryDetails(pWorkSessionPeriod); //Print Header Summary DataRow dataRow = null; DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("Label", typeof(string))); dataTable.Columns.Add(new DataColumn("Value", typeof(string))); //Open DateTime dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_datetime")); dataRow[1] = pWorkSessionPeriod.DateStart.ToString(SettingsApp.DateTimeFormat); dataTable.Rows.Add(dataRow); //Close DataTime dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_datetime")); dataRow[1] = dateCloseDisplay; dataTable.Rows.Add(dataRow); //Open Total CashDrawer dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_open_total_cashdrawer")); dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawerOnOpen"]); dataTable.Rows.Add(dataRow); //Close Total CashDrawer dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_close_total_cashdrawer")); dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyInCashDrawer"]); dataTable.Rows.Add(dataRow); //Total Money In dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_total_money_in")); dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyIn"]); dataTable.Rows.Add(dataRow); //Total Money Out dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0}:", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_total_money_out")); dataRow[1] = FrameworkUtils.DecimalToStringCurrency((decimal)resultHashTable["totalMoneyOut"]); dataTable.Rows.Add(dataRow); //Configure Ticket Column Properties List <TicketColumn> columns = new List <TicketColumn>(); columns.Add(new TicketColumn("Label", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Right)); columns.Add(new TicketColumn("Value", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Left)); TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormalBold); //Print Ticket Table ticketTable.Print(_thermalPrinterGeneric); //Line Feed _thermalPrinterGeneric.LineFeed(); //Get Final Rendered DataTable Groups Dictionary <DataTableGroupPropertiesType, DataTableGroupProperties> dictGroupProperties = GenDataTableWorkSessionMovementResume(pWorkSessionPeriod.PeriodType, pSplitCurrentAccountMode, sqlWhere); //Prepare Local vars for Group Loop XPSelectData xPSelectData = null; string designation = string.Empty; decimal quantity = 0.0m; decimal total = 0.0m; string unitMeasure = string.Empty; //Store Final Totals decimal summaryTotalQuantity = 0.0m; decimal summaryTotal = 0.0m; //Used to Custom Print Table Ticket Rows List <string> tableCustomPrint = new List <string>(); //Start to process Group int groupPosition = -1; //Assign Position to Print Payment Group Split Title int groupPositionTitlePayments = (pWorkSessionPeriod.PeriodType == WorkSessionPeriodType.Day) ? 9 : 8; //If CurrentAccount Mode decrease 1, it dont have PaymentMethods if (pSplitCurrentAccountMode == SplitCurrentAccountMode.CurrentAcount) { groupPositionTitlePayments--; } foreach (KeyValuePair <DataTableGroupPropertiesType, DataTableGroupProperties> item in dictGroupProperties) //foreach (DataTableGroupProperties item in dictGroupProperties.Values) { if (item.Value.Enabled) { //Increment Group Position groupPosition++; //Print Group Titles (FinanceDocuments|Payments) if (groupPosition == 0) { _thermalPrinterGeneric.WriteLine(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_finance_documents"), WriteLineTextMode.Big); _thermalPrinterGeneric.LineFeed(); } else if (groupPosition == groupPositionTitlePayments) { //When finish FinanceDocuemnts groups, print Last Row, the Summary Totals Row _thermalPrinterGeneric.WriteLine(tableCustomPrint[tableCustomPrint.Count - 1], WriteLineTextMode.DoubleHeight); _thermalPrinterGeneric.LineFeed(); _thermalPrinterGeneric.WriteLine(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_worksession_resume_paymens_documents"), WriteLineTextMode.Big); _thermalPrinterGeneric.LineFeed(); } //Reset Totals summaryTotalQuantity = 0.0m; summaryTotal = 0.0m; //Get Group Data from group Query xPSelectData = FrameworkUtils.GetSelectedDataFromQuery(item.Value.Sql); //Generate Columns columns = new List <TicketColumn>(); columns.Add(new TicketColumn("GroupTitle", item.Value.Title, 0, TicketColumnsAlign.Left)); columns.Add(new TicketColumn("Quantity", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_quantity_acronym"), 8, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); //columns.Add(new TicketColumn("UnitMeasure", string.Empty, 3)); columns.Add(new TicketColumn("Total", resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_totalfinal_acronym"), 10, TicketColumnsAlign.Right, typeof(decimal), "{0:0.00}")); //Init DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("GroupDesignation", typeof(string))); dataTable.Columns.Add(new DataColumn("Quantity", typeof(decimal))); //dataTable.Columns.Add(new DataColumn("UnitMeasure", typeof(string))); dataTable.Columns.Add(new DataColumn("Total", typeof(decimal))); //If Has data if (xPSelectData.Data.Length > 0) { foreach (SelectStatementResultRow row in xPSelectData.Data) { designation = Convert.ToString(row.Values[xPSelectData.GetFieldIndex("Designation")]); quantity = Convert.ToDecimal(row.Values[xPSelectData.GetFieldIndex("Quantity")]); unitMeasure = Convert.ToString(row.Values[xPSelectData.GetFieldIndex("UnitMeasure")]); total = Convert.ToDecimal(row.Values[xPSelectData.GetFieldIndex("Total")]); // Override Encrypted values if (GlobalFramework.PluginSoftwareVendor != null && item.Key.Equals(DataTableGroupPropertiesType.DocumentsUser) || item.Key.Equals(DataTableGroupPropertiesType.PaymentsUser)) { designation = GlobalFramework.PluginSoftwareVendor.Decrypt(designation); } //Sum Summary Totals summaryTotalQuantity += quantity; summaryTotal += total; //_log.Debug(string.Format("Designation: [{0}], quantity: [{1}], unitMeasure: [{2}], total: [{3}]", designation, quantity, unitMeasure, total)); //Create Row dataRow = dataTable.NewRow(); dataRow[0] = designation; dataRow[1] = quantity; //dataRow[2] = unitMeasure; dataRow[2] = total; dataTable.Rows.Add(dataRow); } } else { //Create Row dataRow = dataTable.NewRow(); dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_cashdrawer_without_movements"); dataRow[1] = 0.0m; //dataRow[2] = string.Empty;//UnitMeasure dataRow[2] = 0.0m; dataTable.Rows.Add(dataRow); } //Add Final Summary Row dataRow = dataTable.NewRow(); dataRow[0] = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_total"); dataRow[1] = summaryTotalQuantity; //dataRow[2] = string.Empty; dataRow[2] = summaryTotal; dataTable.Rows.Add(dataRow); //Prepare TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormal); //Custom Print Loop, to Print all Table Rows, and Detect Rows to Print in DoubleHeight (Title and Total) tableCustomPrint = ticketTable.GetTable(); WriteLineTextMode rowTextMode; //Dynamic Print All except Last One (Totals), Double Height in Titles for (int i = 0; i < tableCustomPrint.Count - 1; i++) { //Prepare TextMode Based on Row rowTextMode = (i == 0) ? WriteLineTextMode.DoubleHeight : WriteLineTextMode.Normal; //Print Row _thermalPrinterGeneric.WriteLine(tableCustomPrint[i], rowTextMode); } //Line Feed _thermalPrinterGeneric.LineFeed(); } } //When finish all groups, print Last Row, the Summary Totals Row, Ommited in Custom Print Loop _thermalPrinterGeneric.WriteLine(tableCustomPrint[tableCustomPrint.Count - 1], WriteLineTextMode.DoubleHeight); result = true; } catch (Exception ex) { _log.Error(ex.Message, ex); throw new Exception(ex.Message); } } return(result); }
//Totals, with TotalDelivery and TotalChange private void PrintMasterTotals() { try { //Init DataTable DataRow dataRow = null; DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("Label", typeof(string))); dataTable.Columns.Add(new DataColumn("Value", typeof(string))); //Add Row : Discount if (_documentFinanceMasterList[0].Discount > 0.0m) { dataRow = dataTable.NewRow(); dataRow[0] = string.Format("{0} (%)", Resx.global_discount); dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].Discount); dataTable.Rows.Add(dataRow); } //Add Row : TotalGross dataRow = dataTable.NewRow(); dataRow[0] = Resx.global_documentfinance_totalgross; //dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalGross * _documentFinanceMasterList[0].ExchangeRate); dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalNet * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); //Add Row : TotalDiscount if (_documentFinanceMasterList[0].TotalDiscount > 0.0m) { dataRow = dataTable.NewRow(); dataRow[0] = Resx.global_documentfinance_discount_customer; dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalDiscount * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); } //Add Row : Discount PaymentCondition //WIP Always 0 //Add Row : TotalTax dataRow = dataTable.NewRow(); dataRow[0] = Resx.global_documentfinance_totaltax; dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalTax * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); //Add Row : TotalFinal dataRow = dataTable.NewRow(); dataRow[0] = Resx.global_documentfinance_totalfinal; dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalFinal * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); //If Simplified Invoice, Payment Method MONEY and has Total Change, add it if (new Guid(_documentFinanceMasterList[0].DocumentType) == SettingsApp.XpoOidDocumentFinanceTypeSimplifiedInvoice && _documentFinanceMasterList[0].PaymentMethodToken == "MONEY" && _documentFinanceMasterList[0].TotalChange > 0 ) { //Blank Row, to separate from Main Totals dataRow = dataTable.NewRow(); dataRow[0] = string.Empty; dataRow[1] = string.Empty; dataTable.Rows.Add(dataRow); //TotalDelivery dataRow = dataTable.NewRow(); dataRow[0] = Resx.global_total_deliver; dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalDelivery * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); //TotalChange dataRow = dataTable.NewRow(); dataRow[0] = Resx.global_total_change; dataRow[1] = FrameworkUtils.DecimalToString(_documentFinanceMasterList[0].TotalChange * _documentFinanceMasterList[0].ExchangeRate); dataTable.Rows.Add(dataRow); } //Configure Ticket Column Properties List <TicketColumn> columns = new List <TicketColumn>(); columns.Add(new TicketColumn("Label", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Left)); columns.Add(new TicketColumn("Value", "", Convert.ToInt16(_maxCharsPerLineNormal / 2) - 2, TicketColumnsAlign.Right)); //TicketTable(DataTable pDataTable, List<TicketColumn> pColumnsProperties, int pTableWidth) TicketTable ticketTable = new TicketTable(dataTable, columns, _thermalPrinterGeneric.MaxCharsPerLineNormalBold); //Custom Print Loop, to Print all Table Rows, and Detect Rows to Print in DoubleHeight (TotalChange(4) and Total(7)) List <string> table = ticketTable.GetTable(); WriteLineTextMode rowTextMode; //Dynamic Print All, some Rows ommited/bold(Table Header, TotalDocument,TotalChange) for (int i = 1; i < table.Count; i++) { //Prepare TextMode Based on Row rowTextMode = (i == 5 || i == 8) ? WriteLineTextMode.DoubleHeightBold : WriteLineTextMode.Bold; //Print Row _thermalPrinterGeneric.WriteLine(table[i], rowTextMode); } //Line Feed _thermalPrinterGeneric.LineFeed(); } catch (Exception ex) { throw ex; } }