diff --git a/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoice.cs b/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoice.cs index 17574b0..9b0fe1e 100644 --- a/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoice.cs +++ b/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoice.cs @@ -8,7 +8,7 @@ using static System.ComponentModel.Design.ObjectSelectorEditor; namespace bnhtrade.Core.Data.Database.Account { - internal class PurchaseInvoice : Connection + public class PurchaseInvoice : Connection { private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder; diff --git a/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoiceLine.cs b/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoiceLine.cs index 4e7ee2f..d282818 100644 --- a/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoiceLine.cs +++ b/src/bnhtrade.Core/Data/Database/Account/PurchaseInvoiceLine.cs @@ -44,6 +44,7 @@ namespace bnhtrade.Core.Data.Database.Account InvoiceIdList = new List(); InvoiceLineIdList = new List(); StatusList = new List(); + ItemDescription = new List(); } public Dictionary Read() @@ -104,6 +105,9 @@ namespace bnhtrade.Core.Data.Database.Account sql = sql + sqlBuilder.SqlWhereString; } + // catch taxcode to add in after db read + var lineTaxCodeDict = new Dictionary(); + using (SqlConnection conn = new SqlConnection(SqlConnectionString)) { conn.Open(); @@ -173,14 +177,35 @@ namespace bnhtrade.Core.Data.Database.Account line.RecordModified = recordModified; line.RecordCreated = recordCreated; line.IsActive = isActive; - line.AccountTaxCode = accountTaxCode; returnList.Add(purchaseLineID, line); + + lineTaxCodeDict.Add(purchaseLineID, accountTaxCode); } } } } } + // read tax codes form db and add to return object + var taxcodeList = new Data.Database.Account.ReadTaxCode().GetByTaxCode(lineTaxCodeDict.Values.ToList()); + + foreach (var line in returnList.Values) + { + foreach(var taxcode in taxcodeList) + { + if (taxcode.TaxCode == lineTaxCodeDict[line.PurchaseLineId]) + { + line.AccountTaxCode = taxcode; + break; + } + } + if (line.AccountTaxCode == null) + { + throw new Exception("Fail safe, this really shouodn't happen"); + } + } + + // all done return returnList; } } diff --git a/src/bnhtrade.Core/Logic/Account/PurchaseInvoice.cs b/src/bnhtrade.Core/Logic/Account/PurchaseInvoice.cs index c9b1e13..13c3936 100644 --- a/src/bnhtrade.Core/Logic/Account/PurchaseInvoice.cs +++ b/src/bnhtrade.Core/Logic/Account/PurchaseInvoice.cs @@ -6,16 +6,7 @@ using System.Threading.Tasks; namespace bnhtrade.Core.Logic.Account { - public class PurchaseInvoice + public class PurchaseInvoice : Core.Data.Database.Account.PurchaseInvoice { - public List ReadLineStatusToList() - { - return new Data.Database.Account.PurchaseInvoiceLineStatus().Read().Values.ToList(); - } - - public List GetLineSummary(DateTime maxDate, string lineStatus, List wordSearchList) - { - return new Data.Database.Account.PurchaseInvoiceLineSummary().Read(maxDate,lineStatus, wordSearchList); - } } } diff --git a/src/bnhtrade.Core/Logic/Account/PurchaseInvoiceMisc.cs b/src/bnhtrade.Core/Logic/Account/PurchaseInvoiceMisc.cs new file mode 100644 index 0000000..02330bb --- /dev/null +++ b/src/bnhtrade.Core/Logic/Account/PurchaseInvoiceMisc.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace bnhtrade.Core.Logic.Account +{ + public class PurchaseInvoiceMisc + { + public List ReadLineStatusToList() + { + return new Data.Database.Account.PurchaseInvoiceLineStatus().Read().Values.ToList(); + } + + public List GetLineSummary(DateTime maxDate, string lineStatus, List wordSearchList) + { + return new Data.Database.Account.PurchaseInvoiceLineSummary().Read(maxDate,lineStatus, wordSearchList); + } + } +} diff --git a/src/bnhtrade.Core/Model/Account/PurchaseInvoice.cs b/src/bnhtrade.Core/Model/Account/PurchaseInvoice.cs index b6e3250..6fe3a0f 100644 --- a/src/bnhtrade.Core/Model/Account/PurchaseInvoice.cs +++ b/src/bnhtrade.Core/Model/Account/PurchaseInvoice.cs @@ -9,18 +9,71 @@ namespace bnhtrade.Core.Model.Account public class PurchaseInvoice { public int PurchaseID { get; set; } + public int PurchaseNumber { get; set; } + public int? RecordID { get; set; } + public DateTime PurchaseDate { get; set; } + public Model.Account.Contact Contact { get; set; } + public string SupplierRef { get; set; } + public string AccountCurrency { get; set; } + public string PurchaseChannel { get; set; } + public string CurrencyCode { get; set; } - public decimal PurchaseTotalAmount { get; set; } + + public decimal InvoiceNetAmount + { + get + { + return InvoiceGrossAmount - InvoiceTaxAmount; + } + } + + public decimal InvoiceTaxAmount + { + get + { + decimal amount = 0; + foreach (var item in InvoiceLines) + { + amount = amount + item.LineTotalTax; + } + return amount; + } + } + + public decimal InvoiceGrossAmount + { + get + { + decimal amount = 0; + foreach (var item in InvoiceLines) + { + amount = amount + item.LineTotalGross; + } + return amount; + } + } + + /// + /// Value stored in database to check invoice lines against + /// + public decimal InvoiceGrossAmountCheck { get; set; } + + /// + /// Don't know what this is for, all the amounts in the db are gross, so this is always true + /// public bool VatInclusiveAmounts { get; set; } + public DateTime RecordCreated { get; set; } + public DateTime RecordModified { get; set; } + public bool IsActive { get; set; } public List InvoiceLines { get; set; } @@ -28,24 +81,91 @@ namespace bnhtrade.Core.Model.Account public class Line { public int PurchaseLineId { get; set; } + public int PurchaseId { get; set; } + public string Status { get; set; } + public string SupplierRef { get; set; } + public DateTime? CheckedIn { get; set; } + public string ItemDescription { get; set; } + public int ItemQuantity { get; set; } + + public decimal ItemNet + { + get + { + return ItemGross - ItemTax; + } + } + public decimal ItemGross { get; set; } + public decimal ItemTax { get; set; } + + public decimal ShippingNet + { + get + { + return ShippingGross - ShippingTax; + } + } + public decimal ShippingGross { get; set; } + public decimal ShippingTax { get; set; } + + public decimal OtherNet + { + get + { + return OtherGross - OtherTax; + } + } + public decimal OtherGross { get; set; } + public decimal OtherTax { get; set; } - public string AccountTaxCode { get; set; } + + public decimal LineTotalNet + { + get + { + return (ItemGross + ShippingGross + OtherGross) - (ItemTax + ShippingTax + OtherTax); + } + } + + public decimal LineTotalTax + { + get + { + return ItemTax + ShippingTax + OtherTax; + } + } + + public decimal LineTotalGross + { + get + { + return ItemGross + ShippingGross + OtherGross; + } + } + + public bnhtrade.Core.Model.Account.TaxCodeInfo AccountTaxCode { get; set; } + public int? Tax_AccountTransactionId { get; set; } + public int Net_AccountChartOfId { get; set; } + public int? Net_AccountTransactionId { get; set; } + public DateTime RecordCreated { get; set; } + public DateTime RecordModified { get; set; } + public bool IsActive { get; set; } } } diff --git a/src/bnhtrade.Core/Model/Account/TaxCodeInfo.cs b/src/bnhtrade.Core/Model/Account/TaxCodeInfo.cs index fe57a95..4e3d067 100644 --- a/src/bnhtrade.Core/Model/Account/TaxCodeInfo.cs +++ b/src/bnhtrade.Core/Model/Account/TaxCodeInfo.cs @@ -9,7 +9,7 @@ namespace bnhtrade.Core.Model.Account { public class TaxCodeInfo : IValidatableObject { - public TaxCodeInfo(string taxCodeId, string title, string description, decimal taxRatePercent, bool isMarginSchemeRate, + public TaxCodeInfo(string taxCode, string title, string description, decimal taxRatePercent, bool isMarginSchemeRate, bool isValidOnExpense, bool isValidOnIncome, string taxType, bool isActive) { if (TaxRate < 0) @@ -24,7 +24,7 @@ namespace bnhtrade.Core.Model.Account throw new Exception("Tax rate is >= 100%"); } - TaxCode = taxCodeId; + TaxCode = taxCode; TaxCodeDescription = description; TaxRate = taxRatePercent; IsMarginScheme = isMarginSchemeRate; diff --git a/src/bnhtrade.gui/Forms/Account/PurchaseInvoice.Designer.cs b/src/bnhtrade.gui/Forms/Account/PurchaseInvoice.Designer.cs new file mode 100644 index 0000000..f307d5e --- /dev/null +++ b/src/bnhtrade.gui/Forms/Account/PurchaseInvoice.Designer.cs @@ -0,0 +1,514 @@ +namespace bnhtrade.gui.Forms.Account +{ + partial class PurchaseInvoice + { + /// + /// 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() + { + components = new System.ComponentModel.Container(); + bsInvoice = new BindingSource(components); + textBoxEbayUsername = new TextBox(); + bsContact = new BindingSource(components); + label1 = new Label(); + label2 = new Label(); + textBoxEbayEmail = new TextBox(); + label3 = new Label(); + textBoxPaypalUsername = new TextBox(); + label4 = new Label(); + textBoxPaypalEmail = new TextBox(); + label5 = new Label(); + textBoxUsername = new TextBox(); + labelPurchaseInvoiceNumber = new Label(); + labelSupplierRef = new Label(); + textBox1 = new TextBox(); + dateTimeOrderDate = new DateTimePicker(); + textBoxTotalAmount = new TextBox(); + textBoxTaxAmount = new TextBox(); + textBoxNetAmount = new TextBox(); + label6 = new Label(); + label7 = new Label(); + label8 = new Label(); + label = new Label(); + label11 = new Label(); + dataGridView1 = new DataGridView(); + itemDescriptionDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + statusDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + itemQuantityDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); + PurchaseId = new DataGridViewTextBoxColumn(); + PurchaseLineId = new DataGridViewTextBoxColumn(); + ItemNet = new DataGridViewTextBoxColumn(); + ShippingNet = new DataGridViewTextBoxColumn(); + OtherNet = new DataGridViewTextBoxColumn(); + LineTotalTax = new DataGridViewTextBoxColumn(); + LineTotalGross = new DataGridViewTextBoxColumn(); + bsInvoiceLines = new BindingSource(components); + textBoxOrderChannel = new TextBox(); + tabControl1 = new TabControl(); + tabPageAccountTransactions = new TabPage(); + tabPageNotes = new TabPage(); + ((System.ComponentModel.ISupportInitialize)bsInvoice).BeginInit(); + ((System.ComponentModel.ISupportInitialize)bsContact).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)bsInvoiceLines).BeginInit(); + tabControl1.SuspendLayout(); + SuspendLayout(); + // + // bsInvoice + // + bsInvoice.DataSource = typeof(Core.Model.Account.PurchaseInvoice); + // + // textBoxEbayUsername + // + textBoxEbayUsername.DataBindings.Add(new Binding("Text", bsContact, "ContactEbayName", true)); + textBoxEbayUsername.Location = new Point(118, 83); + textBoxEbayUsername.Name = "textBoxEbayUsername"; + textBoxEbayUsername.Size = new Size(215, 23); + textBoxEbayUsername.TabIndex = 0; + // + // bsContact + // + bsContact.DataSource = typeof(Core.Model.Account.Contact); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(16, 86); + label1.Name = "label1"; + label1.Size = new Size(87, 15); + label1.TabIndex = 1; + label1.Text = "ebay username"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(16, 115); + label2.Name = "label2"; + label2.Size = new Size(64, 15); + label2.TabIndex = 3; + label2.Text = "ebay email"; + // + // textBoxEbayEmail + // + textBoxEbayEmail.DataBindings.Add(new Binding("Text", bsContact, "ContactEbayEmail", true)); + textBoxEbayEmail.Location = new Point(118, 112); + textBoxEbayEmail.Name = "textBoxEbayEmail"; + textBoxEbayEmail.Size = new Size(215, 23); + textBoxEbayEmail.TabIndex = 2; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(16, 144); + label3.Name = "label3"; + label3.Size = new Size(97, 15); + label3.TabIndex = 5; + label3.Text = "paypal username"; + // + // textBoxPaypalUsername + // + textBoxPaypalUsername.DataBindings.Add(new Binding("Text", bsContact, "ContactPaypalName", true)); + textBoxPaypalUsername.Location = new Point(118, 141); + textBoxPaypalUsername.Name = "textBoxPaypalUsername"; + textBoxPaypalUsername.Size = new Size(215, 23); + textBoxPaypalUsername.TabIndex = 4; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(16, 173); + label4.Name = "label4"; + label4.Size = new Size(74, 15); + label4.TabIndex = 7; + label4.Text = "paypal email"; + // + // textBoxPaypalEmail + // + textBoxPaypalEmail.DataBindings.Add(new Binding("Text", bsContact, "ContactPaypalEmail", true)); + textBoxPaypalEmail.Location = new Point(118, 170); + textBoxPaypalEmail.Name = "textBoxPaypalEmail"; + textBoxPaypalEmail.Size = new Size(215, 23); + textBoxPaypalEmail.TabIndex = 6; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(16, 57); + label5.Name = "label5"; + label5.Size = new Size(39, 15); + label5.TabIndex = 9; + label5.Text = "Name"; + // + // textBoxUsername + // + textBoxUsername.DataBindings.Add(new Binding("Text", bsContact, "ContantName", true)); + textBoxUsername.Location = new Point(118, 54); + textBoxUsername.Name = "textBoxUsername"; + textBoxUsername.Size = new Size(215, 23); + textBoxUsername.TabIndex = 8; + // + // labelPurchaseInvoiceNumber + // + labelPurchaseInvoiceNumber.AutoSize = true; + labelPurchaseInvoiceNumber.Font = new Font("Segoe UI", 18F, FontStyle.Regular, GraphicsUnit.Point, 0); + labelPurchaseInvoiceNumber.Location = new Point(12, 9); + labelPurchaseInvoiceNumber.Name = "labelPurchaseInvoiceNumber"; + labelPurchaseInvoiceNumber.Size = new Size(213, 32); + labelPurchaseInvoiceNumber.TabIndex = 10; + labelPurchaseInvoiceNumber.Text = "Purchase Invoice #"; + // + // labelSupplierRef + // + labelSupplierRef.AutoSize = true; + labelSupplierRef.Location = new Point(16, 202); + labelSupplierRef.Name = "labelSupplierRef"; + labelSupplierRef.Size = new Size(73, 15); + labelSupplierRef.TabIndex = 12; + labelSupplierRef.Text = "Supplier Ref."; + // + // textBox1 + // + textBox1.DataBindings.Add(new Binding("Text", bsInvoice, "SupplierRef", true)); + textBox1.Location = new Point(118, 199); + textBox1.Name = "textBox1"; + textBox1.Size = new Size(215, 23); + textBox1.TabIndex = 11; + // + // dateTimeOrderDate + // + dateTimeOrderDate.Anchor = AnchorStyles.Top | AnchorStyles.Right; + dateTimeOrderDate.DataBindings.Add(new Binding("Value", bsInvoice, "PurchaseDate", true, DataSourceUpdateMode.Never)); + dateTimeOrderDate.Location = new Point(915, 51); + dateTimeOrderDate.Name = "dateTimeOrderDate"; + dateTimeOrderDate.Size = new Size(143, 23); + dateTimeOrderDate.TabIndex = 14; + // + // textBoxTotalAmount + // + textBoxTotalAmount.Anchor = AnchorStyles.Top | AnchorStyles.Right; + textBoxTotalAmount.DataBindings.Add(new Binding("Text", bsInvoice, "InvoiceGrossAmount", true)); + textBoxTotalAmount.Location = new Point(915, 167); + textBoxTotalAmount.Name = "textBoxTotalAmount"; + textBoxTotalAmount.Size = new Size(143, 23); + textBoxTotalAmount.TabIndex = 18; + // + // textBoxTaxAmount + // + textBoxTaxAmount.Anchor = AnchorStyles.Top | AnchorStyles.Right; + textBoxTaxAmount.DataBindings.Add(new Binding("Text", bsInvoice, "InvoiceTaxAmount", true)); + textBoxTaxAmount.Location = new Point(915, 138); + textBoxTaxAmount.Name = "textBoxTaxAmount"; + textBoxTaxAmount.Size = new Size(143, 23); + textBoxTaxAmount.TabIndex = 17; + // + // textBoxNetAmount + // + textBoxNetAmount.Anchor = AnchorStyles.Top | AnchorStyles.Right; + textBoxNetAmount.DataBindings.Add(new Binding("Text", bsInvoice, "InvoiceNetAmount", true)); + textBoxNetAmount.Location = new Point(915, 109); + textBoxNetAmount.Name = "textBoxNetAmount"; + textBoxNetAmount.Size = new Size(143, 23); + textBoxNetAmount.TabIndex = 16; + // + // label6 + // + label6.Anchor = AnchorStyles.Top | AnchorStyles.Right; + label6.AutoSize = true; + label6.Location = new Point(824, 83); + label6.Name = "label6"; + label6.Size = new Size(84, 15); + label6.TabIndex = 19; + label6.Text = "Order Channel"; + // + // label7 + // + label7.Anchor = AnchorStyles.Top | AnchorStyles.Right; + label7.AutoSize = true; + label7.Location = new Point(824, 141); + label7.Name = "label7"; + label7.Size = new Size(69, 15); + label7.TabIndex = 20; + label7.Text = "Tax amount"; + // + // label8 + // + label8.Anchor = AnchorStyles.Top | AnchorStyles.Right; + label8.AutoSize = true; + label8.Location = new Point(824, 112); + label8.Name = "label8"; + label8.Size = new Size(71, 15); + label8.TabIndex = 21; + label8.Text = "Net amount"; + // + // label + // + label.Anchor = AnchorStyles.Top | AnchorStyles.Right; + label.AutoSize = true; + label.Location = new Point(824, 57); + label.Name = "label"; + label.Size = new Size(64, 15); + label.TabIndex = 23; + label.Text = "Order Date"; + // + // label11 + // + label11.Anchor = AnchorStyles.Top | AnchorStyles.Right; + label11.AutoSize = true; + label11.Location = new Point(824, 170); + label11.Name = "label11"; + label11.Size = new Size(79, 15); + label11.TabIndex = 24; + label11.Text = "Total Amount"; + // + // dataGridView1 + // + dataGridView1.AllowUserToDeleteRows = false; + dataGridView1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView1.AutoGenerateColumns = false; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Columns.AddRange(new DataGridViewColumn[] { itemDescriptionDataGridViewTextBoxColumn, statusDataGridViewTextBoxColumn, itemQuantityDataGridViewTextBoxColumn, PurchaseId, PurchaseLineId, ItemNet, ShippingNet, OtherNet, LineTotalTax, LineTotalGross }); + dataGridView1.DataSource = bsInvoiceLines; + dataGridView1.Location = new Point(16, 259); + dataGridView1.Name = "dataGridView1"; + dataGridView1.ReadOnly = true; + dataGridView1.RowTemplate.Height = 30; + dataGridView1.Size = new Size(1042, 264); + dataGridView1.TabIndex = 25; + // + // itemDescriptionDataGridViewTextBoxColumn + // + itemDescriptionDataGridViewTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + itemDescriptionDataGridViewTextBoxColumn.DataPropertyName = "ItemDescription"; + itemDescriptionDataGridViewTextBoxColumn.HeaderText = "Description"; + itemDescriptionDataGridViewTextBoxColumn.Name = "itemDescriptionDataGridViewTextBoxColumn"; + itemDescriptionDataGridViewTextBoxColumn.ReadOnly = true; + // + // statusDataGridViewTextBoxColumn + // + statusDataGridViewTextBoxColumn.DataPropertyName = "Status"; + statusDataGridViewTextBoxColumn.HeaderText = "Status"; + statusDataGridViewTextBoxColumn.Name = "statusDataGridViewTextBoxColumn"; + statusDataGridViewTextBoxColumn.ReadOnly = true; + // + // itemQuantityDataGridViewTextBoxColumn + // + itemQuantityDataGridViewTextBoxColumn.DataPropertyName = "ItemQuantity"; + itemQuantityDataGridViewTextBoxColumn.HeaderText = "Qty."; + itemQuantityDataGridViewTextBoxColumn.MinimumWidth = 50; + itemQuantityDataGridViewTextBoxColumn.Name = "itemQuantityDataGridViewTextBoxColumn"; + itemQuantityDataGridViewTextBoxColumn.ReadOnly = true; + itemQuantityDataGridViewTextBoxColumn.Width = 50; + // + // PurchaseId + // + PurchaseId.DataPropertyName = "PurchaseId"; + PurchaseId.HeaderText = "PurchaseId"; + PurchaseId.Name = "PurchaseId"; + PurchaseId.ReadOnly = true; + PurchaseId.Visible = false; + // + // PurchaseLineId + // + PurchaseLineId.DataPropertyName = "PurchaseLineId"; + PurchaseLineId.HeaderText = "PurchaseLineId"; + PurchaseLineId.Name = "PurchaseLineId"; + PurchaseLineId.ReadOnly = true; + PurchaseLineId.Visible = false; + // + // ItemNet + // + ItemNet.DataPropertyName = "ItemNet"; + ItemNet.HeaderText = "Item"; + ItemNet.MinimumWidth = 60; + ItemNet.Name = "ItemNet"; + ItemNet.ReadOnly = true; + ItemNet.Width = 60; + // + // ShippingNet + // + ShippingNet.DataPropertyName = "ShippingNet"; + ShippingNet.HeaderText = "Ship"; + ShippingNet.MinimumWidth = 60; + ShippingNet.Name = "ShippingNet"; + ShippingNet.ReadOnly = true; + ShippingNet.Width = 60; + // + // OtherNet + // + OtherNet.DataPropertyName = "OtherNet"; + OtherNet.HeaderText = "Adjust"; + OtherNet.MinimumWidth = 60; + OtherNet.Name = "OtherNet"; + OtherNet.ReadOnly = true; + OtherNet.Width = 60; + // + // LineTotalTax + // + LineTotalTax.DataPropertyName = "LineTotalTax"; + LineTotalTax.HeaderText = "Tax"; + LineTotalTax.MinimumWidth = 60; + LineTotalTax.Name = "LineTotalTax"; + LineTotalTax.ReadOnly = true; + LineTotalTax.Width = 60; + // + // LineTotalGross + // + LineTotalGross.DataPropertyName = "LineTotalGross"; + LineTotalGross.HeaderText = "Total"; + LineTotalGross.MinimumWidth = 60; + LineTotalGross.Name = "LineTotalGross"; + LineTotalGross.ReadOnly = true; + LineTotalGross.Width = 60; + // + // bsInvoiceLines + // + bsInvoiceLines.DataMember = "InvoiceLines"; + bsInvoiceLines.DataSource = bsInvoice; + // + // textBoxOrderChannel + // + textBoxOrderChannel.Anchor = AnchorStyles.Top | AnchorStyles.Right; + textBoxOrderChannel.DataBindings.Add(new Binding("Text", bsInvoice, "PurchaseChannel", true)); + textBoxOrderChannel.Location = new Point(915, 80); + textBoxOrderChannel.Name = "textBoxOrderChannel"; + textBoxOrderChannel.Size = new Size(143, 23); + textBoxOrderChannel.TabIndex = 26; + // + // tabControl1 + // + tabControl1.Controls.Add(tabPageAccountTransactions); + tabControl1.Controls.Add(tabPageNotes); + tabControl1.Location = new Point(16, 541); + tabControl1.Name = "tabControl1"; + tabControl1.SelectedIndex = 0; + tabControl1.Size = new Size(1042, 197); + tabControl1.TabIndex = 27; + // + // tabPageAccountTransactions + // + tabPageAccountTransactions.Location = new Point(4, 24); + tabPageAccountTransactions.Name = "tabPageAccountTransactions"; + tabPageAccountTransactions.Padding = new Padding(3); + tabPageAccountTransactions.Size = new Size(1034, 169); + tabPageAccountTransactions.TabIndex = 0; + tabPageAccountTransactions.Text = "Account Transactions"; + tabPageAccountTransactions.UseVisualStyleBackColor = true; + // + // tabPageNotes + // + tabPageNotes.Location = new Point(4, 24); + tabPageNotes.Name = "tabPageNotes"; + tabPageNotes.Padding = new Padding(3); + tabPageNotes.Size = new Size(1034, 169); + tabPageNotes.TabIndex = 1; + tabPageNotes.Text = "Notes"; + tabPageNotes.UseVisualStyleBackColor = true; + // + // PurchaseInvoice + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1070, 750); + Controls.Add(tabControl1); + Controls.Add(textBoxOrderChannel); + Controls.Add(dataGridView1); + Controls.Add(label11); + Controls.Add(label); + Controls.Add(label8); + Controls.Add(label7); + Controls.Add(label6); + Controls.Add(textBoxTotalAmount); + Controls.Add(textBoxTaxAmount); + Controls.Add(textBoxNetAmount); + Controls.Add(dateTimeOrderDate); + Controls.Add(labelSupplierRef); + Controls.Add(textBox1); + Controls.Add(labelPurchaseInvoiceNumber); + Controls.Add(label5); + Controls.Add(textBoxUsername); + Controls.Add(label4); + Controls.Add(textBoxPaypalEmail); + Controls.Add(label3); + Controls.Add(textBoxPaypalUsername); + Controls.Add(label2); + Controls.Add(textBoxEbayEmail); + Controls.Add(label1); + Controls.Add(textBoxEbayUsername); + Name = "PurchaseInvoice"; + Text = "PurchaseInvoice"; + Load += PurchaseInvoice_Load; + ((System.ComponentModel.ISupportInitialize)bsInvoice).EndInit(); + ((System.ComponentModel.ISupportInitialize)bsContact).EndInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ((System.ComponentModel.ISupportInitialize)bsInvoiceLines).EndInit(); + tabControl1.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private BindingSource bsInvoice; + private TextBox textBoxEbayUsername; + private Label label1; + private Label label2; + private TextBox textBoxEbayEmail; + private Label label3; + private TextBox textBoxPaypalUsername; + private Label label4; + private TextBox textBoxPaypalEmail; + private Label label5; + private TextBox textBoxUsername; + private Label labelPurchaseInvoiceNumber; + private Label labelSupplierRef; + private TextBox textBox1; + private DateTimePicker dateTimeOrderDate; + private TextBox textBoxTotalAmount; + private TextBox textBoxTaxAmount; + private TextBox textBoxNetAmount; + private Label label6; + private Label label7; + private Label label8; + private Label label; + private Label label11; + private DataGridView dataGridView1; + private BindingSource bsContact; + private BindingSource bsInvoiceLines; + private DataGridViewTextBoxColumn itemDescriptionDataGridViewTextBoxColumn; + private DataGridViewTextBoxColumn statusDataGridViewTextBoxColumn; + private DataGridViewTextBoxColumn itemQuantityDataGridViewTextBoxColumn; + private DataGridViewTextBoxColumn PurchaseId; + private DataGridViewTextBoxColumn PurchaseLineId; + private DataGridViewTextBoxColumn ItemNet; + private DataGridViewTextBoxColumn ShippingNet; + private DataGridViewTextBoxColumn OtherNet; + private DataGridViewTextBoxColumn LineTotalTax; + private DataGridViewTextBoxColumn LineTotalGross; + private TextBox textBoxOrderChannel; + public TabControl tabControl1; + private TabPage tabPageAccountTransactions; + private TabPage tabPageNotes; + } +} \ No newline at end of file diff --git a/src/bnhtrade.gui/Forms/Account/PurchaseInvoice.cs b/src/bnhtrade.gui/Forms/Account/PurchaseInvoice.cs new file mode 100644 index 0000000..e034bb4 --- /dev/null +++ b/src/bnhtrade.gui/Forms/Account/PurchaseInvoice.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace bnhtrade.gui.Forms.Account +{ + public partial class PurchaseInvoice : Form + { + Core.Model.Account.PurchaseInvoice purchaseInvoice; + + public PurchaseInvoice(Core.Model.Account.PurchaseInvoice purchaseInvoice) + { + InitializeComponent(); + this.purchaseInvoice = purchaseInvoice; + } + + private void PurchaseInvoice_Load(object sender, EventArgs e) + { + bsInvoiceLines.DataSource = purchaseInvoice; + bsContact.DataSource = purchaseInvoice.Contact; + bsInvoice.DataSource = purchaseInvoice; + labelPurchaseInvoiceNumber.Text += purchaseInvoice.PurchaseNumber.ToString("D6"); + } + } +} diff --git a/src/bnhtrade.gui/Forms/Account/PurchaseInvoice.resx b/src/bnhtrade.gui/Forms/Account/PurchaseInvoice.resx new file mode 100644 index 0000000..371a720 --- /dev/null +++ b/src/bnhtrade.gui/Forms/Account/PurchaseInvoice.resx @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 149, 21 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + 257, 21 + + \ No newline at end of file diff --git a/src/bnhtrade.gui/Form1.Designer.cs b/src/bnhtrade.gui/Home.Designer.cs similarity index 91% rename from src/bnhtrade.gui/Form1.Designer.cs rename to src/bnhtrade.gui/Home.Designer.cs index 1ad7482..ed278d1 100644 --- a/src/bnhtrade.gui/Form1.Designer.cs +++ b/src/bnhtrade.gui/Home.Designer.cs @@ -1,6 +1,6 @@ namespace bnhtrade.gui { - partial class Form1 + partial class Home { /// /// Required designer variable. @@ -41,7 +41,7 @@ purchaseLineIdDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); lineStatusDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); purchaseIdDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn(); - bindingSource1 = new BindingSource(components); + bsReceivingLines = new BindingSource(components); buttonSearch = new Button(); comboBox1 = new ComboBox(); purchaseLineStatusBindingSource = new BindingSource(components); @@ -51,7 +51,7 @@ tabControl1.SuspendLayout(); Receiving.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); - ((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)bsReceivingLines).BeginInit(); ((System.ComponentModel.ISupportInitialize)purchaseLineStatusBindingSource).BeginInit(); SuspendLayout(); // @@ -64,7 +64,7 @@ tabControl1.Location = new Point(12, 12); tabControl1.Name = "tabControl1"; tabControl1.SelectedIndex = 0; - tabControl1.Size = new Size(1010, 533); + tabControl1.Size = new Size(1022, 533); tabControl1.TabIndex = 0; tabControl1.SelectedIndexChanged += tabControl1_SelectedIndexChanged; // @@ -73,7 +73,7 @@ tabPage1.Location = new Point(4, 24); tabPage1.Name = "tabPage1"; tabPage1.Padding = new Padding(3); - tabPage1.Size = new Size(1002, 505); + tabPage1.Size = new Size(1014, 505); tabPage1.TabIndex = 0; tabPage1.Text = "Home"; tabPage1.UseVisualStyleBackColor = true; @@ -84,7 +84,7 @@ tabPage2.Location = new Point(4, 24); tabPage2.Name = "tabPage2"; tabPage2.Padding = new Padding(3); - tabPage2.Size = new Size(1002, 505); + tabPage2.Size = new Size(1014, 505); tabPage2.TabIndex = 1; tabPage2.Text = "FBA Shipments"; tabPage2.UseVisualStyleBackColor = true; @@ -101,7 +101,7 @@ Receiving.Location = new Point(4, 24); Receiving.Name = "Receiving"; Receiving.Padding = new Padding(3); - Receiving.Size = new Size(1002, 505); + Receiving.Size = new Size(1014, 505); Receiving.TabIndex = 2; Receiving.Text = "Receiving"; Receiving.UseVisualStyleBackColor = true; @@ -111,7 +111,7 @@ // labelDataGridCount.Anchor = AnchorStyles.Right; labelDataGridCount.ImageAlign = ContentAlignment.MiddleRight; - labelDataGridCount.Location = new Point(845, 70); + labelDataGridCount.Location = new Point(857, 70); labelDataGridCount.Name = "labelDataGridCount"; labelDataGridCount.RightToLeft = RightToLeft.Yes; labelDataGridCount.Size = new Size(129, 21); @@ -125,11 +125,14 @@ dataGridView1.AutoGenerateColumns = false; dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView1.Columns.AddRange(new DataGridViewColumn[] { purchaseNumberDataGridViewTextBoxColumn, purchaseDateDataGridViewTextBoxColumn, itemDescriptionDataGridViewTextBoxColumn, purchaseLineIdDataGridViewTextBoxColumn, lineStatusDataGridViewTextBoxColumn, purchaseIdDataGridViewTextBoxColumn }); - dataGridView1.DataSource = bindingSource1; + dataGridView1.DataSource = bsReceivingLines; dataGridView1.Location = new Point(31, 94); + dataGridView1.MultiSelect = false; dataGridView1.Name = "dataGridView1"; - dataGridView1.Size = new Size(943, 396); + dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView1.Size = new Size(955, 396); dataGridView1.TabIndex = 5; + dataGridView1.DoubleClick += dataGridView1_DoubleClick; // // purchaseNumberDataGridViewTextBoxColumn // @@ -168,9 +171,9 @@ purchaseIdDataGridViewTextBoxColumn.HeaderText = "PurchaseId"; purchaseIdDataGridViewTextBoxColumn.Name = "purchaseIdDataGridViewTextBoxColumn"; // - // bindingSource1 + // bsReceivingLines // - bindingSource1.DataSource = typeof(Core.Model.Account.PurchaseInvoiceLineSummary); + bsReceivingLines.DataSource = typeof(Core.Model.Account.PurchaseInvoiceLineSummary); // // buttonSearch // @@ -224,20 +227,20 @@ textboxOrderSearch.TabIndex = 0; textboxOrderSearch.KeyPress += textboxOrderSearch_KeyPress; // - // Form1 + // Home // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1034, 557); + ClientSize = new Size(1046, 557); Controls.Add(tabControl1); - Name = "Form1"; + Name = "Home"; Text = "Form1"; Load += Form1_Load; tabControl1.ResumeLayout(false); Receiving.ResumeLayout(false); Receiving.PerformLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); - ((System.ComponentModel.ISupportInitialize)bindingSource1).EndInit(); + ((System.ComponentModel.ISupportInitialize)bsReceivingLines).EndInit(); ((System.ComponentModel.ISupportInitialize)purchaseLineStatusBindingSource).EndInit(); ResumeLayout(false); } @@ -255,7 +258,7 @@ private BindingSource purchaseLineStatusBindingSource; private Button buttonSearch; private DataGridView dataGridView1; - private BindingSource bindingSource1; + private BindingSource bsReceivingLines; private DataGridViewTextBoxColumn purchaseNumberDataGridViewTextBoxColumn; private DataGridViewTextBoxColumn purchaseDateDataGridViewTextBoxColumn; private DataGridViewTextBoxColumn itemDescriptionDataGridViewTextBoxColumn; diff --git a/src/bnhtrade.gui/Form1.cs b/src/bnhtrade.gui/Home.cs similarity index 70% rename from src/bnhtrade.gui/Form1.cs rename to src/bnhtrade.gui/Home.cs index 201889c..39117f8 100644 --- a/src/bnhtrade.gui/Form1.cs +++ b/src/bnhtrade.gui/Home.cs @@ -1,11 +1,13 @@ +using bnhtrade.gui.Forms.Account; + namespace bnhtrade.gui { - public partial class Form1 : Form + public partial class Home : Form { bool initTabReceiving = false; - public Form1() + public Home() { InitializeComponent(); } @@ -34,7 +36,7 @@ namespace bnhtrade.gui private void InitialiseTabReceiving() { Cursor.Current = Cursors.WaitCursor; - purchaseLineStatusBindingSource.DataSource = new Core.Logic.Account.PurchaseInvoice().ReadLineStatusToList(); + purchaseLineStatusBindingSource.DataSource = new Core.Logic.Account.PurchaseInvoiceMisc().ReadLineStatusToList(); comboBox1.SelectedIndex = 3; ListBoxQuery(); initTabReceiving = true; @@ -77,12 +79,12 @@ namespace bnhtrade.gui comboBox = comboBox1.Text; } - bindingSource1.DataSource = new Core.Logic.Account.PurchaseInvoice().GetLineSummary( + bsReceivingLines.DataSource = new Core.Logic.Account.PurchaseInvoiceMisc().GetLineSummary( dateTimeOrderSearch.Value , comboBox , searchList); - labelDataGridCount.Text = bindingSource1.Count.ToString(); + labelDataGridCount.Text = bsReceivingLines.Count.ToString(); } private void bindingSource1_CurrentChanged(object sender, EventArgs e) @@ -95,5 +97,18 @@ namespace bnhtrade.gui ListBoxQuery(); textboxOrderSearch.Select(); } + + private void dataGridView1_DoubleClick(object sender, EventArgs e) + { + var row = dataGridView1.CurrentCell.RowIndex; + var lineSummary = (bnhtrade.Core.Model.Account.PurchaseInvoiceLineSummary)bsReceivingLines[row]; + int purchaseId = lineSummary.PurchaseId; + var dbRead = new Core.Logic.Account.PurchaseInvoice(); + dbRead.PurchaseInvoiceIdList = new List { purchaseId }; + var dbresult = dbRead.Read(); + var purchaseInvoice = dbresult[purchaseId]; + var form = new PurchaseInvoice(purchaseInvoice); + form.Show(); + } } } diff --git a/src/bnhtrade.gui/Form1.resx b/src/bnhtrade.gui/Home.resx similarity index 97% rename from src/bnhtrade.gui/Form1.resx rename to src/bnhtrade.gui/Home.resx index 3431ac8..70d97fa 100644 --- a/src/bnhtrade.gui/Form1.resx +++ b/src/bnhtrade.gui/Home.resx @@ -117,7 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 250, 17 diff --git a/src/bnhtrade.gui/Program.cs b/src/bnhtrade.gui/Program.cs index 51d9543..ebc23e5 100644 --- a/src/bnhtrade.gui/Program.cs +++ b/src/bnhtrade.gui/Program.cs @@ -11,7 +11,7 @@ namespace bnhtrade.gui // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new Home()); } } } \ No newline at end of file diff --git a/src/bnhtrade.gui/Properties/DataSources/bnhtrade.Core.Model.Account.Contact.datasource b/src/bnhtrade.gui/Properties/DataSources/bnhtrade.Core.Model.Account.Contact.datasource new file mode 100644 index 0000000..f0dd868 --- /dev/null +++ b/src/bnhtrade.gui/Properties/DataSources/bnhtrade.Core.Model.Account.Contact.datasource @@ -0,0 +1,10 @@ + + + + bnhtrade.Core.Model.Account.Contact, bnhtrade.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file