From 5e64209b76e9b7fa67b8958e15858e62ad6413b4 Mon Sep 17 00:00:00 2001 From: tanshu Date: Mon, 4 Jul 2016 11:51:39 +0530 Subject: [PATCH] Feature: Added a Tax Management form and a beer consumption report. Chore: Fixed some Form_Load function names as they were copied from old forms and were not neat. Feature: Management BI Improved and should be pretty much solid by now. --- .../Data Contracts Display/SalesAnalysisBO.cs | 7 + Tanshu.Accounts.PointOfSale/MainForm.cs | 23 ++- .../MainForm.designer.cs | 48 ++++- .../Management/ManagementForm.cs | 9 +- .../Management/ManagementForm.designer.cs | 2 +- .../Masters/ReorderTableForm.Designer.cs | 2 +- .../Masters/ReorderTableForm.cs | 2 +- .../Masters/TaxEditForm.Designer.cs | 136 ++++++++++++ .../Masters/TaxEditForm.cs | 81 ++++++++ .../Masters/TaxEditForm.resx | 123 +++++++++++ .../Masters/TaxListForm.Designer.cs | 157 ++++++++++++++ .../Masters/TaxListForm.cs | 64 ++++++ .../Masters/TaxListForm.resx | 123 +++++++++++ .../Products/ProductForm.Designer.cs | 2 +- .../Products/ProductForm.cs | 2 +- .../Products/ProductListForm.Designer.cs | 2 +- .../Products/ProductListForm.cs | 2 +- .../Reports/BeerConsumptionForm.cs | 102 +++++++++ .../Reports/BeerConsumptionForm.designer.cs | 195 ++++++++++++++++++ .../Reports/BeerConsumptionForm.resx | 138 +++++++++++++ .../Reports/BillDetailsForm.cs | 2 +- .../Reports/BillDetailsForm.designer.cs | 2 +- .../Reports/CheckoutForm.Designer.cs | 4 +- .../Reports/CheckoutForm.cs | 6 +- .../Reports/DiscountReportForm.cs | 2 +- .../Reports/DiscountReportForm.designer.cs | 2 +- .../{SaleDetail.cs => SaleDetailForm.cs} | 6 +- ...designer.cs => SaleDetailForm.designer.cs} | 4 +- .../{SaleDetail.resx => SaleDetailForm.resx} | 0 .../Reports/TaxAnalysisForm.cs | 6 +- .../Reports/TaxAnalysisForm.designer.cs | 4 +- .../Reports/VoidReprintedForm.cs | 2 +- .../Reports/VoidReprintedForm.designer.cs | 2 +- .../Tanshu.Accounts.PointOfSale.csproj | 50 ++++- ...signer.cs => AssignGroupRoles.Designer.cs} | 0 ...ssignRoleGroups.cs => AssignGroupRoles.cs} | 0 ...nRoleGroups.resx => AssignGroupRoles.resx} | 0 .../AssignUserGroups.Designer.cs | 2 +- .../User Management/AssignUserGroups.cs | 2 +- Tanshu.Accounts.Repository/ManagementBI.cs | 62 +++++- Tanshu.Accounts.Repository/ReportsBI.cs | 38 ++++ 41 files changed, 1360 insertions(+), 56 deletions(-) create mode 100644 Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.Designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.resx create mode 100644 Tanshu.Accounts.PointOfSale/Masters/TaxListForm.Designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Masters/TaxListForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Masters/TaxListForm.resx create mode 100644 Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.cs create mode 100644 Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.designer.cs create mode 100644 Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.resx rename Tanshu.Accounts.PointOfSale/Reports/{SaleDetail.cs => SaleDetailForm.cs} (94%) rename Tanshu.Accounts.PointOfSale/Reports/{SaleDetail.designer.cs => SaleDetailForm.designer.cs} (98%) rename Tanshu.Accounts.PointOfSale/Reports/{SaleDetail.resx => SaleDetailForm.resx} (100%) rename Tanshu.Accounts.PointOfSale/User Management/{AssignRoleGroups.Designer.cs => AssignGroupRoles.Designer.cs} (100%) rename Tanshu.Accounts.PointOfSale/User Management/{AssignRoleGroups.cs => AssignGroupRoles.cs} (100%) rename Tanshu.Accounts.PointOfSale/User Management/{AssignRoleGroups.resx => AssignGroupRoles.resx} (100%) diff --git a/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs b/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs index 91b057c..2c00b77 100644 --- a/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs +++ b/Tanshu.Accounts.Contracts/Data Contracts Display/SalesAnalysisBO.cs @@ -43,4 +43,11 @@ namespace Tanshu.Accounts.Contracts public virtual decimal Amount { get; set; } public virtual string Settlement { get; set; } } + public class BeerConsumptionDetail + { + public virtual DateTime Date { get; set; } + public virtual Guid ProductID { get; set; } + public virtual string Name { get; set; } + public virtual decimal Quantity { get; set; } + } } diff --git a/Tanshu.Accounts.PointOfSale/MainForm.cs b/Tanshu.Accounts.PointOfSale/MainForm.cs index d13faf9..dc73852 100644 --- a/Tanshu.Accounts.PointOfSale/MainForm.cs +++ b/Tanshu.Accounts.PointOfSale/MainForm.cs @@ -87,7 +87,7 @@ namespace Tanshu.Accounts.PointOfSale private void btnCashierCheckout_Click(object sender, EventArgs e) { if (Session.IsAllowed("Cashier Checkout")) - using (var frm = new CashierCheckoutForm()) + using (var frm = new CheckoutForm()) frm.ShowDialog(); } @@ -101,7 +101,7 @@ namespace Tanshu.Accounts.PointOfSale private void btnSaleDetail_Click(object sender, EventArgs e) { if (Session.IsAllowed("Sales Detail")) - using (var frm = new FrmSaleDetail()) + using (var frm = new SaleDetailForm()) frm.ShowDialog(); } @@ -153,8 +153,10 @@ namespace Tanshu.Accounts.PointOfSale btnSaleDetail.Visible = Session.IsAllowed("Sales Detail"); btnBillDetails.Visible = Session.IsAllowed("Bill Details"); + btnBeerConsumption.Visible = Session.IsAllowed("Beer Consumption"); btnVoidOrReprints.Visible = Session.IsAllowed("Void or Reprinted Bill Report"); btnDiscountReport.Visible = Session.IsAllowed("Discount Report"); + btnTaxes.Visible = Session.IsAllowed("Discount Report"); btnChangePassword.Visible = Session.IsAuthenticated; #if (DEBUG) @@ -301,8 +303,23 @@ namespace Tanshu.Accounts.PointOfSale private void btnTaxAnalysis_Click(object sender, EventArgs e) { if (Session.IsAllowed("Tax Analysis")) - using (var frm = new frmTaxAnalysisForm()) + using (var frm = new TaxAnalysisForm()) frm.ShowDialog(); } + + private void btnBeerConsumption_Click(object sender, EventArgs e) + { + if (Session.IsAllowed("Beer Consumption")) + using (var frm = new BeerConsumptionForm()) + frm.ShowDialog(); + } + + private void btnTaxes_Click(object sender, EventArgs e) + { + if (Session.IsAllowed("Taxes")) + using (var frm = new TaxListForm()) + frm.ShowDialog(); + } + } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/MainForm.designer.cs b/Tanshu.Accounts.PointOfSale/MainForm.designer.cs index b855292..d38f0ac 100644 --- a/Tanshu.Accounts.PointOfSale/MainForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/MainForm.designer.cs @@ -47,10 +47,12 @@ this.btnTaxAnalysis = new System.Windows.Forms.Button(); this.btnSaleDetail = new System.Windows.Forms.Button(); this.btnBillDetails = new System.Windows.Forms.Button(); + this.btnBeerConsumption = new System.Windows.Forms.Button(); this.btnVoidOrReprints = new System.Windows.Forms.Button(); this.btnDiscountReport = new System.Windows.Forms.Button(); this.btnChangePassword = new System.Windows.Forms.Button(); this.btnManagement = new System.Windows.Forms.Button(); + this.btnTaxes = new System.Windows.Forms.Button(); this.btnExit = new System.Windows.Forms.Button(); this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); @@ -95,10 +97,12 @@ this.flowLayoutPanel1.Controls.Add(this.btnTaxAnalysis); this.flowLayoutPanel1.Controls.Add(this.btnSaleDetail); this.flowLayoutPanel1.Controls.Add(this.btnBillDetails); + this.flowLayoutPanel1.Controls.Add(this.btnBeerConsumption); this.flowLayoutPanel1.Controls.Add(this.btnVoidOrReprints); this.flowLayoutPanel1.Controls.Add(this.btnDiscountReport); this.flowLayoutPanel1.Controls.Add(this.btnChangePassword); this.flowLayoutPanel1.Controls.Add(this.btnManagement); + this.flowLayoutPanel1.Controls.Add(this.btnTaxes); this.flowLayoutPanel1.Controls.Add(this.btnExit); this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); @@ -266,52 +270,72 @@ this.btnBillDetails.UseVisualStyleBackColor = true; this.btnBillDetails.Click += new System.EventHandler(this.btnBillDetails_Click); // + // btnBeerConsumption + // + this.btnBeerConsumption.Location = new System.Drawing.Point(471, 321); + this.btnBeerConsumption.Name = "btnBeerConsumption"; + this.btnBeerConsumption.Size = new System.Drawing.Size(150, 100); + this.btnBeerConsumption.TabIndex = 18; + this.btnBeerConsumption.Text = "Beer Consumption"; + this.btnBeerConsumption.UseVisualStyleBackColor = true; + this.btnBeerConsumption.Click += new System.EventHandler(this.btnBeerConsumption_Click); + // // btnVoidOrReprints // - this.btnVoidOrReprints.Location = new System.Drawing.Point(471, 321); + this.btnVoidOrReprints.Location = new System.Drawing.Point(627, 321); this.btnVoidOrReprints.Name = "btnVoidOrReprints"; this.btnVoidOrReprints.Size = new System.Drawing.Size(150, 100); - this.btnVoidOrReprints.TabIndex = 18; + this.btnVoidOrReprints.TabIndex = 19; this.btnVoidOrReprints.Text = "Voids or Reprints"; this.btnVoidOrReprints.UseVisualStyleBackColor = true; this.btnVoidOrReprints.Click += new System.EventHandler(this.btnVoidOrReprints_Click); // // btnDiscountReport // - this.btnDiscountReport.Location = new System.Drawing.Point(627, 321); + this.btnDiscountReport.Location = new System.Drawing.Point(3, 427); this.btnDiscountReport.Name = "btnDiscountReport"; this.btnDiscountReport.Size = new System.Drawing.Size(150, 100); - this.btnDiscountReport.TabIndex = 19; + this.btnDiscountReport.TabIndex = 20; this.btnDiscountReport.Text = "Discount Report"; this.btnDiscountReport.UseVisualStyleBackColor = true; this.btnDiscountReport.Click += new System.EventHandler(this.btnDiscountReport_Click); // // btnChangePassword // - this.btnChangePassword.Location = new System.Drawing.Point(3, 427); + this.btnChangePassword.Location = new System.Drawing.Point(159, 427); this.btnChangePassword.Name = "btnChangePassword"; this.btnChangePassword.Size = new System.Drawing.Size(150, 100); - this.btnChangePassword.TabIndex = 20; + this.btnChangePassword.TabIndex = 21; this.btnChangePassword.Text = "Change Password"; this.btnChangePassword.UseVisualStyleBackColor = true; this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click); // // btnManagement // - this.btnManagement.Location = new System.Drawing.Point(159, 427); + this.btnManagement.Location = new System.Drawing.Point(315, 427); this.btnManagement.Name = "btnManagement"; this.btnManagement.Size = new System.Drawing.Size(150, 100); - this.btnManagement.TabIndex = 21; + this.btnManagement.TabIndex = 22; this.btnManagement.Text = "Management"; this.btnManagement.UseVisualStyleBackColor = true; this.btnManagement.Click += new System.EventHandler(this.btnManagement_Click); // + // btnTaxes + // + this.btnTaxes.Location = new System.Drawing.Point(471, 427); + this.btnTaxes.Name = "btnTaxes"; + this.btnTaxes.Size = new System.Drawing.Size(150, 100); + this.btnTaxes.TabIndex = 23; + this.btnTaxes.Text = "Taxes"; + this.btnTaxes.UseVisualStyleBackColor = true; + this.btnTaxes.Click += new System.EventHandler(this.btnTaxes_Click); + // // btnExit // - this.btnExit.Location = new System.Drawing.Point(315, 427); + this.btnExit.Location = new System.Drawing.Point(627, 427); this.btnExit.Name = "btnExit"; this.btnExit.Size = new System.Drawing.Size(150, 100); - this.btnExit.TabIndex = 22; + this.btnExit.TabIndex = 24; this.btnExit.Text = "Exit"; this.btnExit.UseVisualStyleBackColor = true; this.btnExit.Click += new System.EventHandler(this.btnExit_Click); @@ -353,11 +377,13 @@ private System.Windows.Forms.Button btnSaleAnalysis; private System.Windows.Forms.Button btnSaleDetail; private System.Windows.Forms.Button btnBillDetails; + private System.Windows.Forms.Button btnTaxAnalysis; + private System.Windows.Forms.Button btnBeerConsumption; private System.Windows.Forms.Button btnVoidOrReprints; private System.Windows.Forms.Button btnDiscountReport; private System.Windows.Forms.Button btnChangePassword; private System.Windows.Forms.Button btnManagement; + private System.Windows.Forms.Button btnTaxes; private System.Windows.Forms.Button btnExit; - private System.Windows.Forms.Button btnTaxAnalysis; } } \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Management/ManagementForm.cs b/Tanshu.Accounts.PointOfSale/Management/ManagementForm.cs index 5857de1..e9d72c4 100644 --- a/Tanshu.Accounts.PointOfSale/Management/ManagementForm.cs +++ b/Tanshu.Accounts.PointOfSale/Management/ManagementForm.cs @@ -34,7 +34,7 @@ namespace Tanshu.Accounts.Management bwExcel.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwExcel_RunWorkerCompleted); } - private void Sale_Analysis_Form_Load(object sender, EventArgs e) + private void ManagementForm_Load(object sender, EventArgs e) { dtpStart.Value = DateTime.Today; dtpFinish.Value = DateTime.Today; @@ -179,6 +179,13 @@ namespace Tanshu.Accounts.Management e.Cancel = true; return; } + bi.IncreaseLiqIfLess(item.Sale.Where(x=>x.IsLiq).ToList(), startDate, finishDate); + bwGo.ReportProgress(++count, "Sale Done"); + if (bwGo.CancellationPending == true) + { + e.Cancel = true; + return; + } bi.SaveChanges(); } bwGo.ReportProgress(++count, "Cleanup done"); diff --git a/Tanshu.Accounts.PointOfSale/Management/ManagementForm.designer.cs b/Tanshu.Accounts.PointOfSale/Management/ManagementForm.designer.cs index 473c8de..6efb40e 100644 --- a/Tanshu.Accounts.PointOfSale/Management/ManagementForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/Management/ManagementForm.designer.cs @@ -133,7 +133,7 @@ this.Name = "ManagementForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Sale Analysis Form"; - this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load); + this.Load += new System.EventHandler(this.ManagementForm_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Tanshu.Accounts.PointOfSale/Masters/ReorderTableForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Masters/ReorderTableForm.Designer.cs index 2da28c3..6dc907a 100644 --- a/Tanshu.Accounts.PointOfSale/Masters/ReorderTableForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Masters/ReorderTableForm.Designer.cs @@ -55,7 +55,7 @@ this.Name = "ReorderTableForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Move Table / Kot"; - this.Load += new System.EventHandler(this.MoveTableForm_Load); + this.Load += new System.EventHandler(this.ReorderTableForm_Load); this.ResumeLayout(false); } diff --git a/Tanshu.Accounts.PointOfSale/Masters/ReorderTableForm.cs b/Tanshu.Accounts.PointOfSale/Masters/ReorderTableForm.cs index ad4fdc2..04d4eee 100644 --- a/Tanshu.Accounts.PointOfSale/Masters/ReorderTableForm.cs +++ b/Tanshu.Accounts.PointOfSale/Masters/ReorderTableForm.cs @@ -53,7 +53,7 @@ namespace Tanshu.Accounts.PointOfSale } public FoodTable Selection { get; private set; } - private void MoveTableForm_Load(object sender, EventArgs e) + private void ReorderTableForm_Load(object sender, EventArgs e) { GenerateTables(new Point(75, 75)); } diff --git a/Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.Designer.cs new file mode 100644 index 0000000..5d79d0c --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.Designer.cs @@ -0,0 +1,136 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class TaxEditForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.txtName = new System.Windows.Forms.TextBox(); + this.Label2 = new System.Windows.Forms.Label(); + this.Label5 = new System.Windows.Forms.Label(); + this.btnOk = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.bsLocations = new System.Windows.Forms.BindingSource(this.components); + this.txtRate = new System.Windows.Forms.TextBox(); + ((System.ComponentModel.ISupportInitialize)(this.bsLocations)).BeginInit(); + this.SuspendLayout(); + // + // txtName + // + this.txtName.AccessibleName = ""; + this.txtName.Location = new System.Drawing.Point(94, 12); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(276, 20); + this.txtName.TabIndex = 0; + // + // Label2 + // + this.Label2.AutoSize = true; + this.Label2.Location = new System.Drawing.Point(40, 15); + this.Label2.Name = "Label2"; + this.Label2.Size = new System.Drawing.Size(25, 13); + this.Label2.TabIndex = 10; + this.Label2.Text = "Tax"; + // + // Label5 + // + this.Label5.AutoSize = true; + this.Label5.Location = new System.Drawing.Point(40, 41); + this.Label5.Name = "Label5"; + this.Label5.Size = new System.Drawing.Size(30, 13); + this.Label5.TabIndex = 11; + this.Label5.Text = "Rate"; + // + // btnOk + // + this.btnOk.Location = new System.Drawing.Point(214, 65); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 75); + this.btnOk.TabIndex = 6; + this.btnOk.Text = "&Ok"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(295, 65); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 75); + this.btnCancel.TabIndex = 7; + this.btnCancel.Text = "&Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // bsLocations + // + this.bsLocations.DataSource = typeof(string); + // + // txtRate + // + this.txtRate.AccessibleName = ""; + this.txtRate.Location = new System.Drawing.Point(94, 38); + this.txtRate.Name = "txtRate"; + this.txtRate.Size = new System.Drawing.Size(276, 20); + this.txtRate.TabIndex = 22; + // + // TaxEditForm + // + this.AcceptButton = this.btnOk; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(382, 153); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.Label5); + this.Controls.Add(this.txtName); + this.Controls.Add(this.Label2); + this.Controls.Add(this.txtRate); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TaxEditForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Taxes"; + this.Load += new System.EventHandler(this.TaxEditForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.bsLocations)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.TextBox txtName; + internal System.Windows.Forms.Label Label2; + internal System.Windows.Forms.Label Label5; + private System.Windows.Forms.Button btnOk; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.BindingSource bsLocations; + internal System.Windows.Forms.TextBox txtRate; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.cs b/Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.cs new file mode 100644 index 0000000..c7dd14e --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.cs @@ -0,0 +1,81 @@ +using System; +using System.Windows.Forms; +using Tanshu.Accounts.Repository; +using Tanshu.Accounts.Entities; +using System.Linq; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class TaxEditForm : Form + { + private Guid? _taxID; + public TaxEditForm(Guid taxID) + : this() + { + _taxID = taxID; + } + + public TaxEditForm() + { + InitializeComponent(); + } + + private void TaxEditForm_Load(object sender, EventArgs e) + { + Tax tax; + if (_taxID.HasValue) + { + using (var bi = new TaxBI()) + { + tax = bi.Get(x => x.TaxID == _taxID.Value); + txtName.Text = tax.Name; + txtRate.Text = (tax.Rate * 100).ToString(); + } + } + txtName.Focus(); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void btnOk_Click(object sender, EventArgs e) + { + Tax tax; + using (var bi = new TaxBI()) + { + if (_taxID.HasValue) + tax = bi.Get(x => x.TaxID == _taxID.Value); + else + tax = new Tax(); + + if (string.IsNullOrEmpty(txtName.Text.Trim())) + return; + tax.Name = txtName.Text.Trim(); + + if (string.IsNullOrEmpty(txtRate.Text.Trim())) + txtRate.Text = "0"; + decimal rate; + if (!decimal.TryParse(txtRate.Text, out rate) || (rate < 0 || rate > 100)) + { + MessageBox.Show("Tax Rate is not valid, it must be between 0 to 100 percent."); + txtRate.Focus(); + return; + } + else + tax.Rate = rate / 100; + + if (_taxID.HasValue) + bi.Update(tax); + else + bi.Insert(tax); + bi.SaveChanges(); + } + MessageBox.Show("Update / Save Successful"); + this.Close(); + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.resx b/Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.resx new file mode 100644 index 0000000..ac1282d --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Masters/TaxEditForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Masters/TaxListForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Masters/TaxListForm.Designer.cs new file mode 100644 index 0000000..e4fe2bf --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Masters/TaxListForm.Designer.cs @@ -0,0 +1,157 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class TaxListForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + this.btnAdd = new System.Windows.Forms.Button(); + this.btnEdit = new System.Windows.Forms.Button(); + this.btnExit = new System.Windows.Forms.Button(); + this.dgvTaxes = new System.Windows.Forms.DataGridView(); + this.bsList = new System.Windows.Forms.BindingSource(this.components); + this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.rateDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dgvTaxes)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsList)).BeginInit(); + this.SuspendLayout(); + // + // btnAdd + // + this.btnAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnAdd.Location = new System.Drawing.Point(12, 255); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(75, 75); + this.btnAdd.TabIndex = 68; + this.btnAdd.Text = "&Add"; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // btnEdit + // + this.btnEdit.AccessibleName = "Done"; + this.btnEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnEdit.Location = new System.Drawing.Point(93, 255); + this.btnEdit.Name = "btnEdit"; + this.btnEdit.Size = new System.Drawing.Size(75, 75); + this.btnEdit.TabIndex = 62; + this.btnEdit.Text = "&Edit"; + this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click); + // + // btnExit + // + this.btnExit.AccessibleName = "Done"; + this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnExit.Location = new System.Drawing.Point(514, 255); + this.btnExit.Name = "btnExit"; + this.btnExit.Size = new System.Drawing.Size(75, 75); + this.btnExit.TabIndex = 61; + this.btnExit.Text = "E&xit"; + this.btnExit.Click += new System.EventHandler(this.btnExit_Click); + // + // dgvTaxes + // + this.dgvTaxes.AllowUserToAddRows = false; + this.dgvTaxes.AllowUserToDeleteRows = false; + this.dgvTaxes.AllowUserToResizeRows = false; + this.dgvTaxes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dgvTaxes.AutoGenerateColumns = false; + this.dgvTaxes.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; + this.dgvTaxes.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvTaxes.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.nameDataGridViewTextBoxColumn, + this.rateDataGridViewTextBoxColumn}); + this.dgvTaxes.DataSource = this.bsList; + this.dgvTaxes.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; + this.dgvTaxes.Location = new System.Drawing.Point(12, 12); + this.dgvTaxes.MultiSelect = false; + this.dgvTaxes.Name = "dgvTaxes"; + this.dgvTaxes.ReadOnly = true; + this.dgvTaxes.RowHeadersVisible = false; + this.dgvTaxes.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; + this.dgvTaxes.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvTaxes.Size = new System.Drawing.Size(577, 237); + this.dgvTaxes.TabIndex = 74; + this.dgvTaxes.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvTaxes_CellFormatting); + // + // bsList + // + this.bsList.DataSource = typeof(Tanshu.Accounts.Entities.Tax); + // + // nameDataGridViewTextBoxColumn + // + this.nameDataGridViewTextBoxColumn.DataPropertyName = "Name"; + this.nameDataGridViewTextBoxColumn.HeaderText = "Name"; + this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn"; + this.nameDataGridViewTextBoxColumn.ReadOnly = true; + this.nameDataGridViewTextBoxColumn.Width = 60; + // + // rateDataGridViewTextBoxColumn + // + this.rateDataGridViewTextBoxColumn.DataPropertyName = "Rate"; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; + this.rateDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle1; + this.rateDataGridViewTextBoxColumn.HeaderText = "Rate"; + this.rateDataGridViewTextBoxColumn.Name = "rateDataGridViewTextBoxColumn"; + this.rateDataGridViewTextBoxColumn.ReadOnly = true; + this.rateDataGridViewTextBoxColumn.Width = 55; + // + // TaxListForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(601, 342); + this.Controls.Add(this.dgvTaxes); + this.Controls.Add(this.btnAdd); + this.Controls.Add(this.btnEdit); + this.Controls.Add(this.btnExit); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TaxListForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Taxes"; + this.Load += new System.EventHandler(this.TaxListForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvTaxes)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.bsList)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + internal System.Windows.Forms.Button btnAdd; + internal System.Windows.Forms.Button btnEdit; + internal System.Windows.Forms.Button btnExit; + private System.Windows.Forms.DataGridView dgvTaxes; + private System.Windows.Forms.BindingSource bsList; + private System.Windows.Forms.DataGridViewTextBoxColumn machineDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn nameDataGridViewTextBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn rateDataGridViewTextBoxColumn; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Masters/TaxListForm.cs b/Tanshu.Accounts.PointOfSale/Masters/TaxListForm.cs new file mode 100644 index 0000000..7308900 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Masters/TaxListForm.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Tanshu.Accounts.Entities; +using Tanshu.Accounts.Repository; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class TaxListForm : Form + { + private IList _list; + public TaxListForm() + { + InitializeComponent(); + } + + private void btnAdd_Click(object sender, EventArgs e) + { + using (var frm = new TaxEditForm()) + frm.ShowDialog(); + using (var bi = new TaxBI()) + _list = bi.List(); + bsList.DataSource = _list; + } + + private void TaxListForm_Load(object sender, EventArgs e) + { + using (var bi = new TaxBI()) + _list = bi.List(); + bsList.DataSource = _list; + } + + private void btnEdit_Click(object sender, EventArgs e) + { + var id = ((Tax)bsList.Current).TaxID; + using (var frm = new TaxEditForm(id)) + frm.ShowDialog(); + using (var bi = new TaxBI()) + _list = bi.List(); + bsList.DataSource = _list; + } + + private void btnExit_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void dgvTaxes_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + var data = dgvTaxes.Rows[e.RowIndex].DataBoundItem as Tax; + if (data == null) + return; + if (e.ColumnIndex != 1) + return; + var rate = (decimal)e.Value; + e.Value = string.Format("{0:P}", rate); + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Masters/TaxListForm.resx b/Tanshu.Accounts.PointOfSale/Masters/TaxListForm.resx new file mode 100644 index 0000000..c80ceb8 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Masters/TaxListForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs index 53bd969..7246aab 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductForm.Designer.cs @@ -289,7 +289,7 @@ this.Name = "ProductForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Products"; - this.Load += new System.EventHandler(this.Products_Load); + this.Load += new System.EventHandler(this.ProductForm_Load); ((System.ComponentModel.ISupportInitialize)(this.bsProductGroups)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.bsServiceTax)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.bsVat)).EndInit(); diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs b/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs index 5e1b8e5..e4cafad 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductForm.cs @@ -15,7 +15,7 @@ namespace Tanshu.Accounts.PointOfSale InitializeComponent(); } - private void Products_Load(object sender, EventArgs e) + private void ProductForm_Load(object sender, EventArgs e) { FillCombos(); using (var bis = new SettingBI()) diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs index e378ce6..0670e7a 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.Designer.cs @@ -252,7 +252,7 @@ this.Name = "ProductListForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Products"; - this.Load += new System.EventHandler(this.ProductGroupListForm_Load); + this.Load += new System.EventHandler(this.ProductListForm_Load); ((System.ComponentModel.ISupportInitialize)(this.dgvProducts)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.bsList)).EndInit(); this.ResumeLayout(false); diff --git a/Tanshu.Accounts.PointOfSale/Products/ProductListForm.cs b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.cs index 9d9c8fd..e34cce6 100644 --- a/Tanshu.Accounts.PointOfSale/Products/ProductListForm.cs +++ b/Tanshu.Accounts.PointOfSale/Products/ProductListForm.cs @@ -24,7 +24,7 @@ namespace Tanshu.Accounts.PointOfSale bsList.DataSource = _list; } - private void ProductGroupListForm_Load(object sender, EventArgs e) + private void ProductListForm_Load(object sender, EventArgs e) { ShowGrid(); } diff --git a/Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.cs b/Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.cs new file mode 100644 index 0000000..b2f1c1a --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using Tanshu.Accounts.Repository; +using Tanshu.Accounts.Contracts; +using System.Data; +using System.Collections.Specialized; + +namespace Tanshu.Accounts.PointOfSale +{ + public partial class BeerConsumptionForm : Form + { + IList _list; + public BeerConsumptionForm() + { + InitializeComponent(); + dgvSale.AutoGenerateColumns = false; + } + + private void dtpStart_ValueChanged(object sender, EventArgs e) + { + ShowStatement(); + } + + private void ShowStatement() + { + if (DateTime.Today.Subtract(dtpStart.Value.Date).Days > 5 && !Session.IsAllowed("Accounts Audit")) + return; + var bi = new ReportsBI(); + _list = bi.BeerConsumption(dtpStart.Value, dtpFinish.Value); + dgvSale.DataSource = _list; + } + + private void dtpFinish_ValueChanged(object sender, EventArgs e) + { + ShowStatement(); + } + + private void BeerConsumptionForm_Load(object sender, EventArgs e) + { + dtpStart.Value = DateTime.Today; + dtpFinish.Value = DateTime.Today; + ShowStatement(); + } + + private void btnPrint_Click(object sender, EventArgs e) + { + if (_list == null) + return; + var startDate = dtpStart.Value.Date.AddHours(6); + var finishDate = dtpFinish.Value.Date.AddDays(1).AddHours(5); + //Print.Thermal.PrintSale(Session.User.Name, _list, startDate, finishDate); + } + + private void btnClose_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void btnExport_Click(object sender, EventArgs e) + { + var q = new decimal[_list.Select(x => x.Date.ToString("dd-MMM-yyyy")).Distinct().Count(), _list.Select(x => x.Name).Distinct().Count()]; + var dates = new List(); + var names = new List(); + string data; + foreach (var item in _list) + { + var date = item.Date.ToString("dd-MMM-yyyy"); + if (!dates.Contains(date)) + { + dates.Add(date); + } + if (!names.Contains(item.Name)) + { + names.Add(item.Name); + } + q[dates.IndexOf(date), names.IndexOf(item.Name)] += item.Quantity; + } + + if (_list == null) + return; + data = "Date"; + foreach (var item in names) + { + data += string.Format("\t{0}", item); + } + data += "\n"; + + for (int i = 0; i < dates.Count; i++) + { + data += dates[i]; + for (int j = 0; j < names.Count; j++) + { + data += string.Format("\t{0}", q[i, j]); + } + data += "\n"; + } + Clipboard.SetText(data, TextDataFormat.Text); + } + } +} diff --git a/Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.designer.cs b/Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.designer.cs new file mode 100644 index 0000000..6f13b9b --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.designer.cs @@ -0,0 +1,195 @@ +namespace Tanshu.Accounts.PointOfSale +{ + partial class BeerConsumptionForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + this.dgvSale = new System.Windows.Forms.DataGridView(); + this.dtpFinish = new System.Windows.Forms.DateTimePicker(); + this.dtpStart = new System.Windows.Forms.DateTimePicker(); + this.label10 = new System.Windows.Forms.Label(); + this.btnPrint = new System.Windows.Forms.Button(); + this.btnExport = new System.Windows.Forms.Button(); + this.btnClose = new System.Windows.Forms.Button(); + this.DateColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.QuantityColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).BeginInit(); + this.SuspendLayout(); + // + // dgvSale + // + this.dgvSale.AllowUserToAddRows = false; + this.dgvSale.AllowUserToDeleteRows = false; + this.dgvSale.AllowUserToResizeRows = false; + this.dgvSale.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dgvSale.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; + this.dgvSale.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvSale.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.DateColumn, + this.NameColumn, + this.QuantityColumn}); + this.dgvSale.Location = new System.Drawing.Point(12, 41); + this.dgvSale.MultiSelect = false; + this.dgvSale.Name = "dgvSale"; + this.dgvSale.ReadOnly = true; + this.dgvSale.RowHeadersVisible = false; + this.dgvSale.RowTemplate.Height = 19; + this.dgvSale.RowTemplate.ReadOnly = true; + this.dgvSale.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvSale.Size = new System.Drawing.Size(335, 385); + this.dgvSale.TabIndex = 14; + // + // dtpFinish + // + this.dtpFinish.CustomFormat = "dd-MMM-yyyy"; + this.dtpFinish.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.dtpFinish.Location = new System.Drawing.Point(168, 12); + this.dtpFinish.Name = "dtpFinish"; + this.dtpFinish.Size = new System.Drawing.Size(90, 20); + this.dtpFinish.TabIndex = 21; + this.dtpFinish.ValueChanged += new System.EventHandler(this.dtpFinish_ValueChanged); + // + // dtpStart + // + this.dtpStart.CustomFormat = "dd-MMM-yyyy"; + this.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Custom; + this.dtpStart.Location = new System.Drawing.Point(12, 12); + this.dtpStart.Name = "dtpStart"; + this.dtpStart.Size = new System.Drawing.Size(90, 20); + this.dtpStart.TabIndex = 20; + this.dtpStart.ValueChanged += new System.EventHandler(this.dtpStart_ValueChanged); + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(108, 16); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(54, 13); + this.label10.TabIndex = 22; + this.label10.Text = "<- Date ->"; + // + // btnPrint + // + this.btnPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnPrint.Location = new System.Drawing.Point(12, 432); + this.btnPrint.Name = "btnPrint"; + this.btnPrint.Size = new System.Drawing.Size(75, 75); + this.btnPrint.TabIndex = 28; + this.btnPrint.Text = "Print"; + this.btnPrint.UseVisualStyleBackColor = true; + this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click); + // + // btnExport + // + this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnExport.Location = new System.Drawing.Point(93, 432); + this.btnExport.Name = "btnExport"; + this.btnExport.Size = new System.Drawing.Size(75, 75); + this.btnExport.TabIndex = 29; + this.btnExport.Text = "Export"; + this.btnExport.UseVisualStyleBackColor = true; + this.btnExport.Click += new System.EventHandler(this.btnExport_Click); + // + // btnClose + // + this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnClose.Location = new System.Drawing.Point(272, 432); + this.btnClose.Name = "btnClose"; + this.btnClose.Size = new System.Drawing.Size(75, 75); + this.btnClose.TabIndex = 30; + this.btnClose.Text = "&Close"; + this.btnClose.UseVisualStyleBackColor = true; + this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + // + // DateColumn + // + this.DateColumn.DataPropertyName = "Date"; + this.DateColumn.HeaderText = "Date"; + this.DateColumn.Name = "DateColumn"; + this.DateColumn.ReadOnly = true; + this.DateColumn.Width = 55; + // + // NameColumn + // + this.NameColumn.DataPropertyName = "Name"; + this.NameColumn.HeaderText = "Name"; + this.NameColumn.Name = "NameColumn"; + this.NameColumn.ReadOnly = true; + this.NameColumn.Width = 60; + // + // QuantityColumn + // + this.QuantityColumn.DataPropertyName = "Quantity"; + dataGridViewCellStyle2.Format = "#,##0.00;(#,##0.00);0"; + this.QuantityColumn.DefaultCellStyle = dataGridViewCellStyle2; + this.QuantityColumn.HeaderText = "Quantity"; + this.QuantityColumn.Name = "QuantityColumn"; + this.QuantityColumn.ReadOnly = true; + this.QuantityColumn.Width = 71; + // + // BeerConsumption + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(359, 519); + this.Controls.Add(this.btnClose); + this.Controls.Add(this.btnExport); + this.Controls.Add(this.btnPrint); + this.Controls.Add(this.dgvSale); + this.Controls.Add(this.dtpFinish); + this.Controls.Add(this.dtpStart); + this.Controls.Add(this.label10); + this.MaximizeBox = false; + this.Name = "BeerConsumption"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Beer Consumption"; + this.TopMost = true; + this.Load += new System.EventHandler(this.BeerConsumptionForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.DataGridView dgvSale; + private System.Windows.Forms.DateTimePicker dtpFinish; + private System.Windows.Forms.DateTimePicker dtpStart; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Button btnPrint; + private System.Windows.Forms.Button btnExport; + private System.Windows.Forms.Button btnClose; + private System.Windows.Forms.DataGridViewTextBoxColumn DateColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn NameColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn QuantityColumn; + } +} \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.resx b/Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.resx new file mode 100644 index 0000000..ae7a319 --- /dev/null +++ b/Tanshu.Accounts.PointOfSale/Reports/BeerConsumptionForm.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs index d393b28..8e90be6 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.cs @@ -39,7 +39,7 @@ namespace Tanshu.Accounts.PointOfSale ShowStatement(); } - private void Sale_Analysis_Form_Load(object sender, EventArgs e) + private void BillDetailsForm_Load(object sender, EventArgs e) { dtpStart.Value = DateTime.Today; dtpFinish.Value = DateTime.Today; diff --git a/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.designer.cs b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.designer.cs index 0def57d..d8d1f32 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/BillDetailsForm.designer.cs @@ -97,7 +97,7 @@ this.Name = "BillDetailsForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Sale Analysis Form"; - this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load); + this.Load += new System.EventHandler(this.BillDetailsForm_Load); ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.Designer.cs b/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.Designer.cs index 34172f4..b353e78 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.Designer.cs @@ -1,6 +1,6 @@ namespace Tanshu.Accounts.PointOfSale { - partial class CashierCheckoutForm + partial class CheckoutForm { /// /// Required designer variable. @@ -130,7 +130,7 @@ this.Name = "CashierCheckoutForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Cashier Checkout Form"; - this.Load += new System.EventHandler(this.CashierCheckoutForm_Load); + this.Load += new System.EventHandler(this.CheckoutForm_Load); ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.cs b/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.cs index 2e4e5ed..bd60e27 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/CheckoutForm.cs @@ -8,17 +8,17 @@ using System.Collections.Generic; namespace Tanshu.Accounts.PointOfSale { - public partial class CashierCheckoutForm : Form + public partial class CheckoutForm : Form { CheckoutBI _coProxy; bool _loading; - public CashierCheckoutForm() + public CheckoutForm() { _loading = true; InitializeComponent(); } - private void CashierCheckoutForm_Load(object sender, EventArgs e) + private void CheckoutForm_Load(object sender, EventArgs e) { dtpStart.Format = DateTimePickerFormat.Custom; dtpStart.CustomFormat = "dd-MMM-yyyy"; diff --git a/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs index 98fcd87..fbbfc26 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.cs @@ -36,7 +36,7 @@ namespace Tanshu.Accounts.PointOfSale ShowStatement(); } - private void Sale_Analysis_Form_Load(object sender, EventArgs e) + private void DiscountReportForm_Load(object sender, EventArgs e) { dtpStart.Value = DateTime.Today; dtpFinish.Value = DateTime.Today; diff --git a/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.designer.cs b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.designer.cs index 3cffd00..8b860a1 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/DiscountReportForm.designer.cs @@ -97,7 +97,7 @@ this.Name = "BillDetailsForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Sale Analysis Form"; - this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load); + this.Load += new System.EventHandler(this.DiscountReportForm_Load); ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs b/Tanshu.Accounts.PointOfSale/Reports/SaleDetailForm.cs similarity index 94% rename from Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs rename to Tanshu.Accounts.PointOfSale/Reports/SaleDetailForm.cs index a7a8249..d22a20e 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/SaleDetailForm.cs @@ -7,10 +7,10 @@ using Tanshu.Accounts.Contracts; namespace Tanshu.Accounts.PointOfSale { - public partial class FrmSaleDetail : Form + public partial class SaleDetailForm : Form { IList _list; - public FrmSaleDetail() + public SaleDetailForm() { InitializeComponent(); dgvSale.AutoGenerateColumns = false; @@ -44,7 +44,7 @@ namespace Tanshu.Accounts.PointOfSale ShowStatement(); } - private void Sale_Analysis_Form_Load(object sender, EventArgs e) + private void SaleDetailForm_Load(object sender, EventArgs e) { dtpStart.Value = DateTime.Today; dtpFinish.Value = DateTime.Today; diff --git a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.designer.cs b/Tanshu.Accounts.PointOfSale/Reports/SaleDetailForm.designer.cs similarity index 98% rename from Tanshu.Accounts.PointOfSale/Reports/SaleDetail.designer.cs rename to Tanshu.Accounts.PointOfSale/Reports/SaleDetailForm.designer.cs index b9649c6..33224ee 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.designer.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/SaleDetailForm.designer.cs @@ -1,6 +1,6 @@ namespace Tanshu.Accounts.PointOfSale { - partial class FrmSaleDetail + partial class SaleDetailForm { /// /// Required designer variable. @@ -174,7 +174,7 @@ this.Name = "FrmSaleDetail"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Sale Detail"; - this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load); + this.Load += new System.EventHandler(this.SaleDetailForm_Load); ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Tanshu.Accounts.PointOfSale/Reports/SaleDetail.resx b/Tanshu.Accounts.PointOfSale/Reports/SaleDetailForm.resx similarity index 100% rename from Tanshu.Accounts.PointOfSale/Reports/SaleDetail.resx rename to Tanshu.Accounts.PointOfSale/Reports/SaleDetailForm.resx diff --git a/Tanshu.Accounts.PointOfSale/Reports/TaxAnalysisForm.cs b/Tanshu.Accounts.PointOfSale/Reports/TaxAnalysisForm.cs index 259cdcc..ff590ee 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/TaxAnalysisForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/TaxAnalysisForm.cs @@ -6,17 +6,17 @@ using Tanshu.Accounts.Contracts; namespace Tanshu.Accounts.PointOfSale { - public partial class frmTaxAnalysisForm : Form + public partial class TaxAnalysisForm : Form { IList _list; bool _loading; - public frmTaxAnalysisForm() + public TaxAnalysisForm() { _loading = true; InitializeComponent(); } - private void SaleAnalysisForm_Load(object sender, EventArgs e) + private void TaxAnalysisForm_Load(object sender, EventArgs e) { dtpStart.Format = DateTimePickerFormat.Custom; dtpStart.CustomFormat = "dd-MMM-yyyy"; diff --git a/Tanshu.Accounts.PointOfSale/Reports/TaxAnalysisForm.designer.cs b/Tanshu.Accounts.PointOfSale/Reports/TaxAnalysisForm.designer.cs index 6a695ac..2fbe086 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/TaxAnalysisForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/TaxAnalysisForm.designer.cs @@ -1,6 +1,6 @@ namespace Tanshu.Accounts.PointOfSale { - partial class frmTaxAnalysisForm + partial class TaxAnalysisForm { /// /// Required designer variable. @@ -110,7 +110,7 @@ this.Name = "frmTaxAnalysisForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Sale Analysis Form"; - this.Load += new System.EventHandler(this.SaleAnalysisForm_Load); + this.Load += new System.EventHandler(this.TaxAnalysisForm_Load); ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs b/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs index 0b6e2ee..56a0571 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.cs @@ -37,7 +37,7 @@ namespace Tanshu.Accounts.PointOfSale ShowStatement(); } - private void Sale_Analysis_Form_Load(object sender, EventArgs e) + private void VoidReprintedForm_Load(object sender, EventArgs e) { dtpStart.Value = DateTime.Today; dtpFinish.Value = DateTime.Today; diff --git a/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.designer.cs b/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.designer.cs index 667ba54..cd0d6a4 100644 --- a/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.designer.cs +++ b/Tanshu.Accounts.PointOfSale/Reports/VoidReprintedForm.designer.cs @@ -97,7 +97,7 @@ this.Name = "BillDetailsForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Sale Analysis Form"; - this.Load += new System.EventHandler(this.Sale_Analysis_Form_Load); + this.Load += new System.EventHandler(this.VoidReprintedForm_Load); ((System.ComponentModel.ISupportInitialize)(this.dgvSale)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj b/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj index bf8a3d9..8638037 100644 --- a/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj +++ b/Tanshu.Accounts.PointOfSale/Tanshu.Accounts.PointOfSale.csproj @@ -111,6 +111,18 @@ ManagementForm.cs + + Form + + + TaxEditForm.cs + + + Form + + + TaxListForm.cs + Form @@ -164,6 +176,12 @@ BillDetailsForm.cs + + Form + + + BeerConsumptionForm.cs + Form @@ -182,11 +200,11 @@ VoidReprintedForm.cs - + Form - - SaleDetail.cs + + SaleDetailForm.cs Form @@ -285,11 +303,11 @@ MainForm.cs - + Form - - AssignRoleGroups.cs + + AssignGroupRoles.cs Form @@ -327,6 +345,14 @@ ManagementForm.cs + + TaxEditForm.cs + Designer + + + TaxListForm.cs + Designer + MachineListForm.cs Designer @@ -364,6 +390,10 @@ BillDetailsForm.cs Designer + + BeerConsumptionForm.cs + Designer + TaxAnalysisForm.cs Designer @@ -376,8 +406,8 @@ VoidReprintedForm.cs Designer - - SaleDetail.cs + + SaleDetailForm.cs Designer @@ -436,8 +466,8 @@ MainForm.cs Designer - - AssignRoleGroups.cs + + AssignGroupRoles.cs Designer diff --git a/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.Designer.cs b/Tanshu.Accounts.PointOfSale/User Management/AssignGroupRoles.Designer.cs similarity index 100% rename from Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.Designer.cs rename to Tanshu.Accounts.PointOfSale/User Management/AssignGroupRoles.Designer.cs diff --git a/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.cs b/Tanshu.Accounts.PointOfSale/User Management/AssignGroupRoles.cs similarity index 100% rename from Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.cs rename to Tanshu.Accounts.PointOfSale/User Management/AssignGroupRoles.cs diff --git a/Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.resx b/Tanshu.Accounts.PointOfSale/User Management/AssignGroupRoles.resx similarity index 100% rename from Tanshu.Accounts.PointOfSale/User Management/AssignRoleGroups.resx rename to Tanshu.Accounts.PointOfSale/User Management/AssignGroupRoles.resx diff --git a/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.Designer.cs b/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.Designer.cs index 42f09c0..97f4645 100644 --- a/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.Designer.cs +++ b/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.Designer.cs @@ -97,7 +97,7 @@ this.Name = "AssignUserGroups"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Assign User Groups"; - this.Load += new System.EventHandler(this.AssignRoles_Load); + this.Load += new System.EventHandler(this.AssignUserGroups_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs b/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs index f99325b..5302a95 100644 --- a/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs +++ b/Tanshu.Accounts.PointOfSale/User Management/AssignUserGroups.cs @@ -20,7 +20,7 @@ namespace Tanshu.Accounts.PointOfSale InitializeComponent(); } - private void AssignRoles_Load(object sender, EventArgs e) + private void AssignUserGroups_Load(object sender, EventArgs e) { FillUsers(); } diff --git a/Tanshu.Accounts.Repository/ManagementBI.cs b/Tanshu.Accounts.Repository/ManagementBI.cs index 120c8ef..c7a890f 100644 --- a/Tanshu.Accounts.Repository/ManagementBI.cs +++ b/Tanshu.Accounts.Repository/ManagementBI.cs @@ -766,7 +766,7 @@ and v.VoucherType = :regular"; //Increase Sales if (inv.Inv.IsHappyHour) IncreaseLiqourUsingHappyHour(s, inv, c); - else if (inv.Inv.Discount > .10M) + else if (inv.Inv.Discount > 0) IncreaseLiqourUsingDiscount(s, inv, c); } @@ -778,6 +778,49 @@ and v.VoucherType = :regular"; } } + public void IncreaseLiqIfLess(IList sale, DateTime startDate, DateTime finishDate) + { + var rand = new Random(); + const string query = @" +select v.Date, i +from Voucher v +inner join v.Kots k +inner join k.Inventories i +where v.Date >= :startDate and v.Date <= :finishDate +and v.VoucherType = :regular"; + var list = _session + .CreateQuery(query) + .SetParameter("startDate", startDate.AddHours(7)) + .SetParameter("finishDate", finishDate.AddDays(1).AddHours(7)) + .SetParameter("regular", VoucherType.Regular) + .List(); + List inventories = new List(); + foreach (var item in Randomize(list)) + { + inventories.Add(new InvDate() + { + Date = ((DateTime)item[0]).AddHours(-7).Date, + Inv = (Inventory)item[1] + }); + } + foreach (var inv in inventories) + { + var s = sale.SingleOrDefault(x => x.Rate == inv.Inv.VatRate); + if (s == null) // Temp ignore and move on + continue; + //throw new ArgumentException("Unknown type of vat rate encountered"); + if (Math.Abs(s.Amount) < 10) + continue; // Close enough for now + if (s.Amount >= 0) + continue; //Move on if we have to reduce and we do not have credit sale margin + if (s.IsLiq) + continue; //Move on if we have to reduce and we do not have credit sale margin + //Increase Sales + IncreaseLiqourUsingPrice(s, inv); + + } + } + private void IncreaseFood(SaleDetailJson s, InvDate inv, CreditJson c) { //Increase Sales @@ -874,6 +917,23 @@ and v.VoucherType = :regular"; s.Amount += inv.Inv.Net; c.Amount += inv.Inv.Amount; } + private void IncreaseLiqourUsingPrice(SaleDetailJson s, InvDate inv) + { + //decimal price; + //if (s.Amount * -1 > inv.Inv.Quantity * inv.Inv.EffectivePrice) + // discount = 0; + //else + // discount = inv.Inv.Discount + Math.Round(s.Amount / (inv.Inv.Quantity * inv.Inv.EffectivePrice), 2); + + //const string query = @"update Inventory i set Discount = :discount where i.InventoryID = :inventoryID"; + //_session.CreateQuery(query) + // .SetParameter("discount", discount) + // .SetParameter("inventoryID", inv.Inv.InventoryID) + // .ExecuteUpdate(); + //inv.Inv.Discount = 1 - (inv.Inv.Discount - discount); + //s.Amount += inv.Inv.Net; + //c.Amount += inv.Inv.Amount; + } private void DecreaseLiqour(Random r, SaleDetailJson s, InvDate inv, CreditJson c) { var min = Math.Max(Convert.ToInt32(inv.Inv.Discount * 100) + 1, 10); diff --git a/Tanshu.Accounts.Repository/ReportsBI.cs b/Tanshu.Accounts.Repository/ReportsBI.cs index b44dfa3..2b74ff0 100644 --- a/Tanshu.Accounts.Repository/ReportsBI.cs +++ b/Tanshu.Accounts.Repository/ReportsBI.cs @@ -12,6 +12,44 @@ namespace Tanshu.Accounts.Repository { public class ReportsBI { + public IList BeerConsumption(DateTime startDate, DateTime finishDate) + { + startDate = startDate.Date.AddHours(6); + finishDate = finishDate.Date.AddDays(1).AddHours(5); + if (finishDate <= startDate) + return new List(); + + using (var session = SessionManager.Session) + { + const string query = @" +select v.Date, p.ProductID, p.Name, Sum(i.Quantity * p.Quantity) +from Voucher v +inner join v.Kots k +inner join k.Inventories i +inner join i.Product p +where v.Date >= :startDate and v.Date <= :finishDate and v.Void = false +and exists (select Voucher from VoucherSettlement vs where vs.Voucher = v +and vs.Settled in (:cash, :creditCard, :billToCompany, :staff, :noCharge)) +group by v.Date, p.ProductID, p.Name +order by v.Date, p.ProductID, p.Name +"; + var list = session + .CreateQuery(query) + .SetParameter("startDate", startDate) + .SetParameter("finishDate", finishDate) + .SetParameter("cash", SettleOption.Cash) + .SetParameter("creditCard", SettleOption.CreditCard) + .SetParameter("billToCompany", SettleOption.BillToCompany) + .SetParameter("staff", SettleOption.Staff) + .SetParameter("noCharge", SettleOption.NoCharge) + .List(); + var outList = new List(); + foreach (var item in list) + if ((decimal)item[3] != 0) + outList.Add(new BeerConsumptionDetail() { Date = (DateTime)item[0], ProductID = (Guid)item[1], Name = (string)item[2], Quantity = (decimal)item[3] }); + return outList; + } + } public IList SaleQuantity(DateTime startDate, DateTime finishDate) { startDate = startDate.Date.AddHours(6);