Example #1
0
 /// <summary>
 /// Add/update current report, with settings, to memorised reports.
 /// </summary>
 /// <param name="json"></param>
 /// <returns></returns>
 public AjaxReturn SaveReport(JObject json)
 {
     Report report = json.To<Report>();
     report.ReportGroup = "Memorised Reports";
     report.ReportSettings = json.ToString();
     Database.BeginTransaction();
     Database.Update(report);
     Database.Commit();
     return new AjaxReturn() { message = "Report saved", id = report.idReport };
 }
Example #2
0
 /// <summary>
 /// Post a matched transaction.
 /// May be called direct from StatementMatch for Same transactions,
 /// or when the user presses "Save" for other transactions
 /// </summary>
 public AjaxReturn StatementMatchPost(JObject json)
 {
     Utils.Check(SessionData.StatementMatch != null, "Invalid call to StatementMatchPost");
     MatchInfo match = SessionData.StatementMatch.ToObject<MatchInfo>();
     JArray transactions = SessionData.StatementImport.transactions;
     dynamic transaction = match.transaction < 0 ? null : SessionData.StatementImport.transactions[match.transaction];
     DocType type = match.transaction < 0 ? match.type == "Transfer" ? DocType.Transfer : DocType.Cheque :
         (DocType)((JObject)transactions[match.transaction]).AsInt("DocumentTypeId");
     AjaxReturn result;
     switch (type) {
         case DocType.Payment:
             result = new Customer() {
                 Context = Context,
                 GetParameters = GetParameters,
                 PostParameters = PostParameters,
                 Parameters = Parameters,
             }.PaymentPost(json.To<CustomerSupplier.PaymentDocument>());
             break;
         case DocType.BillPayment:
             result = new Supplier() {
                 Context = Context,
                 GetParameters = GetParameters,
                 PostParameters = PostParameters,
                 Parameters = Parameters,
             }.PaymentPost(json.To<CustomerSupplier.PaymentDocument>());
             break;
         case DocType.Cheque:
         case DocType.Deposit:
         case DocType.CreditCardCharge:
         case DocType.CreditCardCredit:
             result = DocumentPost(json.To<BankingDocument>());
             break;
         case DocType.Transfer:
             result = TransferPost(json.To<TransferDocument>());
             break;
         default:
             throw new CheckException("Unexpected document type:{0}", type.UnCamel());
     }
     if (result.error == null) {
         if(match.transaction >= 0 && match.type == "Same")
             transaction.Matched = 1;
         JArray items = SessionData.StatementImport.import;
         items.RemoveAt(match.current);
         result.redirect = "/banking/" + (items.Count == 0 ? "detail" : "statementmatching") + ".html?id=" + match.id;
     }
     return result;
 }