Skip to content

Commit

Permalink
Merge pull request #173 from xdorro/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
thuyetbn authored Aug 27, 2021
2 parents 1a4406c + 1819fea commit 57da05d
Show file tree
Hide file tree
Showing 33 changed files with 253 additions and 140 deletions.
40 changes: 22 additions & 18 deletions Backend/Areas/Admin/Controllers/ChequesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public ActionResult PostData(Cheques chequeInformation)
}, JsonRequestBehavior.AllowGet);
}

if (0 > chequeInformation.Amount)
if (0 >= chequeInformation.Amount)
{
errors.Add("Amount", "Please enter a positive number");
return Json(new
Expand Down Expand Up @@ -356,6 +356,17 @@ public ActionResult ChequeExec(ChequesExecViewModel chequeExec)
}, JsonRequestBehavior.AllowGet);
}

if (chequeExec.PaymentMethod == "bank-account" && string.IsNullOrEmpty(chequeExec.ToBankAccountName))
{
errors.Add("ToBankAccountName", "This field is required!");
return Json(new
{
message = "Error",
data = errors,
statusCode = 400,
}, JsonRequestBehavior.AllowGet);
}

BankAccounts toBankAccounts;
if (chequeExec.PaymentMethod == "bank-account" &&
!Utils.IsNullOrEmpty(chequeExec.ToBankAccountName))
Expand Down Expand Up @@ -397,36 +408,29 @@ public ActionResult ChequeExec(ChequesExecViewModel chequeExec)

if (toBankAccounts != null)
{
cheque.ToBankAccountId = toBankAccounts.AccountId;
cheque.ToBankAccountId = toBankAccounts.BankAccountId;
if (toBankAccounts.Account != null & toBankAccounts.Account.NumberId != null)
{
cheque.NumberId = toBankAccounts.Account.NumberId;
}
}

//cheques.Edit(cheque);
_context.SaveChanges();

var data = new ChequesViewModel
{
ChequeBookId = cheque.ChequeBookId,
Code = cheque.Code,
NumberId = cheque.NumberId,
ChequeId = cheque.ChequeId,
StatusName = ((ChequeStatus) cheque.Status).ToString(),
Status = cheque.Status,
AmountNumber = cheque.Amount,
FromBankAccountName = cheque.FromBankAccount.Name,
FromBankAccountId = cheque.FromBankAccountId,
ToBankAccountName = cheque.ToBankAccountId == null
? "None, using cash!"
: cheque.ToBankAccount.Name
};
var data = new ChequesViewModel(cheque);

if (chequeExec.PaymentMethod != "bank-account" || toBankAccounts == null)
{
transaction.Commit();
return Json(new
{
message = "Success",
data = data,
statusCode = 200,
}, JsonRequestBehavior.AllowGet);

}

toBankAccounts.Balance += cheque.Amount;
//bankAccounts.Edit(toBankAccounts);
// _context.Entry(toBankAccounts).State = EntityState.Modified;
Expand Down
4 changes: 3 additions & 1 deletion Backend/Areas/Admin/Controllers/CurrenciesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public ActionResult GetData()

public ActionResult FindId(int id)
{
return Json(currencies.Get(id), JsonRequestBehavior.AllowGet);
var currency = currencies.Get(id);
var data = new CurencyViewModel(currency);
return Json(data, JsonRequestBehavior.AllowGet);
}

