/// <summary> /// total pembayaran invoice /// </summary> /// <param name="id"></param> /// <returns></returns> public double getTotalInvoice(double id) { double price = -1; try { price = 0; SppDashboard sd = db.sppData.FirstOrDefault(f => f.spp_id == id); if (sd != null) { // invoice list if (sd.invoice_number != null) { JavaScriptSerializer js = new JavaScriptSerializer(); InvoiceFormat[] invoices = js.Deserialize<InvoiceFormat[]>(sd.invoice_number); if (invoices.Count() > 0) { foreach (var invoice in invoices) { price = price + invoice.total; } } } } } catch (Exception e) { Log.Error(e); } return price; }
/// <summary> /// info spp tertentu /// </summary> /// <param name="spp">id spp</param> /// <returns></returns> public SppDashboard getSpp(int? spp) { try { SppDashboard sd = db.sppData.Find(spp); if (sd != null) { var sppData = db.sppData.Where(m => m.po == _po).ToList(); if(sppData.Count() > 0) { foreach (var item in sppData) { if(sd.spp_number == null && item.spp_number != null) { sd.spp_number = item.spp_number; } if(sd.spp_date == null && sd.spp_date == DateTime.MinValue && item.spp_date != null && item.spp_date > DateTime.MinValue) { sd.spp_date = item.spp_date; } else { sd.spp_date = DateTime.Now; } if(sd.address == null && item.address != null) { sd.address = item.address; } if(sd.npwp == null && item.npwp != null) { sd.npwp = item.npwp; } if(sd.bank_name == null && item.bank_name != null) { sd.bank_name = item.bank_name; } if (sd.bill_number == null && item.bill_number != null) { sd.bill_number = item.bill_number; } if (sd.bill_owner == null && item.bill_owner != null) { sd.bill_owner = item.bill_owner; } if (sd.kabag_from == null && item.kabag_from != null) { sd.kabag_from = item.kabag_from; } if (sd.kabag_from_name == null && item.kabag_from_name != null) { sd.kabag_from_name = item.kabag_from_name; } if (sd.kabag_from_nik == null && item.kabag_from_nik != null) { sd.kabag_from_nik = item.kabag_from_nik; } if (sd.kabag_accounting_name == null && item.kabag_accounting_name != null) { sd.kabag_accounting_name = item.kabag_accounting_name; } } } return sd; } else { return new SppDashboard(); } } catch (Exception e) { Log.Error(e); return new SppDashboard(); } }