def transactions(): itms = EnterpriseAPI.ItemPicker() pkgs = EnterpriseAPI.PackagePicker() wh = EnterpriseAPI.GetWareHouses() warehouse = EnterpriseAPI.GetWareHouses() trans = EnterpriseAPI.GetTrans() rqst = EnterpriseAPI.ApprRequests() if request.method == 'POST': if request.form['submit'] == 'Submit': try: if request.form['transaction-type'] == 'Inbound': transid = EnterpriseAPI.InboundTransaction( session['username'], session['password'], request.form.getlist('Name'), request.form.getlist('code'), request.form['warehouse'], request.form.getlist('bins'), request.form.getlist('unit'), request.form.getlist('quantity'), request.form['transaction-status'], request.form['comments']) flash('Inbound transaction recorded...', category='success') return redirect(url_for('logistics.transactions')) elif request.form['transaction-type'] == 'Outbound': transid = EnterpriseAPI.OutboundTransaction( session['username'], session['password'], request.form.getlist('Name'), request.form.getlist('code'), request.form['warehouse'], request.form.getlist('bins'), request.form.getlist('unit'), request.form.getlist('quantity'), request.form['transaction-status'], request.form['comments']) flash('Outbound transaction recorded...', category='success') return redirect(url_for('logistics.transactions')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('logistics.transactions')) return render_template('logistics/transactions.html', username=session['username'], role=session['role'], itms=itms, pkgs=pkgs, warehouse=warehouse, wh=wh, trans=trans, rqst=rqst)
def items_packages_inventory(): wh = EnterpriseAPI.GetWareHouses() itms = EnterpriseAPI.ItemPicker() pkgs = EnterpriseAPI.PackagePicker() cmp = EnterpriseAPI.GetCompanyProfile() if request.method == 'POST': if request.form['submit'] == 'Submit': if request.form['to-date'] < request.form['from-date']: flash('Error: To date must be later than from date', category='fail') return redirect(url_for('logistics.warehouse_inventory')) else: if request.form['file-type'] == 'csv': file = EnterpriseAPI.Items_Packs_Inventory_to_CSV( session['username'], session['password'], request.form['from-date'], request.form['to-date'], request.form.getlist('itm_check'), request.form.getlist('pkg_check')) response = make_response(file) response.headers['Content-type'] = 'text/csv' response.headers[ 'Content-Disposition'] = 'attachement; filename = items-packs_inventory_report.csv' return response elif request.form['file-type'] == 'pdf': data = EnterpriseAPI.Items_Packs_Inventory_to_PDF( session['username'], session['password'], request.form['from-date'], request.form['to-date'], request.form.getlist('itm_check'), request.form.getlist('pkg_check')) reportdate = datetime.datetime.now() rendered = render_template( '/logistics/item-pack-inventory-report.html', reportdate=reportdate, itm=request.form.getlist('itm_check'), pkg=request.form.getlist('pkg_check'), data=data, cmp=cmp) pdf = pdfkit.from_string(rendered, False) response = make_response(pdf) response.headers['Content-type'] = 'application/pdf' response.headers[ 'Content-Disposition'] = 'attachement; filename = item-pack-inventory-report.pdf' return response return render_template('logistics/item-package-inventory-report.html', username=session['username'], role=session['role'], wh=wh, itms=itms, pkgs=pkgs)
def requests(): trans = EnterpriseAPI.GetRequests() itms = EnterpriseAPI.ItemPicker() pkgs = EnterpriseAPI.PackagePicker() wh = EnterpriseAPI.GetWareHouses() appr = EnterpriseAPI.InvApprovers() if request.method == 'POST': if request.form['submit'] == 'Submit': if (request.form['status'] == 'Approved' or request.form['status'] == 'Rejected' ) and request.form['approver'] != session['username']: flash( "Can't proceed with request, approver's permission is required.", category='fail') return redirect(url_for('logistics.requests')) else: try: data, code = EnterpriseAPI.CreateRequest( session['username'], session['password'], request.form['type'], request.form['status'], request.form['approver'], request.form['comments'], request.form.getlist('code'), request.form.getlist('Name'), request.form.getlist('unit'), request.form.getlist('quantity')) msg = Message('New Inventory request', recipients=[data[2]]) msg.body = "Dear {}, \n Please note that new inventory request, code: {} has been created and requires your approval or rejection.".format( data[0], code) app.mail.send(msg) flash('Request successfully added.', category='success') return redirect(url_for('logistics.requests')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('logistics.requests')) return render_template('logistics/requests.html', username=session['username'], role=session['role'], trans=trans, wh=wh, itms=itms, pkgs=pkgs, appr=appr)
def EditRefundInvoice(invcode): customers = InvoicesAPI.GetAllCustomers() currencies = AccountingAPI.GetAllCurrencies() itms = EnterpriseAPI.ItemPicker() pkgs = EnterpriseAPI.PackagePicker() invs = InvoicesAPI.GetInvoices('refund') srvs = InvoicesAPI.GetServicesByType('Revenue') data1, data2 = InvoicesAPI.GetInvoice(session['username'], session['password'], invcode) if request.method == 'POST': if request.form['submit'] == 'Submit': try: InvoicesAPI.EditInvoice( session['username'], session['password'], invcode, 'refund', request.form['Customer'], request.form['SheetDate'], request.form['currency'], request.form['terms'], request.form.getlist('description'), request.form.getlist('unitprice'), request.form.getlist('quantity'), request.form.getlist('amount'), request.form['totalamount'], request.form['discount'], request.form['tax'], request.form['invamount'], request.form['pay_method'], request.form['billing_account'], request.form['comments']) flash('Invoices updated successfully', category='success') return redirect(url_for('invoices.RefundInvoice')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('invoices.RefundInvoice')) return render_template('invoices/edit_refund_invoice.html', username=session['username'], role=session['role'], itms=itms, pkgs=pkgs, customers=customers, currencies=currencies, invs=invs, data1=data1, data2=data2, invcode=invcode, srvs=srvs)
def ProcurementInvoice(): providers = EnterpriseAPI.GetProviders() currencies = AccountingAPI.GetAllCurrencies() itms = EnterpriseAPI.ItemPicker() pkgs = EnterpriseAPI.PackagePicker() invs = InvoicesAPI.GetInvoices('procurement') srvs = InvoicesAPI.GetServicesByType('Expense') if request.method == 'POST': if request.form['submit'] == 'Submit': try: invcode = InvoicesAPI.AddInvoice( session['username'], session['password'], 'procurement', request.form['Customer'], request.form['SheetDate'], request.form['currency'], request.form['terms'], request.form.getlist('description'), request.form.getlist('unitprice'), request.form.getlist('quantity'), request.form.getlist('amount'), request.form['totalamount'], request.form['discount'], request.form['tax'], request.form['invamount'], request.form['pay_method'], request.form['billing_account'], request.form['comments']) flash('Invoices created successfully', category='success') return redirect(url_for('invoices.ProcurementInvoice')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('invoices.ProcurementInvoice')) return render_template('invoices/procurement_invoice.html', username=session['username'], role=session['role'], itms=itms, pkgs=pkgs, providers=providers, currencies=currencies, invs=invs, srvs=srvs)
def edit_request(reqid): trans = EnterpriseAPI.GetRequests() itms = EnterpriseAPI.ItemPicker() pkgs = EnterpriseAPI.PackagePicker() wh = EnterpriseAPI.GetWareHouses() appr = EnterpriseAPI.InvApprovers() head, details, aprv = EnterpriseAPI.ReqInfo(reqid) if request.method == 'POST': if request.form['submit'] == 'Submit': if (request.form['status'] == 'Approved' or request.form['status'] == 'Rejected' ) and request.form['approver'] != session['username']: flash( "Can't proceed with request, approver's permission is required.", category='fail') return redirect(url_for('logistics.requests')) else: try: EnterpriseAPI.UpdateRequest(session['username'], session['password'], request.form['status'], request.form['comments'], reqid) flash('Request Updated', category='success') return redirect(url_for('logistics.requests')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('logistics.requests')) return render_template('logistics/edit_request.html', username=session['username'], role=session['role'], trans=trans, wh=wh, appr=appr, head=head, details=details, aprv=aprv)