function fnAutoReceipt(objReservationDetails,fAryAccountBalance) {
let bIfContinue = true;
let dateDeparture = new Date(objReservationDetails.ResScreenData.ResRows[5].ValueText);
let dateToday = new Date();
let nCreditCardId = 0;
dateToday.setHours(0, 0, 0, 0);
dateDeparture.setHours(0, 0, 0, 0);
if (dateDeparture.getTime() !== dateToday.getTime()) {
console.log('continue');
bIfContinue = false;
}
if (bIfContinue) {
let strDate = new Date(objReservationDetails.ResScreenData.ResRows[5].ValueText);
let strAryMonth= ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
if (strDate != 'undefined') {
let strCreditCard = prompt('Please enter the credit card type \n AC: Alicredit \n WC: Wechatcredit \n GC: Great Wall Card \n UC: UnionPay ','WC');
strCreditCard= strCreditCard.toUpperCase();
if (strCreditCard.match('AC'))
strCreditCard = 'Alicredit';
else if (strCreditCard.match('WC'))
strCreditCard = 'Wechatcredit';
else if (strCreditCard.match('GC'))
strCreditCard = 'Great Wall Card';
else if (strCreditCard.match('UC'))
strCreditCard = 'UnionPay';
else {
strCreditCard = 'undefined'
alert('无法识别信用卡类别,仅支持AC(ali),WC(Wechatcredit),GC(Great Wall Card),UC(UnionPay)');
bIfContinue = false;
}
let objAryCCList = JSON.parse(window.localStorage.getItem('CreditCardList'));
for (let nCounter = 0; nCounter < objAryCCList.length; nCounter++) {
if (objAryCCList[nCounter].CreditCard == strCreditCard) {
nCreditCardId = objAryCCList[nCounter].CardId;
}
}
if (nCreditCardId == 0) {
alert('无法识别信用卡类别,请重试');
bIfContinue = false;
}
}
if (bIfContinue) {
let nAmount = fAryAccountBalance[5];
nAmount = prompt('Please Check the amount of receipt',nAmount);
let jobj = {
"ReceiptType": 4,
"Source": 3000,
"DateOfReceiptOverride": strDate.getDate()+ ' '+ strAryMonth[strDate.getMonth()] + ' ' + strDate.getFullYear(),
"CreditCardNumber": "",
"CreditCardExpiry": "",
"NameOnCreditCard": " ",
"CreditCardId": nCreditCardId,
"CreditCardCCVNo": "",
"lstOfAccountsToPay":
[{
"AccountType": 1,
"ReceiptAmount": nAmount,
"SecondCurrency": 0,
"AccountNo": objReservationDetails.ResScreenData.AccountId,
"ManualChargeAllocationTransIds": [],
"InvoiceNo": 0,
"ExchangeRateOverridden": 0
}],
"Tip": 0,
"Comment": '',
"JournalId": "",
"DateBanked": strDate.getDate()+ ' '+ strAryMonth[strDate.getMonth()] + ' ' + strDate.getFullYear(),
"Drawer": "",
"Tendered": 0,
"ChequeNo": "",
"Bank": "",
"CreditCardTransactionFeeType": 0,
"Branch": "",
"PostCode": "",
"State": "",
"StreetNo": null,
"Authorization": "",
"PropertyId": JSON.parse(window.localStorage.getItem('RM_Property')).data.split('_')[0],
"EFTPOSStationNo": "",
"EftposTerminalId": 0,
"TokenId": 0,
"DemoOrInternal": false,
"ExcludeOnlinePayment": false,
"IgnoreARAllocationCheck": false,
"SecurityDeposit": false,
"CurrencyCode": "¥",
"Addr1": "",
"Addr2": "",
"ClientResidence": 0,
"ExchangeRateId": 0,
"GatewayProvider": 13,
"ClientId": objReservationDetails.ResScreenData.ClientId,
"CreditCardFee": 0,
"UsingEFTPOSTerminal": false,
"Token": "",
"ResId": objReservationDetails.ResScreenData.ResId,
"CompId": 0,
"AgentId": 0,
"PayByLinkOption": 0,
"PayByLinkFrom": "",
"PayByLinkTo": "",
"PayByLinkEntityId": "",
"PayByLinkEntityType": "",
"PayByLinkLetterId": 0
}
console.log(jobj);
if (1) {
let xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "https://app9.rmscloud.cn/api/Receipt/ProcessReceiptOnAccountScreen", true);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
let objParam = {
"strName": "fnCallBackAutoReceipt",
"objValue": null,
"bIfContinue":true,
"strErrorDescription":""
}
window.postMessage(objParam);
}
}
xmlhttp.setRequestHeader('content-Type', 'application/json; charset=utf-8');
xmlhttp.send(JSON.stringify(jobj));
}
}
}
}