private void AddExpensePaymentIntoQBLog(Model.PaymentReceipt payment, int group) { // Add Debit entry. smART.Model.QBLog parentQBLog = new Model.QBLog(); parentQBLog.Source_ID = payment.ID; parentQBLog.Source_Type = "Payment"; parentQBLog.Parent_ID = 0; parentQBLog.Account_No = ""; parentQBLog.Account_Name = "Gold Star Metalex"; parentQBLog.Debit_Amt = payment.Net_Amt; parentQBLog.Remarks = string.Format("Payment ID: {0}", payment.ID); parentQBLog.Parent_ID = 0; parentQBLog.Group = group; parentQBLog = AddInQBLog(parentQBLog, payment); // Add Credit entry smART.Model.QBLog childQBLog = new Model.QBLog(); childQBLog.Source_ID = payment.ID; childQBLog.Parent_ID = parentQBLog.ID; childQBLog.Account_No = ""; childQBLog.Account_Name = "Inventory Asset"; childQBLog.Credit_Amt = payment.Net_Amt; childQBLog.Remarks = string.Format("Payment ID: {0}", payment.ID); childQBLog.Group = group; childQBLog.Source_Type = "Payment"; AddInQBLog(childQBLog, payment); }
public void AddReceiptIntoQBLog(Model.PaymentReceipt receipt, int group) { // Add Debit entry. smART.Model.QBLog parentQBLog = new Model.QBLog(); parentQBLog.Source_ID = receipt.ID; parentQBLog.Source_Type = "Receipt"; parentQBLog.Parent_ID = 0; parentQBLog.Account_No = ""; parentQBLog.Account_Name = receipt.Transaction_Mode == "Cash" ? "Petty Cash" : "Gold Star Metalex"; parentQBLog.Debit_Amt = receipt.Net_Amt; parentQBLog.Remarks = string.Format("Receipt#: {0}, Receipt Party: {1}", receipt.ID, receipt.Party.Party_Name); parentQBLog.Parent_ID = 0; parentQBLog.Group = group; parentQBLog.Name = receipt.Party.Party_Name; parentQBLog.RS_Ref_No = string.Format("R{0}", receipt.ID); parentQBLog = AddInQBLog(parentQBLog, receipt); // Get Invoice# and Booking# string[] paymentReceiptPredicates = { "Invoice.Booking.Sales_Order_No.Party", "PaymentReceipt" }; IEnumerable <Model.PaymentReceiptDetails> paymentReceipts = _repository.Find <Model.PaymentReceiptDetails>(o => o.PaymentReceipt.ID == receipt.ID, paymentReceiptPredicates); string strBooking = string.Empty; string strInvoice = string.Empty; foreach (var item in paymentReceipts) { if (string.IsNullOrEmpty(strBooking)) { strBooking += item.Invoice.Booking.Booking_Ref_No; } else { strBooking += ", " + item.Invoice.Booking.Booking_Ref_No; } if (string.IsNullOrEmpty(strInvoice)) { strInvoice += item.Invoice.ID; } else { strInvoice += ", " + item.Invoice.ID; } } // Add Credit entry. smART.Model.QBLog childQBLog = new Model.QBLog(); childQBLog.Source_ID = receipt.ID; childQBLog.Parent_ID = parentQBLog.ID; childQBLog.Account_No = ""; childQBLog.Account_Name = "Accounts Receivable"; childQBLog.Credit_Amt = receipt.Net_Amt; childQBLog.Remarks = string.Format("Receipt#: {0}, Invoice#: {1}, Booking#: {2}, Receipt Party: {3}", receipt.ID, strInvoice, strBooking, receipt.Party.Party_Name); childQBLog.Group = group; childQBLog.Source_Type = "Receipt"; childQBLog.Name = receipt.Party.Party_Name; childQBLog.RS_Ref_No = string.Format("R{0}", receipt.ID); AddInQBLog(childQBLog, receipt); }
private void AddScalePaymentIntoQBLog(Model.PaymentReceipt payment, int group) { // Add Debit entry. smART.Model.QBLog parentQBLog = new Model.QBLog(); parentQBLog.Source_ID = payment.ID; parentQBLog.Source_Type = "Payment"; parentQBLog.Parent_ID = 0; parentQBLog.Account_No = ""; parentQBLog.Account_Name = payment.Transaction_Mode == "Cash" ? "Petty Cash" : "Gold Star Metalex"; parentQBLog.Credit_Amt = payment.Net_Amt; parentQBLog.Remarks = string.Format("Payment#: {0}, Payment Party: {1}", payment.ID, payment.Party.Party_Name); parentQBLog.Parent_ID = 0; parentQBLog.Group = group; parentQBLog.Name = payment.Party.Party_Name; parentQBLog.RS_Ref_No = string.IsNullOrEmpty(payment.Check_Wire_Transfer) ? string.Format("P{0}", payment.ID) : payment.Check_Wire_Transfer; parentQBLog = AddInQBLog(parentQBLog, payment); string[] paymentReceiptPredicates = { "Settlement.Scale", "PaymentReceipt", "ExpenseRequest" }; IEnumerable <Model.PaymentReceiptDetails> paymentReceipts = _repository.Find <Model.PaymentReceiptDetails>(o => o.PaymentReceipt.ID == payment.ID, paymentReceiptPredicates); foreach (var item in paymentReceipts) { // Add Credit entry. smART.Model.QBLog childQBLog = new Model.QBLog(); childQBLog.Source_ID = payment.ID; childQBLog.Parent_ID = parentQBLog.ID; childQBLog.Account_No = ""; childQBLog.Account_Name = "Inventory Asset"; childQBLog.Debit_Amt = item.Apply_Amount; childQBLog.Remarks = string.Format("Payment#: {0}, Scale#: {1}, Payment Party: {2}", payment.ID, item.Settlement.Scale.ID, payment.Party.Party_Name); childQBLog.Group = group; childQBLog.Source_Type = "Payment"; childQBLog.Name = payment.Party.Party_Name; childQBLog.RS_Ref_No = string.IsNullOrEmpty(payment.Check_Wire_Transfer) ? string.Format("P{0}", payment.ID) : payment.Check_Wire_Transfer; AddInQBLog(childQBLog, item); } }
public void AddPaymentReceiptIntoQBLog(int paymentId) { // Check duplicate log. smART.Model.QBLog parentQBLog = _repository.Find <Model.QBLog>(o => o.Source_ID == paymentId && (o.Source_Type == "Payment" || o.Source_Type == "Receipt")).FirstOrDefault(); if (parentQBLog != null) { return; } // Get payment. string[] paymentPredicates = { "Party", "Account_Name" }; Model.PaymentReceipt entity = _repository.Find <Model.PaymentReceipt>(o => o.ID == paymentId, paymentPredicates).FirstOrDefault(); if (entity != null && entity.Transaction_Status == "Closed") { // Get last entry to generate group. Model.QBLog latestQBLog = _repository.GetAll <Model.QBLog>().LastOrDefault(); int group = latestQBLog != null ? latestQBLog.Group + 1 : 1; if (entity.Transaction_Type == "Payment") { // For Scale Ticket Payment. if (entity.Payment_Receipt_Type == "Tickets") { AddScalePaymentIntoQBLog(entity, group); } //// For Expense Payment. //else if (entity.Payment_Receipt_Type == "Expenses") // AddExpensePaymentIntoQBLog(entity, group); } else if (entity.Transaction_Type == "Receipt") { AddReceiptIntoQBLog(entity, group); } } }