[HttpPost]
Expand Down
12 changes: 9 additions & 3 deletions Backend/Areas/Admin/Views/Accounts/ProfileAccount.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,13 @@
var trans = {
Amount: $("#Amount").val(),
ToId: $("#Name").val(),
};
managerBank.receiveMoney(trans);
};
if (trans.Amount[0] === "0") {
notifyError("Error", "Your Amount must be number")
} else {
managerBank.receiveMoney(trans);
}
}
});
function loadStatus(status = null) {
Expand Down Expand Up @@ -420,6 +425,7 @@
notifySuccess("Transfers Successfully", res.data);
}else {
notifyError("Transfers Error", res.data.FromId);
validator2.showErrors(res.data)
}
}
Expand Down Expand Up @@ -535,7 +541,7 @@
data: 'ChequeBookId',
"render": function (data, type, row) {
let toggle = row.Status === 0 ? "Close book" : "Open book";
return '<div class="dropdown custom-dropdown mb-0"><div class="btn sharp btn-primary tp-btn" data-toggle="dropdown" aria-expanded="false"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18px" height="18px" viewBox="0 0 24 24" version="1.1"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect x="0" y="0" width="24" height="24"></rect><circle fill="#000000" cx="12" cy="5" r="2"></circle><circle fill="#000000" cx="12" cy="12" r="2"></circle><circle fill="#000000" cx="12" cy="19" r="2"></circle></g></svg></div><div class="dropdown-menu dropdown-menu-right" x-placement="bottom-end" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(40px, 41px, 0px);"><a data-id="' + row.ChequeBookId + '" data-account="' + row.AccountId + '" class="dropdown-item btn-detail-2" href="javascript:void(0);">Details</a><a data-id="' + row.ChequeBookId + '" class="dropdown-item btn-toggle" href="javascript:void(0);">' + toggle + '</a><a data-id="' + row.ChequeBookId + '" class="dropdown-item text-danger btn-delete2" href="javascript:void(0);">Delete</a></div></div>'
return '<div class="dropdown custom-dropdown mb-0"><div class="btn sharp btn-primary tp-btn" data-toggle="dropdown" aria-expanded="false"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18px" height="18px" viewBox="0 0 24 24" version="1.1"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect x="0" y="0" width="24" height="24"></rect><circle fill="#000000" cx="12" cy="5" r="2"></circle><circle fill="#000000" cx="12" cy="12" r="2"></circle><circle fill="#000000" cx="12" cy="19" r="2"></circle></g></svg></div><div class="dropdown-menu dropdown-menu-right" x-placement="bottom-end" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(40px, 41px, 0px);"><a data-id="' + row.ChequeBookId + '" data-account="' + row.AccountId + '" class="dropdown-item btn-detail-2 text-info" href="javascript:void(0);">Details</a><a data-id="' + row.ChequeBookId + '" class="dropdown-item btn-toggle text-warning" href="javascript:void(0);">' + toggle + '</a><a data-id="' + row.ChequeBookId + '" class="dropdown-item text-danger btn-delete2" href="javascript:void(0);">Delete</a></div></div>'
}
},
Expand Down
5 changes: 2 additions & 3 deletions Backend/Areas/Admin/Views/BankAccounts/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,9 @@
function loadStatus(status = null) {
$.ajax({
type: "GET",
url: "/Admin/Accounts/GetStatus",
url: "/Admin/BankAccounts/GetStatus",
success: function (res) {
console.log(res)
let html;
var html;
$.each(res, function (key, value) {
html += "<option value = '" + key + "' " + ((parseInt(status)) === key ? 'selected' : '') + ">" + value + " </option>";
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<th>CreatedAt</th>
<th>Messages</th>
<th>Amount </th>
<th>Balance </th>
<th>Status </th>
</tr>
</thead>
Expand Down
2 changes: 1 addition & 1 deletion Backend/Areas/Admin/Views/ChequeBooks/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
data: 'ChequeBookId',
"render": function (data, type, row) {
let toggle = row.Status === 0 ? "Close book" : "Open book";
return '<div class="dropdown custom-dropdown mb-0"><div class="btn sharp btn-primary tp-btn" data-toggle="dropdown" aria-expanded="false"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18px" height="18px" viewBox="0 0 24 24" version="1.1"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect x="0" y="0" width="24" height="24"></rect><circle fill="#000000" cx="12" cy="5" r="2"></circle><circle fill="#000000" cx="12" cy="12" r="2"></circle><circle fill="#000000" cx="12" cy="19" r="2"></circle></g></svg></div><div class="dropdown-menu dropdown-menu-right" x-placement="bottom-end" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(40px, 41px, 0px);"><a data-id="' + row.ChequeBookId + '" data-account="' + row.AccountId + '" class="dropdown-item btn-detail-2" href="javascript:void(0);">Details</a><a data-id="' + row.ChequeBookId + '" class="dropdown-item btn-toggle" href="javascript:void(0);">' + toggle + '</a><a data-id="' + row.ChequeBookId + '" class="dropdown-item text-danger btn-delete" href="javascript:void(0);">Delete</a></div></div>'
return '<div class="dropdown custom-dropdown mb-0"><div class="btn sharp btn-primary tp-btn" data-toggle="dropdown" aria-expanded="false"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18px" height="18px" viewBox="0 0 24 24" version="1.1"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect x="0" y="0" width="24" height="24"></rect><circle fill="#000000" cx="12" cy="5" r="2"></circle><circle fill="#000000" cx="12" cy="12" r="2"></circle><circle fill="#000000" cx="12" cy="19" r="2"></circle></g></svg></div><div class="dropdown-menu dropdown-menu-right" x-placement="bottom-end" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(40px, 41px, 0px);"><a data-id="' + row.ChequeBookId + '" data-account="' + row.AccountId + '" class="dropdown-item btn-detail-2 text-info" href="javascript:void(0);">Details</a><a data-id="' + row.ChequeBookId + '" class="dropdown-item btn-toggle text-warning" href="javascript:void(0);">' + toggle + '</a><a data-id="' + row.ChequeBookId + '" class="dropdown-item text-danger btn-delete" href="javascript:void(0);">Delete</a></div></div>'
}
},
Expand Down
42 changes: 21 additions & 21 deletions Backend/Areas/Admin/Views/Cheques/Cheque.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@
</label>
</div>
<div class="form-group destination-account mt-2" style="display: none">
<label for="ToBankAccountId">Bank Account Destination</label>
<label for="ToBankAccountName">Bank Account Destination</label>
<input type="text" name="ToBankAccountName" id="ToBankAccountName" class="form-control" placeholder="Bank Account Destination...">
<span class="text-dark font-weight-bold" id="text2" style="display: none">Name: </span>
<span class="text-danger font-weight-bold" id="infoReceiver" style="display: none"></span>
<div id="InfoBankAccount" style="display: none">
<span class="text-dark font-weight-bold" id="text2">Name: <span class="text-danger font-weight-bold" id="infoReceiver"></span></span>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-success toastrDefaultSuccess" id="btnSave">Save</button>
<button type="button" class="btn btn-warning" data-dismiss="modal">Reset</button>
</div>
</div>
</form>
Expand All @@ -75,50 +75,50 @@
<div class="item">
<div class="row">
<div class="col-md-4">
<p>Code: </p>
<p class="text-warning">Code: </p>
</div>
<div class="col-md-8">
<p id="modal-code"></p>
<p id="modal-code" class="text-warning"></p>
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-md-4">
<p>Amount: </p>
<p class="text-danger">Amount: </p>
</div>
<div class="col-md-8">
<p id="modal-amount"></p>
<p id="modal-amount" class="text-danger"></p>
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-md-4">
<p>Source: </p>
<p class="text-success">Source: </p>
</div>
<div class="col-md-8">
<p id="modal-from"></p>
<p id="modal-from" class="text-success"></p>
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-md-4">
<p>Destination: </p>
<p class="text-success">Destination: </p>
</div>
<div class="col-md-8">
<p id="modal-to"></p>
<p id="modal-to" class="text-success"></p>
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-md-4">
<p>Status: </p>
<p class="text-info">Status: </p>
</div>
<div class="col-md-8">
<p id="modal-status"></p>
<p id="modal-status" class="text-info"></p>
</div>
</div>
</div>
Expand Down Expand Up @@ -220,27 +220,27 @@
$(".destination-account").show();
}else{
$(".destination-account").hide();
$("#ToBankAccountId").val("");
$("#ToBankAccountName").val("");
}
})
$('#successModal').on('shown.bs.modal', function () {
$(".destination-account").hide();
$("#InfoBankAccount").hide();
$('#infoReceiver').html("");
validator.resetForm();
});
$(document).on('blur', '#ToBankAccountName', function () {
let dataInfoBankAccount;
if (this.value.trim().length == 0 && this.value == "") {
$('#infoReceiver').css('display', 'none');
$('#text2').css('display', 'none');
$("#InfoBankAccount").hide();
} else {
dataInfoBankAccount = loadInfoBankAccount(this.value);
$('#text2').css('display', 'inline-block');
$("#InfoBankAccount").show();
}
if (dataInfoBankAccount.statusCode === 200) {
$('#infoReceiver').css('display', 'inline-block');
$('#infoReceiver').html(dataInfoBankAccount.data[0].Name);
} else {
$('#infoReceiver').css('display', 'inline-block');
$('#infoReceiver').html("Account doesn't exist");
}
});
Expand Down
Loading

0 comments on commit 57da05d

Please sign in to comment.