Ejemplo n.º 1
0
 /// <summary>
 /// Retrieve a payment for editing
 /// </summary>
 public void Payment(int id)
 {
     PaymentDocument document = getPayment(id);
     JObject record = document.ToJObject();
     Database.NextPreviousDocument(record, "WHERE DocumentTypeId = " + (int)PaymentDoc);
     Select s = new Select();
     record.Add("BankAccounts", s.BankAccount(""));
     record.Add("Names", s.Name(NameType, ""));
     Record = record;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Retrieve document, or prepare new one
 /// </summary>
 public JObject document(int id, DocType type)
 {
     Title = Title.Replace("Document", type.UnCamel());
     Extended_Document header = getDocument<Extended_Document>(id);
     if (header.idDocument == null) {
         header.DocumentTypeId = (int)type;
         header.DocType = type.UnCamel();
         header.DocumentDate = Utils.Today;
         header.DocumentName = "";
         header.DocumentIdentifier = Settings.NextNumber(type).ToString();
         if (GetParameters["name"].IsInteger()) {
             JObject name = Database.QueryOne("*", "WHERE Type = " + Database.Quote(NameType) + " AND idNameAddress = " + GetParameters["name"], "NameAddress");
             if (name != null) {
                 checkNameType(name.AsString("Type"), NameType);
                 header.DocumentNameAddressId = name.AsInt("idNameAddress");
                 header.DocumentAddress = name.AsString("Address");
                 header.DocumentName = name.AsString("Name");
             }
         }
     } else {
         checkDocType(header.DocumentTypeId, type);
         checkNameType(header.DocumentNameAddressId, NameType);
     }
     JObject record = new JObject().AddRange("header", header);
     Database.NextPreviousDocument(record, "WHERE DocumentTypeId = " + (int)type);
     Select s = new Select();
     record.AddRange("VatCodes", s.VatCode(""),
         "Names", s.Name(NameType, ""));
     return record;
 }