diff --git a/netforce_clinic/actions/clinic_matching_payment_popup.xml b/netforce_clinic/actions/clinic_matching_payment_popup.xml
new file mode 100644
index 0000000..82416b9
--- /dev/null
+++ b/netforce_clinic/actions/clinic_matching_payment_popup.xml
@@ -0,0 +1,6 @@
+
+ Select
+ form_popup
+ clinic.matching.payment.popup
+ _popup
+
diff --git a/netforce_clinic/layouts/clinic_cust_invoice_form.xml b/netforce_clinic/layouts/clinic_cust_invoice_form.xml
index 8667d88..f185557 100644
--- a/netforce_clinic/layouts/clinic_cust_invoice_form.xml
+++ b/netforce_clinic/layouts/clinic_cust_invoice_form.xml
@@ -1,5 +1,6 @@
-
+
+
diff --git a/netforce_clinic/layouts/clinic_matching_payment_form.xml b/netforce_clinic/layouts/clinic_matching_payment_form.xml
index cb6f5b6..e01e9b6 100644
--- a/netforce_clinic/layouts/clinic_matching_payment_form.xml
+++ b/netforce_clinic/layouts/clinic_matching_payment_form.xml
@@ -2,14 +2,13 @@
@@ -21,22 +20,57 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/netforce_clinic/layouts/clinic_matching_payment_popup.xml b/netforce_clinic/layouts/clinic_matching_payment_popup.xml
new file mode 100644
index 0000000..1a2e4d3
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_matching_payment_popup.xml
@@ -0,0 +1,9 @@
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index 41689fa..69c0b11 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -104,6 +104,7 @@ from . import make_apt
from . import make_apt_line
from . import matching_payment
from . import matching_payment_line
+from . import matching_payment_popup
from . import invoice_payment
from . import invoice_payment_line
from . import matching_hdcase
diff --git a/netforce_clinic/models/account_invoice.py b/netforce_clinic/models/account_invoice.py
index 9415185..a7d05eb 100644
--- a/netforce_clinic/models/account_invoice.py
+++ b/netforce_clinic/models/account_invoice.py
@@ -7,6 +7,8 @@ class AccountInvoice(Model):
_fields={
'clinic_expense_id': fields.Many2One("clinic.hd.case.expense","Expense"),
'department_id': fields.Many2One("clinic.department","Department",search=True),
+ 'patient_partner_id': fields.Many2One("partner","Patient",search=True),
}
+
AccountInvoice.register()
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index 874024f..8f24120 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -506,6 +506,7 @@ class HDCase(Model):
}))
patient=obj.patient_id
+ patient_partner=patient.partner_id
if rmb_lines:
ptype=patient.type_id
@@ -528,6 +529,8 @@ class HDCase(Model):
}
vals["partner_id"]=partner.id
vals['lines']=rmb_lines
+ if patient_partner:
+ vals['patient_partner_id']=patient_partner.id,
get_model("account.invoice").create(vals,context)
if normb_lines and is_credit:
@@ -548,6 +551,8 @@ class HDCase(Model):
'partner_id':partner.id,
}
vals['lines']=normb_lines
+ if patient_partner:
+ vals['patient_partner_id']=patient_partner.id,
get_model("account.invoice").create(vals,context) # create alway
obj.make_pickings()
diff --git a/netforce_clinic/models/matching_payment.py b/netforce_clinic/models/matching_payment.py
index fc58422..b66c21a 100644
--- a/netforce_clinic/models/matching_payment.py
+++ b/netforce_clinic/models/matching_payment.py
@@ -10,7 +10,6 @@ from . import utils
class MatchingPayment(Model):
_name="clinic.matching.payment"
_string="Payment Matching"
- #_transient=True
def _get_store(self,ids,context={}):
res={}
@@ -28,9 +27,13 @@ class MatchingPayment(Model):
total_fee=0
total_srv=0
total_epo=0
- for line in obj.lines:
- if line.state!='match':
- continue
+ otype=obj.type or "all"
+ lines=obj.lines
+ if otype=='match':
+ lines=obj.match_lines
+ elif otype=='unmatch':
+ lines=obj.unmatch_lines
+ for line in lines:
total_fee+=line.fee or 0
total_srv+=line.srv or 0
total_epo+=line.epo or 0
@@ -38,9 +41,9 @@ class MatchingPayment(Model):
if state=='match':
total_match+=1
res[obj.id]={
- 'total': len(obj.lines),
+ 'total': len(lines),
'total_match': total_match,
- 'total_unmatch': len(obj.lines)-total_match,
+ 'total_unmatch': len(lines)-total_match,
'total_fee': total_fee,
'total_srv': total_srv,
'total_epo': total_epo,
@@ -58,6 +61,8 @@ class MatchingPayment(Model):
'pcode': fields.Char("Code",required=True),
'hcode_id': fields.Many2One("clinic.hospital","HCode"),
'lines': fields.One2Many("clinic.matching.payment.line","match_id", "Lines"),
+ 'match_lines': fields.One2Many("clinic.matching.payment.line","match_id", "Lines",domain=[['state','=','match']]),
+ 'unmatch_lines': fields.One2Many("clinic.matching.payment.line","match_id", "Lines",domain=[['state','=','unmatch']]),
'note': fields.Text("Note"),
'total': fields.Integer("Total",function="_get_all",function_multi=True),
'total_match': fields.Integer("Match",function="_get_all",function_multi=True),
@@ -66,6 +71,7 @@ class MatchingPayment(Model):
'total_srv': fields.Float("Service",function="_get_all",function_multi=True),
'total_epo': fields.Float("EPO",function="_get_all",function_multi=True),
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
+ 'type': fields.Selection([['all','All'],['match','Match'],['unmatch','Not Match']],'Type'),
'user_id': fields.Many2One("base.user","Approver"),
}
@@ -102,6 +108,7 @@ class MatchingPayment(Model):
'pcode': _get_pcode,
'state': 'draft',
'user_id': lambda *a: get_active_user(),
+ 'type': 'all',
}
_order="date desc"
@@ -517,16 +524,36 @@ class MatchingPayment(Model):
def get_data(self,context={}):
ref_id=int(context.get("refer_id","0"))
obj=self.browse(ref_id)
- dom=[]
- dom.append(['date','>=',obj.date_from])
- dom.append(['date','<=',obj.date_to])
- for invoice in get_model("account.invoice").search_browse(dom):
- pass
- match_ids=[]
+ inv_match_ids=[]
for line in obj.lines:
- pass
- print("name ", obj.name)
- data={}
+ invoice=line.invoice_id
+ if invoice and line.state=='match':
+ inv_match_ids.append(invoice.id)
+ dom=[
+ ['partner_id','=',obj.partner_id.id],
+ ['date', '>=', obj.date_from],
+ ['date', '<=', obj.date_to],
+ ['state','=','waiting_payment'],
+ ]
+ lines=[]
+ no=1
+ for invoice in get_model('account.invoice').search_browse(dom):
+ if invoice.id in inv_match_ids:
+ continue
+ vals={
+ 'no': no,
+ 'date': invoice.date,
+ 'number': invoice.number,
+ 'ref': invoice.ref,
+ 'amount_due': invoice.amount_due or 0,
+ }
+ lines.append(vals)
+ no+=1
+ data={
+ 'lines': lines,
+ 'date_from': obj.date_from,
+ 'date_to': obj.date_to,
+ }
return data
def print_invoice_unmatch(self,ids,context={}):
@@ -537,7 +564,7 @@ class MatchingPayment(Model):
'mode': 'form',
'active_id': obj.id,
},
- 'flash': 'TODO',
+ #'flash': 'TODO',
}
MatchingPayment.register()
diff --git a/netforce_clinic/models/matching_payment_popup.py b/netforce_clinic/models/matching_payment_popup.py
new file mode 100644
index 0000000..8a6faf2
--- /dev/null
+++ b/netforce_clinic/models/matching_payment_popup.py
@@ -0,0 +1,39 @@
+from netforce.model import Model, fields, get_model
+
+class MatchingPaymentPopup(Model):
+ _name="clinic.matching.payment.popup"
+ _transient=True
+
+ _fields={
+ "matching_payment_id": fields.Many2One("clinic.matching.payment","Matching Payment",required=True,on_delete="cascade"),
+ 'type': fields.Selection([['all','All'],['match','Match'],['unmatch','Not Match']],'Type'),
+ }
+
+ def _get_id(self,context={}):
+ refer_id=context.get("refer_id")
+ if not refer_id:
+ return None
+ return int(refer_id)
+
+ _defaults={
+ 'matching_payment_id': _get_id,
+ 'type': 'all',
+ }
+
+ def do_select(self,ids,context):
+ obj=self.browse(ids)[0]
+ matching=obj.matching_payment_id
+ matching.write({
+ 'type': obj.type,
+ })
+ return {
+ 'next': {
+ 'name': 'clinic_matching_payment',
+ 'mode': 'form',
+ 'active_id': matching.id,
+ },
+ }
+
+
+MatchingPaymentPopup.register()
+
diff --git a/netforce_clinic/reports/matching_payment_invoice_unmatch.xlsx b/netforce_clinic/reports/matching_payment_invoice_unmatch.xlsx
index dfd255c..6505488 100644
Binary files a/netforce_clinic/reports/matching_payment_invoice_unmatch.xlsx and b/netforce_clinic/reports/matching_payment_invoice_unmatch.xlsx differ
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index 62ae521..c03c81d 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -1,16 +1,15 @@
todo:
- - report k. boy (sub detail) -> ok
- - need to update level of nurse (Chanon)
- - staff rotation
- - update level for staff
- - add script to
- multi department access ***
- - merge staff same name but different department
- - doctor นายแพทย์ ทวีชัย
- - ** udpate server (run click me)
- - ** update accounting
- - bug
- - wht (david)
+ - merge staff same name but different department
+ - doctor นายแพทย์ ทวีชัย
+ - run script
+ - update level's nurse
+ - report k. boy (sub detail) -> ok
+ - ** update accounting
+ - link ref -> ok
+ - bug -> ok
+ - wht (david) -> p yui test
+
===============================
- compute labor cost