xxxx
parent
1738023cf0
commit
b4b7d511a7
|
@ -5,7 +5,7 @@
|
|||
<group span="6" columns="1">
|
||||
<field name="number"/>
|
||||
<field name="name"/>
|
||||
<field name="type" required="1"/>
|
||||
<field name="type" onchange="onchange_type" required="1"/>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
<field name="date_import"/>
|
||||
|
@ -20,7 +20,6 @@
|
|||
<list>
|
||||
<field name="name"/>
|
||||
<field name="select" onchange="onchange_sheet"/>
|
||||
<!--<field name="process_type"/>-->
|
||||
</list>
|
||||
</field>
|
||||
</group>
|
||||
|
@ -29,23 +28,25 @@
|
|||
<group span="3" columns="1">
|
||||
<button string="Load Sheet" type="primary" icon="download" method="load_sheet"/>
|
||||
<newline/>
|
||||
<button string="Load DATA" type="warning" icon="download" method="load_data"/>
|
||||
<button string="Load Payment" type="warning" icon="download" method="load_payment"/>
|
||||
<newline/>
|
||||
<button offset="10" string="Find Invoice" type="success" icon="search" method="find_invoice"/>
|
||||
<button offset="10" string="Match Invoice" type="success" icon="search" method="find_invoice"/>
|
||||
<newline/>
|
||||
<button offset="10" string="Make Payment" type="primary" icon="arrow-right" method="make_payment"/>
|
||||
<newline/>
|
||||
<button string="Post" type="success" icon="arrow-right" method="post_payment"/>
|
||||
<newline/>
|
||||
<button string="Clear DATA" type="default" icon="remove" method="clear_data"/>
|
||||
<button string="Undo" type="danger" icon="circle" method="undo"/>
|
||||
<newline/>
|
||||
<button string="Clear" type="default" icon="remove" method="clear"/>
|
||||
</group>
|
||||
<group span="3" columns="1">
|
||||
<field name="description" width="300" height="250" nolabel="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Priview">
|
||||
<field name="input_data" count="10" nolabel="1">
|
||||
<tab string="Payments">
|
||||
<field name="payment_lines" count="10" nolabel="1">
|
||||
<list>
|
||||
<field name="doc_date"/>
|
||||
<field name="name"/>
|
||||
|
@ -55,16 +56,13 @@
|
|||
</field>
|
||||
</tab>
|
||||
<tab string="Invoices">
|
||||
<field name="lines" count="10" nolabel="1">
|
||||
<field name="invoice_lines" count="10" nolabel="1">
|
||||
<list>
|
||||
<field name="invoice_id"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
</field>
|
||||
</tab>
|
||||
<tab string="History">
|
||||
<separator string="TODO"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
</foot>
|
||||
|
|
|
@ -19,6 +19,6 @@ from . import nation
|
|||
from . import race
|
||||
from . import cause_chronic
|
||||
from . import je
|
||||
from . import input_data
|
||||
from . import input_line
|
||||
from . import file_sheet
|
||||
from . import payment
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import time
|
||||
from netforce.model import Model, fields
|
||||
|
||||
class InputLine(Model):
|
||||
_name="clinic.input.line"
|
||||
_string="Input Line"
|
||||
class Invoice(Model):
|
||||
_name="clinic.invoice"
|
||||
_string="Clinic Invoice"
|
||||
|
||||
_fields={
|
||||
'je_id': fields.Many2One("clinic.je","Journal Entry"),
|
||||
'invoice_id': fields.Many2One("account.invoice","Invoice"),
|
||||
'invoice_id': fields.Many2One("account.invoice","NF Invoice"),
|
||||
'amount': fields.Float("Amount"),
|
||||
}
|
||||
|
||||
InputLine.register()
|
||||
Invoice.register()
|
||||
|
|
|
@ -8,6 +8,14 @@ from netforce.access import get_active_user, set_active_user
|
|||
from netforce.utils import get_file_path
|
||||
from netforce.utils import get_data_path
|
||||
|
||||
PAMENT_TYPE={
|
||||
"mg":"Medical Government",
|
||||
"sc":"Social Security",
|
||||
"nhso":"NHSO (30฿)",
|
||||
"personal": "Personal",
|
||||
"others": "Others",
|
||||
}
|
||||
|
||||
class JE(Model):
|
||||
_name="clinic.je"
|
||||
_string="Import Journal Entry"
|
||||
|
@ -19,11 +27,11 @@ class JE(Model):
|
|||
"type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)")],"Type"),
|
||||
'file': fields.File("File"),
|
||||
'payment_id': fields.Many2One("account.payment","Payment"),
|
||||
'lines': fields.One2Many("clinic.input.line","je_id", "Input Line"),
|
||||
'input_data': fields.One2Many("clinic.input.data","je_id", "Input Data"),
|
||||
'payment_lines': fields.One2Many("clinic.payment","je_id", "Payments"),
|
||||
'invoice_lines': fields.One2Many("clinic.invoice","je_id", "Invoices"),
|
||||
'sheets': fields.One2Many("clinic.file.sheet","je_id", "Sheets"),
|
||||
'columns': fields.One2Many("clinic.file.column","je_id", "Columns"),
|
||||
"state": fields.Selection([("draft","Draft"),('sheet_loaded','Sheet Loaded'),("fail","Fail"),("done","Done")],"Status",required=True),
|
||||
"state": fields.Selection([("draft","Draft"),('sheet_loaded','Sheet Loaded'),('payment_load','Payment Load'),('posted','Posted'),("fail","Fail"),("done","Done")],"Status",required=True),
|
||||
'description': fields.Text("Description")
|
||||
}
|
||||
|
||||
|
@ -90,7 +98,7 @@ class JE(Model):
|
|||
'flash': "Load sheet successfully",
|
||||
}
|
||||
|
||||
def load_data(self,ids,context={}):
|
||||
def load_payment(self,ids,context={}):
|
||||
obj=self.browse(ids[0])
|
||||
if not obj.file:
|
||||
raise Exception("Please select some file!")
|
||||
|
@ -105,6 +113,7 @@ class JE(Model):
|
|||
raise Exception("Please select some sheet!")
|
||||
if len(indexes) > 1:
|
||||
raise Exception("Only one sheet can select!")
|
||||
|
||||
sheet_name=indexes[0][1]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
|
@ -112,7 +121,7 @@ class JE(Model):
|
|||
ws=wb.sheet_by_name(sheet_name)
|
||||
num_rows = ws.nrows - 1
|
||||
curr_row = -1
|
||||
input_data=[]
|
||||
payment_lines=[]
|
||||
while curr_row < num_rows:
|
||||
curr_row += 1
|
||||
# skip header
|
||||
|
@ -129,19 +138,22 @@ class JE(Model):
|
|||
'hn':ws.cell_value(curr_row, 2),
|
||||
'amount':ws.cell_value(curr_row, 3),
|
||||
}
|
||||
input_data.append(('create',data))
|
||||
data_ids=[data.id for data in obj.input_data]
|
||||
get_model("clinic.input.data").delete(data_ids)
|
||||
payment_lines.append(('create',data))
|
||||
|
||||
data_ids=[data.id for data in obj.invoice_lines]
|
||||
get_model("clinic.payment").delete(data_ids)
|
||||
obj.write({
|
||||
'input_data': input_data,
|
||||
'description': 'see preview',
|
||||
'payment_lines': payment_lines,
|
||||
'description': 'see -> payments',
|
||||
})
|
||||
|
||||
|
||||
def clear_data(self,ids,context={}):
|
||||
def clear(self,ids,context={}):
|
||||
obj=self.browse(ids[0])
|
||||
data_ids=[data.id for data in obj.input_data]
|
||||
get_model("clinic.input.data").delete(data_ids)
|
||||
invoice_ids=[invoice.id for invoice in obj.invoice_lines]
|
||||
get_model("clinic.invoice").delete(invoice_ids)
|
||||
payment_ids=[payment.id for payment in obj.payment_lines]
|
||||
get_model("clinic.payment").delete(payment_ids)
|
||||
|
||||
def find_invoice(self,ids,context={}):
|
||||
obj=self.browse(ids[0])
|
||||
|
@ -157,22 +169,22 @@ class JE(Model):
|
|||
raise Exception("No partner")
|
||||
|
||||
# XXX
|
||||
if obj.lines:
|
||||
for line in obj.lines:
|
||||
if obj.payment_lines:
|
||||
for line in obj.payment_lines:
|
||||
line.delete()
|
||||
dom=[]
|
||||
dom.append(['state','=','waiting_payment'])
|
||||
dom.append(['partner_id','=',partner_id])
|
||||
lines=[]
|
||||
invoice_lines=[]
|
||||
for invoice in get_model("account.invoice").search_browse(dom):
|
||||
print(invoice.id, " ", invoice.number, " ", invoice.amount_total),
|
||||
line={
|
||||
'invoice_id': invoice.id,
|
||||
'amount': invoice.amount_total,
|
||||
}
|
||||
lines.append(('create',line))
|
||||
invoice_lines.append(('create',line))
|
||||
obj.write({
|
||||
'lines': lines,
|
||||
'invoice_lines': invoice_lines,
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
|
@ -180,12 +192,12 @@ class JE(Model):
|
|||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash':'Load invoice OK!',
|
||||
'flash':'Invoice Load!',
|
||||
}
|
||||
|
||||
def post_payment(self,ids,context={}):
|
||||
obj=self.browse(ids[0])
|
||||
if not obj.lines:
|
||||
if not obj.payment_lines:
|
||||
raise Exception("No invoice to post")
|
||||
|
||||
def onchange_sheet(self,context={}):
|
||||
|
@ -200,20 +212,20 @@ class JE(Model):
|
|||
def make_payment(self,ids,context={}):
|
||||
obj=self.browse(ids[0])
|
||||
if obj.payment_id:
|
||||
if obj.lines:
|
||||
if obj.payment_lines:
|
||||
if obj.payment_id.invoice_lines:
|
||||
return
|
||||
vals={
|
||||
'invoice_lines':[],
|
||||
}
|
||||
for line in obj.lines:
|
||||
# XXX
|
||||
for line in obj.invoice_lines:
|
||||
line={
|
||||
'invoice_id': line.invoice_id.id,
|
||||
'amount': line.amount,
|
||||
}
|
||||
vals['invoice_lines'].append(('create',line))
|
||||
obj.payment_id.write(vals)
|
||||
print("add invoice to payment")
|
||||
return
|
||||
company_id=get_active_company()
|
||||
timenow=time.strftime("%Y-%m-%d")
|
||||
|
@ -251,5 +263,11 @@ class JE(Model):
|
|||
},
|
||||
'flash': "Make payment ok !",
|
||||
}
|
||||
|
||||
def onchange_type(self,context={}):
|
||||
data=context['data']
|
||||
payment_type=PAMENT_TYPE.get(data['type'],"")
|
||||
data['name']="%s Payment for %s"%(payment_type,time.strftime("%Y-%m-%d"))
|
||||
return data
|
||||
|
||||
JE.register()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from netforce.model import Model, fields
|
||||
|
||||
class InputData(Model):
|
||||
_name="clinic.input.data"
|
||||
_string="Input Data"
|
||||
class Payment(Model):
|
||||
_name="clinic.payment"
|
||||
_string="Payment"
|
||||
_fields={
|
||||
'doc_date': fields.Date("Doc Date"),
|
||||
'name': fields.Char("Name"),
|
||||
|
@ -11,4 +11,4 @@ class InputData(Model):
|
|||
'je_id': fields.Many2One("clinic.je","Journal Entry"),
|
||||
}
|
||||
|
||||
InputData.register()
|
||||
Payment.register()
|
|
@ -13,3 +13,27 @@ question?
|
|||
- 1 cycle take how long ?
|
||||
issue:
|
||||
hd case should link only 1 dialyzer -> should not copy 2 time
|
||||
|
||||
create journal entry
|
||||
-> ok
|
||||
|
||||
sunday
|
||||
todo:
|
||||
- need to close all issue:
|
||||
https://docs.google.com/spreadsheets/d/1GDl9vCswHlD1MMfVwRS504keIz9NYL8VhUZlSPDEJvk/edit?usp=drive_web
|
||||
payment
|
||||
- personal
|
||||
- government
|
||||
|
||||
set visible for each staus
|
||||
|
||||
======= import data
|
||||
- flow
|
||||
1. select sheet
|
||||
2. select columns
|
||||
3. load data -> load payment
|
||||
4. review data -> review payment
|
||||
5. import data -> post payment
|
||||
6. done
|
||||
- issue
|
||||
load excel is very slow
|
||||
|
|
Loading…
Reference in New Issue