Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Printer = peripheral.find("printer")
- local function CheckPrinter()
- local Pass = true
- if Printer.getInkLevel() == 0 or Printer.getPaperLevel() == 0 then Pass = false end
- return Pass
- end
- local function ReceiptHelp()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- print("==Commands==")
- print("CheckPrinter : sees if printer is able to print")
- print("PrintReceipt : Company,Purchase,Title,Client,Items")
- print("==end==")
- end
- local function PrintReceipt(Company,Purchase,Title,Client,Items)
- local Sub = 0
- for i = 1, #Items do
- Sub = Sub + Items[i][3]
- end
- local Taxes = (Sub*GovEc.GetTax("sales"))
- local total = Sub + Taxes
- local Layout = {"===Receipt===",Company.." "..Purchase,"Proof of Purchase",os.date(),"to order of "..Client,"-Items-"}
- if Client == "n" then Layout[5] = "Certificate" end
- for i = 1, #Items do
- Layout[#Layout + 1] = Items[i][1].." x"..Items[i][2].." $"..Items[i][3]
- end
- Layout[#Layout + 1] = "Subtotal : $"..Sub
- Layout[#Layout + 1] = "taxes : $"..Taxes
- Layout[#Layout + 1] = "total : $"..total
- Layout[#Layout + 1] = "==Official=Document=="
- Layout[#Layout + 1] = "created with authorization of"
- Layout[#Layout + 1] = "the State Government and bank"
- Printer.newPage()
- Printer.setTitle(Title)
- Printer.setCursorPos(1,1)
- for i = 1, #Layout do
- Printer.setCursorPos(1,i)
- Printer.write(Layout[i])
- end
- Printer.endPage()
- end
- return {ReceiptHelp = ReceiptHelp, PrintReceipt = PrintReceipt, CheckPrinter = CheckPrinter}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement