Skip to content

Commit

Permalink
Merge a13cc85 into ac82e04
Browse files Browse the repository at this point in the history
  • Loading branch information
madmath03 committed May 1, 2020
2 parents ac82e04 + a13cc85 commit a56dccc
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 59 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ language: shell
branches:
only:
- master
- develop

before_install:
- env | sort
Expand Down
42 changes: 24 additions & 18 deletions erpnext_ocr/config/desktop.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Monogramm and Contributors
# See license.txt
"""Configuration for desktop."""

from __future__ import unicode_literals

from frappe import _


def get_data():
return [
{
"module_name": "OCR Read",
"_doctype": "OCR Read",
"color": "#00bcd4",
"icon": "fa fa-eye",
"type": "link",
"link": "List/OCR Read"
},
"""Returns the application desktop icons configuration."""
return [
{
"module_name": "OCR Read",
"_doctype": "OCR Read",
"color": "#00bcd4",
"icon": "fa fa-eye",
"type": "link",
"link": "List/OCR Read"
},

{
"module_name": "ERPNext OCR",
"color": "#00bcd4",
"icon": "octicon octicon-eye",
"type": "module",
"label": _("ERPNext OCR"),
"hidden": 1
}
]
{
"module_name": "ERPNext OCR",
"color": "#00bcd4",
"icon": "octicon octicon-eye",
"type": "module",
"label": _("ERPNext OCR"),
"hidden": 1
}
]
21 changes: 13 additions & 8 deletions erpnext_ocr/config/docs.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# -*- coding: utf-8 -*-
"""
Configuration for docs
"""
# Copyright (c) 2020, Monogramm and Contributors
# See license.txt
"""Configuration for docs."""

from __future__ import unicode_literals


source_link = "https://github.com/Monogramm/erpnext_ocr"
docs_base_url = "https://monogramm.github.io/erpnext_ocr"
headline = "ERPNext OCR Integration"
sub_heading = "Optical Character Recognition using tesseract within ERPNext"


def get_context(context):
context.brand_html = "ERPNext OCR"
context.source_link = source_link
context.docs_base_url = docs_base_url
context.headline = headline
context.sub_heading = sub_heading
"""Returns the application documentation context.
:param context: application documentation context"""
context.brand_html = "ERPNext OCR"
context.source_link = source_link
context.docs_base_url = docs_base_url
context.headline = headline
context.sub_heading = sub_heading
2 changes: 1 addition & 1 deletion erpnext_ocr/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# **erpnext_ocr** Documentation
# **ERPNext OCR** Documentation

This is the Documentation for **ERPNext OCR**.

Expand Down
9 changes: 0 additions & 9 deletions erpnext_ocr/erpnext_ocr/doctype/ocr_import/constants.py

This file was deleted.

10 changes: 9 additions & 1 deletion erpnext_ocr/erpnext_ocr/doctype/ocr_import/test_ocr_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@
import unittest

import frappe
from erpnext_ocr.erpnext_ocr.doctype.ocr_import.constants import TEST_RESULT_FOR_SI, TEST_RESULT_FOR_ITEM

from erpnext_ocr.erpnext_ocr.doctype.ocr_import.ocr_import import generate_doctype

# test recodes will automatically be generated by frappe
test_data = frappe.get_test_records('OCR Import')

TEST_RESULT_FOR_SI = '''
\n\nD. Brawn Manufacture\n\nInvoice no. DVT-AX-345678\n\nPayment date: 03/12/2006\n\n \n\n
\n\n \n\n \n\nReference Designation ty Unit price “Total CHF Sales\nWork\nSERVICE D COMPLETE OVERHAUL 1 5500.00 500,00 220\nSERVICE D REFRESHING COMPLETE CASE 1 380,00 380.00 220\nAND RHODIUM BATH\nExterior parts:\nJO.297.085.FP FLAT GASKET. 1 3.00 3.00 220\nJO.197.075.FP FLAT GASKET 1 4.00 4.00 220\nJO.199.059.08 FLAT ROUND GASKET 1 6.00 600 220\nVi.261.036.8C W.G.FIXATION SCREWS 10 4.00 40.00 220\nAL465.085.BC WHITE GOLD "FOIL" 1 70.00 70.00 220\nPAIR OF HAND\nLENGTH: 10/13.50MM\nCALIBRE 2868\nSPECIAL DISCOUNT -3003.00 — -3003.00\nDiscount “500.00 “800.00\nTotal CHF 2100.00\nRETURN AFTER REPAIR\n\nNO COMMERCIAL VALUE\n'''

TEST_RESULT_FOR_ITEM = '''
Series STO-ITEM-.YYYY.-\n\nItem Code fdsa\n\nItem Name fdsa\n\nItem Group Consumable\nDefault Unit of Measure Nos\n\nfdsa\n\nShelf Life In Days\n\nEnd of Life 31-12-2099\nDefault Material Request Purchase\nType\n\nSr UOM\n\n1 Nos\n\nMax Sample Quantity\n\nVariant Based On\n\nSr Company\n\n1 fdsa\n\nIs Purchase Item\nMinimum Order Qty\n\nSafety Stock\nCountry of Origin Russian Federation\n\nIs Sales Item\n\nWeightage\n\nMaintain Stock\n\nInclude Item In Manufacturing\n\nOpening Stock\n\nValuation Rate\nStandard Selling Rate\n\nAllow over delivery or receipt\nupto this percent\n\n0 Weight Per Unit\n\nItem Attribute\n\nDefault Warehouse\n\nStores - F\n\nv Lead Time in days\n\n0 Last Purchase Rate\n\nv Max Discount (%)\nNo of Months\n\nNo of Months\n\nv\n\n0\nRUB 0,00\n\nRUB 123,00\n\n0\n\nConversion Factor\n\n‘l\n
'''


class TestOCRImport(unittest.TestCase):
def setUp(self):
Expand Down
5 changes: 3 additions & 2 deletions erpnext_ocr/erpnext_ocr/doctype/ocr_read/ocr_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def read_image(self):
return read_ocr(self)

def read_image_bg(self, is_async=True, now=False):
return frappe.enqueue("erpnext_ocr.erpnext_ocr.doctype.ocr_read.ocr_read.read_ocr", queue="long",
timeout=1500, is_async=is_async, now=now, **{'obj': self})
return frappe.enqueue("erpnext_ocr.erpnext_ocr.doctype.ocr_read.ocr_read.read_ocr",
queue="long", timeout=1500, is_async=is_async,
now=now, **{'obj': self})


@frappe.whitelist()
Expand Down
5 changes: 4 additions & 1 deletion erpnext_ocr/hooks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Monogramm and Contributors
# See license.txt

from __future__ import unicode_literals
from . import __version__ as app_version

app_name = "erpnext_ocr"
app_title = "ERPNext OCR"
app_publisher = "Monogramm"
app_description = "Optical Character Recognition using tesseract within ERPNext"
app_description = "Optical Character Recognition using tesseract within Frappe."
app_icon = "octicon octicon-eye"
app_color = "#00bcd4"
app_email = "opensource@monogramm.io"
Expand Down
9 changes: 8 additions & 1 deletion erpnext_ocr/install.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Monogramm and Contributors
# For license information, please see license.txt

from __future__ import unicode_literals

import frappe


def before_tests():
"""Frappe trigger before application tests."""
settings = frappe.get_doc("System Settings")
settings.time_zone = "Etc/GMT+3"
settings.language = "en"
settings.save()
selling_settings = frappe.get_doc("Selling Settings")
selling_settings.allow_multiple_items = 1
selling_settings.save()
selling_settings.save()
32 changes: 15 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Monogramm and Contributors
# See license.txt

from setuptools import setup, find_packages
try: # for pip >= 10
from pip._internal.req import parse_requirements
except ImportError: # for pip <= 9.0.3
from pip.req import parse_requirements
import re, ast

with open('requirements.txt') as f:
install_requires = f.read().strip().split('\n')

# get version from __version__ variable in erpnext_ocr/__init__.py
# get version from __version__ variable in erpnext_autoinstall/__init__.py
_version_re = re.compile(r'__version__\s+=\s+(.*)')

with open('erpnext_ocr/__init__.py', 'rb') as f:
version = str(ast.literal_eval(_version_re.search(
f.read().decode('utf-8')).group(1)))

requirements = parse_requirements("requirements.txt", session="")

setup(
name='erpnext_ocr',
version=version,
description='OCR',
author='Monogramm',
author_email='opensource@monogramm.io',
packages=find_packages(),
zip_safe=False,
include_package_data=True,
install_requires=[str(ir.req) for ir in requirements],
dependency_links=[str(ir._link) for ir in requirements if ir._link]
name='erpnext_ocr',
version=version,
description='Optical Character Recognition using tesseract within Frappe..',
author='Monogramm',
author_email='opensource@monogramm.io',
packages=find_packages(),
zip_safe=False,
include_package_data=True,
install_requires=install_requires
)

0 comments on commit a56dccc

Please sign in to comment.