INTRODUCTION
Here I will discuss a programming technique I use in the C# platform to perform a double entry posting to a general ledger in a Chart Of Accounts application I made for a long time customer. This is actually the first of two methods used in this program. I will discuss the second method in a later article.
THE FIRST STEP
Initially, we need to key in the total amount to process for the double entry posting operation. You enter this amount in either the “Total Debit Amount” or “Total Credit Amount” textbox in the screen below (Figures 1 & 2). The transaction type and transaction description also need to be entered. Next, click the corresponding button for either the “Total Debit Amount For Double Entry Posting” or “Total Credit Amount For Double Entry Posting”. One thing to note – this step is not yet performing the double entry posting - we are merely setting up for doing that next.
Figure 1: Entry
Figure 2: Entry Posting
Next, I present the underlying C# code that facilitates this preliminary step. For the button, “Total Debit Amount For Double Entry Posting”:
- long autonum_var;
- long[] convert_to_number = new long[GLAMOUNTS];
- string transaction_str, debit_str, stringAutoNumber;
- char[] totalamount = new char[GLAMOUNTS];
-
-
- if (textBox_transactiondescription.Text.Length > 0 && textBox_totaldebitamount.Text.Length > 0 && comboBox_transactiontype.Text.Length > 0)
- {
-
-
- result = MessageBox.Show("Do you want to proceed with this double entry posting transaction?", "Verification Mode", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
-
- if (result == DialogResult.Yes)
- {
-
- Cursor.Current = new Cursor(currdir + "Busy_l.cur");
-
-
-
- DateTime saveNow = DateTime.Now;
- dateString = saveNow.ToString(datePatt);
-
-
- transaction_str = textBox_transactiondescription.Text;
- debit_str = textBox_totaldebitamount.Text;
- remaining_offsetting_balance_str = textBox_totaldebitamount.Text;
- textBox_remainingbalanceoftotal.Text = textBox_totaldebitamount.Text;
-
-
-
-
- listBox_chartofaccountslisting.BackColor = Color.MediumPurple;
-
- button_totaldebitamountfordoubleentryposting.Enabled = false;
- button_totalcreditamountfordoubleentryposting.Enabled = false;
-
-
- MakeListBoxSandyBrown = 0;
- MakeListBoxMediumPurple = 1;
- MakeListBoxTomato = 0;
-
- ApplyOffSettingDebits = 1;
- ApplyOffSettingCredits = 0;
-
-
-
-
-
- StreamReader streamobj3 = new StreamReader(currdir + "autonumber.txt");
- streamobj3.BaseStream.Seek(0, SeekOrigin.Begin);
- stringAutoNumber = streamobj3.ReadLine();
- streamobj3.Close();
-
- for (a = 0; a < 3; a++)
- {
- convert_to_number[a] = 0;
- if (stringAutoNumber.Substring(a, 1) == "0") convert_to_number[a] = 0;
- if (stringAutoNumber.Substring(a, 1) == "1") convert_to_number[a] = 1;
- if (stringAutoNumber.Substring(a, 1) == "2") convert_to_number[a] = 2;
- if (stringAutoNumber.Substring(a, 1) == "3") convert_to_number[a] = 3;
- if (stringAutoNumber.Substring(a, 1) == "4") convert_to_number[a] = 4;
- if (stringAutoNumber.Substring(a, 1) == "5") convert_to_number[a] = 5;
- if (stringAutoNumber.Substring(a, 1) == "6") convert_to_number[a] = 6;
- if (stringAutoNumber.Substring(a, 1) == "7") convert_to_number[a] = 7;
- if (stringAutoNumber.Substring(a, 1) == "8") convert_to_number[a] = 8;
- if (stringAutoNumber.Substring(a, 1) == "9") convert_to_number[a] = 9;
- }
- autonum_var = ((convert_to_number[0] * 100) + (convert_to_number[1] * 10) + (convert_to_number[2] * 1));
- autonum_var++;
- if (autonum_var > 999) {
- autonum_var = 0;
- }
-
- for (a = 0; a < 3; a++) charVal_auto_number[a] = (char)48;
- countervar = 2;
- do
- {
- longresult = Math.DivRem(autonum_var, 10, out long2);
- autonum_var = longresult;
- if (long2 == 0) charVal_auto_number[countervar] = (char)48;
- if (long2 == 1) charVal_auto_number[countervar] = (char)49;
- if (long2 == 2) charVal_auto_number[countervar] = (char)50;
- if (long2 == 3) charVal_auto_number[countervar] = (char)51;
- if (long2 == 4) charVal_auto_number[countervar] = (char)52;
- if (long2 == 5) charVal_auto_number[countervar] = (char)53;
- if (long2 == 6) charVal_auto_number[countervar] = (char)54;
- if (long2 == 7) charVal_auto_number[countervar] = (char)55;
- if (long2 == 8) charVal_auto_number[countervar] = (char)56;
- if (long2 == 9) charVal_auto_number[countervar] = (char)57;
- countervar--;
- } while (autonum_var > 0);
-
- if (File.Exists(currdir + "autonumber.txt"))
- {
- File.Delete(currdir + "autonumber.txt");
- }
-
- FileStream fstreamobj2 = new FileStream(currdir + "autonumber.txt", FileMode.Create);
- StreamWriter writerobj2 = new StreamWriter(fstreamobj2);
- writerobj2.WriteLine(charVal_auto_number);
- writerobj2.Close();
- fstreamobj2.Close();
-
-
-
- this.textBox_totaldebitamount.Text = " 0.00";
-
-
- Cursor.Current = Cursors.Default;
-
-
- }
-
-
- }
- else
- {
-
- MessageBox.Show("The debit and/or transaction description and/or transaction type field(s) may be empty...please fill them in and retry...", "Error Mode");
-
- }
Now for the button, “Total Credit Amount For Double Entry Posting”: - long autonum_var;
- long[] convert_to_number = new long[GLAMOUNTS];
- string transaction_str, credit_str, stringAutoNumber;
- char[] totalamount = new char[GLAMOUNTS];
-
-
- if (textBox_transactiondescription.Text.Length > 0 && textBox_totalcreditamount.Text.Length > 0 && comboBox_transactiontype.Text.Length > 0)
- {
-
-
- result = MessageBox.Show("Do you want to proceed with this double entry posting transaction?", "Verification Mode", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
-
- if (result == DialogResult.Yes)
- {
-
- Cursor.Current = new Cursor(currdir + "Busy_l.cur");
-
-
-
- DateTime saveNow = DateTime.Now;
- dateString = saveNow.ToString(datePatt);
-
-
- transaction_str = textBox_transactiondescription.Text;
- credit_str = textBox_totalcreditamount.Text;
- remaining_offsetting_balance_str = textBox_totalcreditamount.Text;
- textBox_remainingbalanceoftotal.Text = textBox_totalcreditamount.Text;
-
-
-
-
- listBox_chartofaccountslisting.BackColor = Color.MediumPurple;
-
- button_totaldebitamountfordoubleentryposting.Enabled = false;
- button_totalcreditamountfordoubleentryposting.Enabled = false;
-
-
- MakeListBoxSandyBrown = 0;
- MakeListBoxMediumPurple = 1;
- MakeListBoxTomato = 0;
-
- ApplyOffSettingDebits = 0;
- ApplyOffSettingCredits = 1;
-
-
-
-
-
- StreamReader streamobj3 = new StreamReader(currdir + "autonumber.txt");
- streamobj3.BaseStream.Seek(0, SeekOrigin.Begin);
- stringAutoNumber = streamobj3.ReadLine();
- streamobj3.Close();
-
- for (a = 0; a < 3; a++)
- {
- convert_to_number[a] = 0;
- if (stringAutoNumber.Substring(a, 1) == "0") convert_to_number[a] = 0;
- if (stringAutoNumber.Substring(a, 1) == "1") convert_to_number[a] = 1;
- if (stringAutoNumber.Substring(a, 1) == "2") convert_to_number[a] = 2;
- if (stringAutoNumber.Substring(a, 1) == "3") convert_to_number[a] = 3;
- if (stringAutoNumber.Substring(a, 1) == "4") convert_to_number[a] = 4;
- if (stringAutoNumber.Substring(a, 1) == "5") convert_to_number[a] = 5;
- if (stringAutoNumber.Substring(a, 1) == "6") convert_to_number[a] = 6;
- if (stringAutoNumber.Substring(a, 1) == "7") convert_to_number[a] = 7;
- if (stringAutoNumber.Substring(a, 1) == "8") convert_to_number[a] = 8;
- if (stringAutoNumber.Substring(a, 1) == "9") convert_to_number[a] = 9;
- }
- autonum_var = ((convert_to_number[0] * 100) + (convert_to_number[1] * 10) + (convert_to_number[2] * 1));
- autonum_var++;
- if (autonum_var > 999)
- {
- autonum_var = 0;
- }
-
- for (a = 0; a < 3; a++) charVal_auto_number[a] = (char)48;
- countervar = 2;
- do
- {
- longresult = Math.DivRem(autonum_var, 10, out long2);
- autonum_var = longresult;
- if (long2 == 0) charVal_auto_number[countervar] = (char)48;
- if (long2 == 1) charVal_auto_number[countervar] = (char)49;
- if (long2 == 2) charVal_auto_number[countervar] = (char)50;
- if (long2 == 3) charVal_auto_number[countervar] = (char)51;
- if (long2 == 4) charVal_auto_number[countervar] = (char)52;
- if (long2 == 5) charVal_auto_number[countervar] = (char)53;
- if (long2 == 6) charVal_auto_number[countervar] = (char)54;
- if (long2 == 7) charVal_auto_number[countervar] = (char)55;
- if (long2 == 8) charVal_auto_number[countervar] = (char)56;
- if (long2 == 9) charVal_auto_number[countervar] = (char)57;
- countervar--;
- } while (autonum_var > 0);
-
- if (File.Exists(currdir + "autonumber.txt"))
- {
- File.Delete(currdir + "autonumber.txt");
- }
-
- FileStream fstreamobj2 = new FileStream(currdir + "autonumber.txt", FileMode.Create);
- StreamWriter writerobj2 = new StreamWriter(fstreamobj2);
- writerobj2.WriteLine(charVal_auto_number);
- writerobj2.Close();
- fstreamobj2.Close();
-
-
-
- this.textBox_totalcreditamount.Text = " 0.00";
-
-
- Cursor.Current = Cursors.Default;
-
-
- }
-
-
- }
- else
- {
-
- MessageBox.Show("The credit and/or transaction description and/or transaction type field(s) may be empty...please fill them in and retry...", "Error Mode");
-
- }
NOW FOR THE POSTING CODE
After keying in a debit or credit amount for the initial posting operation and clicking the corresponding button beneath its textbox, we are now ready to proceed with the double entry posting operation. Notice that the color for the listing for Chart of Accounts has changed from “sandy brown” to “medium purple” (Figures 3 & 4). This is a sort of heads up I devised to alert the operator to the fact that we are now in the initial posting phase of the double entry posting operation.
Figure 3: Posting
Figure 4: purple
Notice the amount that was originally entered for the total debit or credit amount is now in the textbox for the remaining balance. Just below that is a textbox for the amount to be applied. The operator may enter any number of amounts in this textbox as long as the cumulative total does not exceed the original remaining balance amount. In fact, the operator cannot exit this mode and proceed to the next step until the full amount to be posted has been reduced to zero by successive posting operations. To post an amount after keying in how much of the remaining balance you want to apply, just double click on a selected ledger in the “medium purple” colored Chart of Accounts listing.
After the remaining balance of the initial posting phase has been reduced to zero, we will enter the offsetting posting phase as evidenced by the “medium purple” color of the Chart of Accounts listing turning to “tomato color” (Figures 5 & 6). Mechanically, this functions identically to the initial posting phase.
Figure 5: medium Purple
Figure 6: Tomato
After the offsetting posting phase is complete, the listing color for Chart of Accounts simply reverts back to “sandy brown” color to signal it is ready for another double entry posting operation. Here is the code listing that facilitates the posting operation:
- int amount_flag;
- long runningbalance_to_chararray, debit_var, credit_var, runningbalance;
- long remaining_balance, post_amount, new_remaining_balance,choose_record_datafile_offset;
- long[] convert_to_number = new long[GLAMOUNTS];
- string transaction_str, debit_str, credit_str, remaining_balance_str, post_amount_str;
- string listBox1_String, stringBalance;
- char[] totalamount = new char[GLAMOUNTS];
- char[] charVal_date, charVal_tranaction, charVal_debit, charVal_credit;
-
- if (listBox_chartofaccountslisting.SelectedIndex != -1)
- {
-
-
- listBox1_String = listBox_chartofaccountslisting.Text;
-
-
- for (a = 0; a < 5; a++)
- {
- convert_to_number[a] = 0;
- if (listBox1_String.Substring((listBox1_String.Length - 5) + a, 1) == "0") convert_to_number[a] = 0;
- if (listBox1_String.Substring((listBox1_String.Length - 5) + a, 1) == "1") convert_to_number[a] = 1;
- if (listBox1_String.Substring((listBox1_String.Length - 5) + a, 1) == "2") convert_to_number[a] = 2;
- if (listBox1_String.Substring((listBox1_String.Length - 5) + a, 1) == "3") convert_to_number[a] = 3;
- if (listBox1_String.Substring((listBox1_String.Length - 5) + a, 1) == "4") convert_to_number[a] = 4;
- if (listBox1_String.Substring((listBox1_String.Length - 5) + a, 1) == "5") convert_to_number[a] = 5;
- if (listBox1_String.Substring((listBox1_String.Length - 5) + a, 1) == "6") convert_to_number[a] = 6;
- if (listBox1_String.Substring((listBox1_String.Length - 5) + a, 1) == "7") convert_to_number[a] = 7;
- if (listBox1_String.Substring((listBox1_String.Length - 5) + a, 1) == "8") convert_to_number[a] = 8;
- if (listBox1_String.Substring((listBox1_String.Length - 5) + a, 1) == "9") convert_to_number[a] = 9;
- }
- choose_record_datafile_offset = ((convert_to_number[0] * 10000) + (convert_to_number[1] * 1000) + (convert_to_number[2] * 100) + (convert_to_number[3] * 10) + (convert_to_number[4] * 1)) * GLMASTERLEN;
-
- if (listBox1_String.Substring(0, 4) == "GL A") MessageBox.Show("Invalid selection...", "Error Mode");
- if (listBox1_String.Substring(0, 4) != "GL A")
- {
-
-
-
-
- StreamReader streamobj2 = new StreamReader(currdir + "mastcoa.txt");
- streamobj2.BaseStream.Seek(choose_record_datafile_offset, SeekOrigin.Begin);
- stringVal = streamobj2.ReadLine();
- streamobj2.Close();
-
- strfile = stringVal.Substring(45, 8);
- strfile = strfile + ".txt";
-
-
-
-
- if (MakeListBoxSandyBrown == 1)
- {
-
- this.textBox2.Text = stringVal.Substring(0, 41);
- this.textBox3.Text = stringVal.Substring(41, 4);
-
- listBox2.Items.Clear();
- listBox2.Items.Add("Date " + "\t" + "Txn" + "\t" + "TYPE" + "\t" + "Transaction Description " + "\t" + "Debit " + "\t" + "Credit " + "\t" + "BALANCE ");
-
- FileInfo datafileinfo = new FileInfo(currdir + strfile);
- sizeofdatafile = datafileinfo.Length;
- StreamReader streamobj = new StreamReader(currdir + strfile);
- streamobj.BaseStream.Seek(0, SeekOrigin.Begin);
-
- runningbalance = 0;
- datafileoffset = 0;
- do
- {
-
- stringVal = streamobj.ReadLine();
-
- for (a = 0; a < GLAMOUNTS; a++)
- {
- convert_to_number[a] = 0;
- if (stringVal.Substring(50 + a, 1) == "0") convert_to_number[a] = 0;
- if (stringVal.Substring(50 + a, 1) == "1") convert_to_number[a] = 1;
- if (stringVal.Substring(50 + a, 1) == "2") convert_to_number[a] = 2;
- if (stringVal.Substring(50 + a, 1) == "3") convert_to_number[a] = 3;
- if (stringVal.Substring(50 + a, 1) == "4") convert_to_number[a] = 4;
- if (stringVal.Substring(50 + a, 1) == "5") convert_to_number[a] = 5;
- if (stringVal.Substring(50 + a, 1) == "6") convert_to_number[a] = 6;
- if (stringVal.Substring(50 + a, 1) == "7") convert_to_number[a] = 7;
- if (stringVal.Substring(50 + a, 1) == "8") convert_to_number[a] = 8;
- if (stringVal.Substring(50 + a, 1) == "9") convert_to_number[a] = 9;
- }
- debit_var = ((convert_to_number[0] * 100000000) + (convert_to_number[1] * 10000000) + (convert_to_number[2] * 1000000) + (convert_to_number[3] * 100000) + (convert_to_number[4] * 10000) + (convert_to_number[5] * 1000) + (convert_to_number[6] * 100) + (convert_to_number[8] * 10) + (convert_to_number[9] * 1));
-
- for (a = 0; a < GLAMOUNTS; a++)
- {
- convert_to_number[a] = 0;
- if (stringVal.Substring(60 + a, 1) == "0") convert_to_number[a] = 0;
- if (stringVal.Substring(60 + a, 1) == "1") convert_to_number[a] = 1;
- if (stringVal.Substring(60 + a, 1) == "2") convert_to_number[a] = 2;
- if (stringVal.Substring(60 + a, 1) == "3") convert_to_number[a] = 3;
- if (stringVal.Substring(60 + a, 1) == "4") convert_to_number[a] = 4;
- if (stringVal.Substring(60 + a, 1) == "5") convert_to_number[a] = 5;
- if (stringVal.Substring(60 + a, 1) == "6") convert_to_number[a] = 6;
- if (stringVal.Substring(60 + a, 1) == "7") convert_to_number[a] = 7;
- if (stringVal.Substring(60 + a, 1) == "8") convert_to_number[a] = 8;
- if (stringVal.Substring(60 + a, 1) == "9") convert_to_number[a] = 9;
- }
- credit_var = ((convert_to_number[0] * 100000000) + (convert_to_number[1] * 10000000) + (convert_to_number[2] * 1000000) + (convert_to_number[3] * 100000) + (convert_to_number[4] * 10000) + (convert_to_number[5] * 1000) + (convert_to_number[6] * 100) + (convert_to_number[8] * 10) + (convert_to_number[9] * 1));
-
- runningbalance = runningbalance - debit_var + credit_var;
-
- for (a = 0; a < 10; a++) totalamount[a] = (char)32;
- totalamount[6] = (char)48;
- totalamount[7] = (char)46;
- totalamount[8] = (char)48;
- totalamount[9] = (char)48;
- runningbalance_to_chararray = runningbalance;
- if (runningbalance < 0)
- {
- runningbalance_to_chararray = 0 - runningbalance;
- }
- countervar = 9;
- do
- {
- longresult = Math.DivRem(runningbalance_to_chararray, 10, out long2);
- runningbalance_to_chararray = longresult;
- if (long2 == 0) totalamount[countervar] = (char)48;
- if (long2 == 1) totalamount[countervar] = (char)49;
- if (long2 == 2) totalamount[countervar] = (char)50;
- if (long2 == 3) totalamount[countervar] = (char)51;
- if (long2 == 4) totalamount[countervar] = (char)52;
- if (long2 == 5) totalamount[countervar] = (char)53;
- if (long2 == 6) totalamount[countervar] = (char)54;
- if (long2 == 7) totalamount[countervar] = (char)55;
- if (long2 == 8) totalamount[countervar] = (char)56;
- if (long2 == 9) totalamount[countervar] = (char)57;
- countervar--;
- if (countervar == 7)
- {
- totalamount[countervar] = (char)46;
- countervar--;
- }
- } while (runningbalance_to_chararray > 0);
-
- stringBalance = new string(totalamount);
- if (runningbalance < 0)
- {
- stringBalance = "- " + stringBalance;
- }
- else
- {
- stringBalance = "+ " + stringBalance;
- }
-
- listBox2.Items.Add(stringVal.Substring(0, 8) + "\t " + stringVal.Substring(70, 3) + "\t " + stringVal.Substring(8, 2) + "\t" + stringVal.Substring(10, 28) + "\t" + stringVal.Substring(50, 10) + "\t" + stringVal.Substring(60, 10) + "\t" + stringBalance);
-
- datafileoffset = datafileoffset + GLDETAILEN;
-
- } while (datafileoffset < sizeofdatafile);
- streamobj.Close();
-
- this.textBox_totaldebitamount.Text = " 0.00";
- this.textBox_totalcreditamount.Text = " 0.00";
- this.textBox_transactiondescription.Text = "";
-
- Cursor.Current = Cursors.Default;
-
- }
-
-
-
-
-
- if (MakeListBoxMediumPurple == 1 || MakeListBoxTomato == 1)
- {
-
-
-
-
- DateTime saveNow = DateTime.Now;
- dateString = saveNow.ToString(datePatt);
-
- remaining_balance_str = textBox_remainingbalanceoftotal.Text;
- post_amount_str = textBox_enteramounttobeapplied.Text;
-
-
- for (a = 0; a < GLAMOUNTS; a++)
- {
- convert_to_number[a] = 0;
- if (remaining_balance_str.Substring(a, 1) == "0") convert_to_number[a] = 0;
- if (remaining_balance_str.Substring(a, 1) == "1") convert_to_number[a] = 1;
- if (remaining_balance_str.Substring(a, 1) == "2") convert_to_number[a] = 2;
- if (remaining_balance_str.Substring(a, 1) == "3") convert_to_number[a] = 3;
- if (remaining_balance_str.Substring(a, 1) == "4") convert_to_number[a] = 4;
- if (remaining_balance_str.Substring(a, 1) == "5") convert_to_number[a] = 5;
- if (remaining_balance_str.Substring(a, 1) == "6") convert_to_number[a] = 6;
- if (remaining_balance_str.Substring(a, 1) == "7") convert_to_number[a] = 7;
- if (remaining_balance_str.Substring(a, 1) == "8") convert_to_number[a] = 8;
- if (remaining_balance_str.Substring(a, 1) == "9") convert_to_number[a] = 9;
- }
- remaining_balance = ((convert_to_number[0] * 100000000) + (convert_to_number[1] * 10000000) + (convert_to_number[2] * 1000000) + (convert_to_number[3] * 100000) + (convert_to_number[4] * 10000) + (convert_to_number[5] * 1000) + (convert_to_number[6] * 100) + (convert_to_number[8] * 10) + (convert_to_number[9] * 1));
-
- for (a = 0; a < GLAMOUNTS; a++)
- {
- convert_to_number[a] = 0;
- if (post_amount_str.Substring(a, 1) == "0") convert_to_number[a] = 0;
- if (post_amount_str.Substring(a, 1) == "1") convert_to_number[a] = 1;
- if (post_amount_str.Substring(a, 1) == "2") convert_to_number[a] = 2;
- if (post_amount_str.Substring(a, 1) == "3") convert_to_number[a] = 3;
- if (post_amount_str.Substring(a, 1) == "4") convert_to_number[a] = 4;
- if (post_amount_str.Substring(a, 1) == "5") convert_to_number[a] = 5;
- if (post_amount_str.Substring(a, 1) == "6") convert_to_number[a] = 6;
- if (post_amount_str.Substring(a, 1) == "7") convert_to_number[a] = 7;
- if (post_amount_str.Substring(a, 1) == "8") convert_to_number[a] = 8;
- if (post_amount_str.Substring(a, 1) == "9") convert_to_number[a] = 9;
- }
- post_amount = ((convert_to_number[0] * 100000000) + (convert_to_number[1] * 10000000) + (convert_to_number[2] * 1000000) + (convert_to_number[3] * 100000) + (convert_to_number[4] * 10000) + (convert_to_number[5] * 1000) + (convert_to_number[6] * 100) + (convert_to_number[8] * 10) + (convert_to_number[9] * 1));
-
-
-
-
- if (post_amount <= remaining_balance)
- {
-
-
-
- if (MakeListBoxTomato == 1)
- {
- result = MessageBox.Show("Do you want to process this offsetting general ledger transaction?", "Verification Mode", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
- }
- else
- {
- result = MessageBox.Show("Do you want to process this initial general ledger transaction?", "Verification Mode", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
- }
-
- if (result == DialogResult.Yes)
- {
-
-
- if (ApplyOffSettingDebits == 1)
- {
-
-
-
-
-
- transaction_str = textBox_transactiondescription.Text;
- debit_str = textBox_enteramounttobeapplied.Text;
-
- charVal_date = dateString.ToCharArray(0, dateString.Length);
- charVal_tranaction = transaction_str.ToCharArray(0, transaction_str.Length);
- charVal_debit = debit_str.ToCharArray(0, debit_str.Length);
-
- for (a = 0; a < GLDETAILEN - 2; a++) recordatavar_transactions[a] = (char)32;
- for (a = 0; a < dateString.Length; a++) recordatavar_transactions[a] = charVal_date[a];
- if (this.comboBox_transactiontype.Text == "CR")
- {
- recordatavar_transactions[8] = 'C';
- recordatavar_transactions[9] = 'R';
- }
- if (this.comboBox_transactiontype.Text == "CD")
- {
- recordatavar_transactions[8] = 'C';
- recordatavar_transactions[9] = 'D';
- }
- if (this.comboBox_transactiontype.Text == "GL")
- {
- recordatavar_transactions[8] = 'G';
- recordatavar_transactions[9] = 'L';
- }
- if (this.comboBox_transactiontype.Text == "J")
- {
- recordatavar_transactions[8] = 'J';
- recordatavar_transactions[9] = ' ';
- }
- if (this.comboBox_transactiontype.Text == "PR")
- {
- recordatavar_transactions[8] = 'P';
- recordatavar_transactions[9] = 'R';
- }
- if (this.comboBox_transactiontype.Text == "PY")
- {
- recordatavar_transactions[8] = 'P';
- recordatavar_transactions[9] = 'Y';
- }
- if (this.comboBox_transactiontype.Text == "ST")
- {
- recordatavar_transactions[8] = 'S';
- recordatavar_transactions[9] = 'T';
- }
- for (a = 0; a < transaction_str.Length; a++) recordatavar_transactions[a + 10] = charVal_tranaction[a];
- for (a = 0; a < debit_str.Length; a++) recordatavar_transactions[a + 50] = charVal_debit[a];
- for (a = 0; a < 3; a++) recordatavar_transactions[a + 70] = charVal_auto_number[a];
-
-
- FileStream fstreamobj1 = new FileStream(currdir + strfile, FileMode.Append);
- StreamWriter writerobj1 = new StreamWriter(fstreamobj1);
- writerobj1.WriteLine(recordatavar_transactions);
- writerobj1.Close();
- fstreamobj1.Close();
-
- }
-
-
- if (ApplyOffSettingCredits == 1)
- {
-
-
-
-
-
- transaction_str = textBox_transactiondescription.Text;
- credit_str = textBox_enteramounttobeapplied.Text;
-
- charVal_date = dateString.ToCharArray(0, dateString.Length);
- charVal_tranaction = transaction_str.ToCharArray(0, transaction_str.Length);
- charVal_credit = credit_str.ToCharArray(0, credit_str.Length);
-
- for (a = 0; a < GLDETAILEN - 2; a++) recordatavar_transactions[a] = (char)32;
- for (a = 0; a < dateString.Length; a++) recordatavar_transactions[a] = charVal_date[a];
- if (this.comboBox_transactiontype.Text == "CR")
- {
- recordatavar_transactions[8] = 'C';
- recordatavar_transactions[9] = 'R';
- }
- if (this.comboBox_transactiontype.Text == "CD")
- {
- recordatavar_transactions[8] = 'C';
- recordatavar_transactions[9] = 'D';
- }
- if (this.comboBox_transactiontype.Text == "GL")
- {
- recordatavar_transactions[8] = 'G';
- recordatavar_transactions[9] = 'L';
- }
- if (this.comboBox_transactiontype.Text == "J")
- {
- recordatavar_transactions[8] = 'J';
- recordatavar_transactions[9] = ' ';
- }
- if (this.comboBox_transactiontype.Text == "PR")
- {
- recordatavar_transactions[8] = 'P';
- recordatavar_transactions[9] = 'R';
- }
- if (this.comboBox_transactiontype.Text == "PY")
- {
- recordatavar_transactions[8] = 'P';
- recordatavar_transactions[9] = 'Y';
- }
- if (this.comboBox_transactiontype.Text == "ST")
- {
- recordatavar_transactions[8] = 'S';
- recordatavar_transactions[9] = 'T';
- }
- for (a = 0; a < transaction_str.Length; a++) recordatavar_transactions[a + 10] = charVal_tranaction[a];
- for (a = 0; a < credit_str.Length; a++) recordatavar_transactions[a + 60] = charVal_credit[a];
- for (a = 0; a < 3; a++) recordatavar_transactions[a + 70] = charVal_auto_number[a];
-
-
- FileStream fstreamobj1 = new FileStream(currdir + strfile, FileMode.Append);
- StreamWriter writerobj1 = new StreamWriter(fstreamobj1);
- writerobj1.WriteLine(recordatavar_transactions);
- writerobj1.Close();
- fstreamobj1.Close();
-
- }
-
-
-
-
-
- new_remaining_balance = remaining_balance - post_amount;
-
- this.textBox_enteramounttobeapplied.Text = " 0.00";
- amount_flag = 0;
-
-
-
-
- if (new_remaining_balance == 0 && MakeListBoxTomato == 1)
- {
-
-
- this.listBox_chartofaccountslisting.BackColor = Color.SandyBrown;
- MakeListBoxSandyBrown = 1;
- MakeListBoxMediumPurple = 0;
- MakeListBoxTomato = 0;
-
-
-
- this.button_totaldebitamountfordoubleentryposting.Enabled = true;
- this.button_totalcreditamountfordoubleentryposting.Enabled = true;
- this.textBox_transactiondescription.Text = "";
-
-
-
- if (ApplyOffSettingDebits == 1 && ApplyOffSettingCredits == 0)
- {
- ApplyOffSettingDebits = 0;
- ApplyOffSettingCredits = 1;
- }
- else
- {
- ApplyOffSettingDebits = 1;
- ApplyOffSettingCredits = 0;
- }
-
- }
-
-
-
-
- if (new_remaining_balance == 0 && MakeListBoxMediumPurple == 1)
- {
-
-
- this.listBox_chartofaccountslisting.BackColor = Color.Tomato;
- MakeListBoxSandyBrown = 0;
- MakeListBoxMediumPurple = 0;
- MakeListBoxTomato = 1;
-
-
- this.textBox_remainingbalanceoftotal.Text = remaining_offsetting_balance_str;
- amount_flag = 1;
-
-
-
- if (ApplyOffSettingDebits == 1 && ApplyOffSettingCredits == 0)
- {
- ApplyOffSettingDebits = 0;
- ApplyOffSettingCredits = 1;
- }
- else
- {
- ApplyOffSettingDebits = 1;
- ApplyOffSettingCredits = 0;
- }
-
- }
-
-
-
- if (amount_flag == 0)
- {
-
- for (a = 0; a < 10; a++) totalamount[a] = (char)32;
- totalamount[6] = (char)48;
- totalamount[7] = (char)46;
- totalamount[8] = (char)48;
- totalamount[9] = (char)48;
- countervar = 9;
- do
- {
- longresult = Math.DivRem(new_remaining_balance, 10, out long2);
- new_remaining_balance = longresult;
- if (long2 == 0) totalamount[countervar] = (char)48;
- if (long2 == 1) totalamount[countervar] = (char)49;
- if (long2 == 2) totalamount[countervar] = (char)50;
- if (long2 == 3) totalamount[countervar] = (char)51;
- if (long2 == 4) totalamount[countervar] = (char)52;
- if (long2 == 5) totalamount[countervar] = (char)53;
- if (long2 == 6) totalamount[countervar] = (char)54;
- if (long2 == 7) totalamount[countervar] = (char)55;
- if (long2 == 8) totalamount[countervar] = (char)56;
- if (long2 == 9) totalamount[countervar] = (char)57;
- countervar--;
- if (countervar == 7)
- {
- totalamount[countervar] = (char)46;
- countervar--;
- }
- } while (new_remaining_balance > 0);
-
- this.textBox_remainingbalanceoftotal.Text = new string(totalamount);
- }
-
-
- }
-
- }
- else
- {
-
- MessageBox.Show("The amount you want to post is greater than the remaining balance...transaction aborted....please input a new posting amount and retry...", "Error Mode");
-
- }
-
- }
-
-
- }
-
- }
CONCLUSION This method of performing a double entry posting is versatile, because the total debit or credit amount to be posted can be spread among any number of general ledger accounts until the total amount has been subtracted down to zero by the program’s built in calculator. It is also user friendly, because the color coded listing for the Chart of Accounts uses specific colors to denote the initial posting phase of “medium purple” and the offsetting posting phase of “tomato”. I have seen Chart of Accounts
software packages that are very intimidating to work with. I tried to get as far away from that as I could when I designed this one.