Last active
May 9, 2025 20:54
-
-
Save bryanwillis/b44e5c3e9ce2301e99feb68e54a6cd6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Invoice = Map(); | |
Line = List(); | |
CustomerRef = Map(); | |
CurrencyRef = Map(); | |
BillEmail = Map(); | |
SalesTermRef = Map(); | |
CustomerMemo = Map(); | |
lineCount = 0; | |
serviceList = List(); | |
for each rec in input.inv_sf | |
{ | |
lineCount = lineCount + 1; | |
linemap = Map(); | |
linemap.put("Description",rec.item_nm.item_dscr); | |
linemap.put("DetailType","SalesItemLineDetail"); | |
SalesItemLineDetail = Map(); | |
SalesItemLineDetail.put("Qty",rec.qty); | |
SalesItemLineDetail.put("UnitPrice",rec.item_price); | |
ItemRef = Map(); | |
ItemRef.put("value",rec.item_nm.qb_item_id.toNumber()); | |
//ItemRef.put("name",rec.invoice_item.item_name); | |
SalesItemLineDetail.put("ItemRef",ItemRef); | |
linemap.put("SalesItemLineDetail",SalesItemLineDetail); | |
linemap.put("LineNum",lineCount); | |
linemap.put("Amount",rec.tot_chrg); | |
Line.add(linemap); | |
serviceList.add(rec.item_nm.item_nm); | |
} | |
Invoice.put("Line",Line); | |
//Invoice.put("AllowOnlinePayment",true); | |
CustomerRef.put("value",input.client_id.qb_clnt_id); | |
Invoice.put("CustomerRef",CustomerRef); | |
Invoice.put("SyncToken","0"); | |
CurrencyRef.put("value","USD"); | |
Invoice.put("CurrencyRef",CurrencyRef); | |
Invoice.put("DocNumber",input.srv_id); | |
BillEmail.put("Address",input.client_id.pmry_email); | |
Invoice.put("BillEmail",BillEmail); | |
invoiceDate = toString(zoho.currentdate,"MM/dd/yyyy"); | |
Invoice.put("TxnDate",invoiceDate); | |
Invoice.put("PrintStatus","NeedToPrint"); | |
SalesTermRef.put("value","6"); | |
Invoice.put("SalesTermRef",SalesTermRef); | |
Invoice.put("AllowOnlineACHPayment",true); | |
// CustomerMemo.put("value","We now accept credit card and ACH transfers. We will no longer able to accept payment via check. Thank you for your business!"); | |
Invoice.put("CustomerMemo",CustomerMemo); | |
if(client_id.pmry_email.isEmpty() = true) | |
{ | |
Invoice.put("EmailStatus","NotSet"); | |
} | |
else | |
{ | |
Invoice.put("EmailStatus","NeedToSend"); | |
} | |
cus = List(); | |
map1 = Map(); | |
map1.put("DefinitionId","1"); | |
map1.put("Type","StringType"); | |
map1.put("Name","Location of Service"); | |
location = input.srt_loc.client_nm; | |
address = input.srt_ad.district_city + ", " + input.srt_ad.state_province; | |
if(location == "Residence") | |
{ | |
locationMap = location.concat("; ").concat(address); | |
if(locationMap.len() > 31) | |
{ | |
map1.put("StringValue",locationMap.left(31)); | |
} | |
else | |
{ | |
map1.put("StringValue",locationMap); | |
} | |
} | |
else if(location == "Miscellaneous Location") | |
{ | |
locationMap = "Misc Location".concat("; ").concat(address); | |
if(locationMap.len() > 31) | |
{ | |
map1.put("StringValue",locationMap.left(31)); | |
} | |
else | |
{ | |
map1.put("StringValue",locationMap); | |
} | |
} | |
else if(location.isEmpty() = true) | |
{ | |
map1.put("StringValue","Compassion Funeral Service"); | |
} | |
else | |
{ | |
if("Embalming in Our Care" in serviceList) | |
{ | |
map1.put("StringValue","Compassion Funeral Service"); | |
} | |
else | |
{ | |
locationMap = location; | |
if(locationMap.len() > 31) | |
{ | |
map1.put("StringValue",locationMap.left(31)); | |
} | |
else | |
{ | |
map1.put("StringValue",locationMap); | |
} | |
} | |
} | |
cus.add(map1); | |
map2 = Map(); | |
map2.put("DefinitionId","2"); | |
map2.put("Type","StringType"); | |
map2.put("Name","Date of Service"); | |
serviceDate = toString(input.srv_dt_time,"MM/dd/yyyy hh:mm a"); | |
map2.put("StringValue",serviceDate); | |
cus.add(map2); | |
map3 = Map(); | |
map3.put("DefinitionId","3"); | |
map3.put("Type","StringType"); | |
map3.put("Name","Name of Deceased"); | |
deceased = input.deceased_nm; | |
if(deceased.len() > 31) | |
{ | |
map3.put("StringValue",deceased.left(31)); | |
} | |
else | |
{ | |
map3.put("StringValue",deceased); | |
} | |
cus.add(map3); | |
deceasedName = input.deceased_nm; | |
if(deceasedName.len() > 31) | |
{ | |
deceasedName = deceasedName.left(31); | |
} | |
locationOfService = ""; | |
if(location == "Residence") | |
{ | |
locationOfService = location.concat("; ").concat(address); | |
} | |
else if(location == "Miscellaneous Location") | |
{ | |
locationOfService = "Misc Location".concat("; ").concat(address); | |
} | |
else if(location.isEmpty() == true || ("Embalming in Our Care" in serviceList)) | |
{ | |
locationOfService = "Compassion Funeral Service"; | |
} | |
else | |
{ | |
locationOfService = location; | |
} | |
if(locationOfService.len() > 31) | |
{ | |
locationOfService = locationOfService.left(31); | |
} | |
serviceDate = toString(input.srv_dt_time,"MM/dd/yyyy hh:mm a"); | |
memoText = "Name of Deceased: " + deceasedName + "\nLocation of Service: " + locationOfService + "\nDate of Service: " + serviceDate; | |
CustomerMemo.put("value", memoText); | |
Invoice.put("CustomField",cus); | |
//info Invoice; | |
resp = intuit.quickbooks.create("cfs_quickbooks","Invoice","9130348870604906",Invoice); | |
input.qb_inv_id = resp.get("Invoice").get("Id"); | |
if(resp.get("Invoice").get("Id") != null) | |
{ | |
input.inv_sta = "Invoice Created"; | |
for each record in INV_SF[srv_id = input.srv_id] | |
{ | |
record.inv_sta="Invoice Created"; | |
} | |
//input.main_staff_log_status = null; | |
} | |
//info resp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment