Programmer:Delivery Order v2: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
public void NewSaleDeliveryOrder(AutoCount.Authentication.UserSession userSession, SaleDeliveryOrderSource source) |
public void NewSaleDeliveryOrder(AutoCount.Authentication.UserSession userSession, SaleDeliveryOrderSource source) |
||
{ |
{ |
||
string newDocStr = "<<New>>"; |
|||
AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrderCommand cmd = AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrderCommand.Create(userSession, userSession.DBSetting); |
AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrderCommand cmd = AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrderCommand.Create(userSession, userSession.DBSetting); |
||
AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrder doc = cmd.AddNew(); |
AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrder doc = cmd.AddNew(); |
||
doc.DebtorCode = source.CustomerCode; |
doc.DebtorCode = source.CustomerCode; |
||
doc.DocNo = source.DocumentNo; |
doc.DocNo = source.DocumentNo ?? newDocStr; |
||
doc.DocDate = source.DocumentDate; |
doc.DocDate = source.DocumentDate; |
||
doc.Description = source.Description; |
doc.Description = source.Description; |
Latest revision as of 02:49, 3 August 2020
Technical Specification
- NetTotal must not be negative amount
- Document NetTotal amount is read-only, as the net total must be the sum of detail total (sub-total).
Assemblies version 2.0
AutoCount.Accounting.dll AutoCount.Accounting.UI.dll AutoCount.dll AutoCount.MainEntry.dll AutoCount.UI.dll AutoCount.Invoicing.dll AutoCount.Invoicing.Sales.dll
Sample with data model
Create New Sale Delivery Order
public void NewSaleDeliveryOrder(AutoCount.Authentication.UserSession userSession, SaleDeliveryOrderSource source)
{
string newDocStr = "<<New>>";
AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrderCommand cmd = AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrderCommand.Create(userSession, userSession.DBSetting);
AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrder doc = cmd.AddNew();
doc.DebtorCode = source.CustomerCode;
doc.DocNo = source.DocumentNo ?? newDocStr;
doc.DocDate = source.DocumentDate;
doc.Description = source.Description;
doc.CurrencyRate = source.CurrencyRate;
doc.Agent = source.SalesPerson;
//Set whether to apply which rounding methodo of either Document or Each Line,
//this may affect different result in GST Calculation due to decimal point.
doc.RoundingMethod = source.RoundMethod;
//Document Level Inclusive Tax
doc.InclusiveTax = source.Inclusive;
source.Details.ForEach(s => AddSaleDeliveryOrderDetail(s, doc.AddDetail));
try
{
doc.Save();
//log success
AutoCount.AppMessage.ShowMessage(string.Format("{0} is created.", doc.DocNo));
}
catch (AutoCount.AppException ex)
{
//log ex.Message
AutoCount.AppMessage.ShowMessage(ex.Message);
}
}
private void AddSaleDeliveryOrderDetail(SaleDeliveryOrderDetail sourceDtl,
Func<AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrderDetail> addToDoc)
{
AutoCount.Invoicing.Sales.DeliveryOrder.DeliveryOrderDetail dtl = addToDoc();
dtl.AccNo = sourceDtl.Account;
dtl.ItemCode = sourceDtl.ItemCode;
dtl.Description = sourceDtl.Description ?? dtl.Description;
if (sourceDtl.Project != null)
dtl.ProjNo = sourceDtl.Project;
if (sourceDtl.Department != null)
dtl.DeptNo = sourceDtl.Department;
if (sourceDtl.Location != null)
dtl.Location = sourceDtl.Location;
dtl.Qty = sourceDtl.Quantity ?? dtl.Qty;
dtl.UOM = sourceDtl.Uom ?? dtl.UOM;
dtl.UnitPrice = sourceDtl.UnitPrice ?? dtl.UnitPrice;
dtl.Discount = sourceDtl.Discount ?? dtl.Discount;
dtl.SubTotal = sourceDtl.Amount ?? dtl.SubTotal;
if (sourceDtl.GSTCode != null)
dtl.TaxType = sourceDtl.GSTCode;
dtl.TaxAdjustment = sourceDtl.GSTAdjustment;
}
Classes of source
public class SaleDeliveryOrderSource
{
public string CustomerCode { get; set; }
public string DocumentNo { get; set; }
public DateTime DocumentDate { get; set; }
public string Description { get; set; }
public decimal CurrencyRate { get; set; } = 1;
public string SalesPerson { get; set; }
public AutoCount.Document.DocumentRoundingMethod RoundMethod { get; set; } =
AutoCount.Document.DocumentRoundingMethod.LineByLine_Ver2;
public bool Inclusive { get; set; } = false;
public List<SaleDeliveryOrderDetail> Details { get; set; } = new List<SaleDeliveryOrderDetail>();
}
public class SaleDeliveryOrderDetail
{
public string Account { get; set; }
public string ItemCode { get; set; }
public string Description { get; set; }
public string Location { get; set; }
public string Project { get; set; }
public string Department { get; set; }
public decimal? Quantity { get; set; }
public string Uom { get; set; }
public decimal? UnitPrice { get; set; }
public string Discount { get; set; }
public decimal? Amount { get; set; }
public string GSTCode { get; set; }
public decimal GSTAdjustment { get; set; }
}
Implementation
public void MainEntry(AutoCount.Authentication.UserSession userSession)
{
SaleDeliveryOrderSource newDoc = new SaleDeliveryOrderSource()
{
CustomerCode = "300-A001",
Description = "SALES INVOICE GENERATED",
//If let AutoCount auto assign running number, assign "<<New>>" is unnecessary
//DocumentNo = "<<New>>",
DocumentDate = new DateTime(2017, 11, 30),
Inclusive = true
};
//There are many ways which data input can be entered into details, here are some of the common input.
newDoc.Details.Add(new SaleDeliveryOrderDetail() { Description = "Particulars" });
newDoc.Details.Add(new SaleDeliveryOrderDetail() { ItemCode = "FG00001", Quantity = 1, UnitPrice = 50.20M, GSTCode = "SR-S" });
newDoc.Details.Add(new SaleDeliveryOrderDetail() { ItemCode = "FG00001", Quantity = 2, UnitPrice = 50.20M, Discount = "5%", GSTCode = "SR-S" });
newDoc.Details.Add(new SaleDeliveryOrderDetail() { ItemCode = "FG00001", Quantity = 1, GSTCode = "SR-S", Amount = 50.20M });
newDoc.Details.Add(new SaleDeliveryOrderDetail() { Description = "Non-Stock Items" });
//When AccNo & ItemCode both are not defined, system will retrieve from default Sale Account.
//If default Sale Account is not maintained in Tools | Options, system will throw error on saving.
newDoc.Details.Add(new SaleDeliveryOrderDetail() { Description = "Misc. Charges", GSTCode = "SR-S", Amount = 30 });
newDoc.Details.Add(new SaleDeliveryOrderDetail() { Account = "500-0000", Description = "Transport", Amount = 50, GSTCode = "SR-S" });
NewSaleDeliveryOrder(userSession, newDoc);
}
Non-Stock Item can either with or without ItemCode, it depends on the setting & preference of customer Account Book. |
See Also
- Programmer:Quotation v2
- Programmer:Sales Order v2
- Programmer:Delivery Order v2
- Programmer:Sales Invoice v2
- Programmer:Cash Sale with Payment v2
Go to top
|
Resources For AutoCount Software Developers
|