Journal Entry
![]() |
Go to top
|
![]() |
Resources For AutoCount Software Developers
|
Rules in Cash Book Entry
- Net Total of Debit and Credit must be same amount.
- Debit & Credit are not allow to coexist on the same line. Each line is either Debit or Credit.
- If the source amount is 100 at Debit, and 30 at Credit at same line, then 70 is placed at Debit.
- Eg. Debit = 100, Credit = 30, then DR = 70
- Amount in DR and CR cannot be negative.
- If the source amount is negative at Debit, then the amount should be placed at Credit.
- Eg. Debit = -100, then CR = 100
Assemblies version 1.8
BCE.AutoCount.dll BCE.AutoCount.GL.dll
Create new Journal Entry
public void NewJournalEntry(BCE.Data.DBSetting dbSetting, JournalSource source)
{
BCE.AutoCount.GL.JournalEntry.JournalEntryCommand cmd = BCE.AutoCount.GL.JournalEntry.JournalEntryCommand.Create(dbSetting);
BCE.AutoCount.GL.JournalEntry.JournalEntry doc = cmd.AddNew();
BCE.AutoCount.GL.JournalEntry.JournalEntryDetail dtl = null;
doc.Description = source.Description;
doc.CurrencyCode = source.CurrencyCode;
doc.CurrencyRate = source.CurrencyRate;
doc.DocNo = source.VoucherNo;
doc.DocDate = source.VoucherDate;
//Document Level Inclusive Tax
doc.InclusiveTax = source.InclusiveTax;
foreach (JournalDetail jnDtl in source.Details)
{
dtl = doc.AddDetail();
dtl.AccNo = jnDtl.Account;
dtl.Description = jnDtl.Description;
dtl.ProjNo = jnDtl.Project;
dtl.DeptNo = jnDtl.Department;
dtl.TaxType = jnDtl.GSTCode;
dtl.SupplyPurchase = jnDtl.GSTSupplyPurchase;
//Detail Level Inclusive Tax
dtl.InclusiveTax = jnDtl.InclusiveTax;
if (jnDtl.DebitAmount.HasValue)
dtl.DR = jnDtl.DebitAmount.Value;
else
dtl.CR = jnDtl.CreditAmount.Value;
}
try
{
doc.Save();
//log success
}
catch (BCE.Application.AppException ex)
{
//log ex.Message
}
}
![]() |
When dtl.DR is assigned with any value, system will auto reset the value of dtl.CR. Likewise same behavior apply to dtl.CR. |
![]() |
To learn about differences of Document Level & Detail Level Tax Inclusive, see Inclusive GST in Cash Book |
Classes of source
public class JournalSource
{
public string Description { get; set; }
public string CurrencyCode { get; set; }
public decimal CurrencyRate { get; set; }
public string VoucherNo { get; set; }
public DateTime VoucherDate { get; set; }
public bool InclusiveTax { get; set; } = false;
public List<JournalDetail> Details { get; set; } = new List<JournalDetail>();
}
public class JournalDetail
{
public string Account { get; set; }
public string Description { get; set; }
public string Project { get; set; }
public string Department { get; set; }
public decimal? DebitAmount { get; set; }
public decimal? CreditAmount { get; set; }
public BCE.AutoCount.Tax.TaxSupplyPurchase GSTSupplyPurchase { get; set; } = BCE.AutoCount.Tax.TaxSupplyPurchase.Supply;
public string GSTCode { get; set; }
public bool InclusiveTax { get; set; } = false;
}
Implementation
public MainEntry(BCE.Data.DBSetting dbSetting)
{
JournalSource newJN = new JournalSource()
{
Description = "SALARY OCT 2017",
CurrencyCode = "MYR",
CurrencyRate = 1,
VoucherNo = "<<New>>",
VoucherDate = new DateTime(2017, 11, 28),
};
newJN.Details.Add(new JournalDetail(){ Account = "410-0000", Description = "SALARY OCT 2017", CreditAmount = 11956.00M });
newJN.Details.Add(new JournalDetail(){ Account = "900-1005", Description = "TOM", DebitAmount = 5000 });
newJN.Details.Add(new JournalDetail(){ Account = "900-1005", Description = "JERRY", DebitAmount = 4800 });
newJN.Details.Add(new JournalDetail(){ Account = "700-3010", Description = "SALARY OCT 2017", DebitAmount = 1176 });
newJN.Details.Add(new JournalDetail(){ Account = "700-3015", Description = "SALARY OCT 2017", DebitAmount = 980 });
NewJournalEntry(dbSetting, newJN);
}