diff --git a/netforce_clinic/actions/clinic_payment_matching.xml b/netforce_clinic/actions/clinic_payment_matching.xml new file mode 100644 index 0000000..fd2e0ee --- /dev/null +++ b/netforce_clinic/actions/clinic_payment_matching.xml @@ -0,0 +1,8 @@ + + Payment Matching + report + clinic.payment.matching + payment_matching + payment_matching + account_menu + diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml index c6ed01b..6bc6bdd 100644 --- a/netforce_clinic/layouts/clinic_account_menu.xml +++ b/netforce_clinic/layouts/clinic_account_menu.xml @@ -1,6 +1,6 @@ - + @@ -18,6 +18,9 @@ + + + diff --git a/netforce_clinic/layouts/clinic_document_form.xml b/netforce_clinic/layouts/clinic_document_form.xml new file mode 100644 index 0000000..8854b3c --- /dev/null +++ b/netforce_clinic/layouts/clinic_document_form.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/netforce_clinic/layouts/clinic_payment_matching.xml b/netforce_clinic/layouts/clinic_payment_matching.xml new file mode 100644 index 0000000..918a0f4 --- /dev/null +++ b/netforce_clinic/layouts/clinic_payment_matching.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/netforce_clinic/layouts/clinic_prod_form.xml b/netforce_clinic/layouts/clinic_prod_form.xml index 9f58722..01800df 100644 --- a/netforce_clinic/layouts/clinic_prod_form.xml +++ b/netforce_clinic/layouts/clinic_prod_form.xml @@ -1,8 +1,8 @@ - + - + @@ -10,7 +10,7 @@ - + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index e9f6029..a12468c 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -142,3 +142,5 @@ from . import conv_bal from . import conv_sale_invoice from . import account_move_line from . import invoice_payment +from . import document +from . import payment_matching diff --git a/netforce_clinic/models/document.py b/netforce_clinic/models/document.py new file mode 100644 index 0000000..3859784 --- /dev/null +++ b/netforce_clinic/models/document.py @@ -0,0 +1,10 @@ +from netforce.model import Model,fields + +class Document(Model): + _inherit="document" + + _fields={ + 'name': fields.Char("Name",search=True), + } + +Document.register() diff --git a/netforce_clinic/models/payment_matching.py b/netforce_clinic/models/payment_matching.py new file mode 100644 index 0000000..0484a58 --- /dev/null +++ b/netforce_clinic/models/payment_matching.py @@ -0,0 +1,108 @@ +import time +from calendar import monthrange + +from netforce.model import Model, fields, get_model + +class PaymentMatching(Model): + _name="clinic.payment.matching" + _string="Payment Matching" + _transient=True + + + _fields={ + 'name': fields.Char("Name"), + "date": fields.Date("Month"), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), + 'file_id': fields.Many2One('document','File',domain=[['categ_id.code','=','MP']]), + "period_id": fields.Many2One("clinic.period.line","Period"), + 'department_id': fields.Many2One("clinic.department","Department"), + 'branch_id': fields.Many2One("clinic.branch","Branch"), + "inv_state": fields.Selection([("draft","Draft"),("waiting_approval","Waiting Approval"),("waiting_payment","Waiting Payment"),("paid","Paid"),("voided","Voided")],"Status"), + "view_type": fields.Selection([("invoice","Invoice"),("file","File")],"View Type"), + } + + def _get_date_from(self,context={}): + year,month,day=time.strftime("%Y-%m-%d").split("-") + return '%s-%s-%s'%(year,month,day) + + def _get_date_to(self,context={}): + year,month,day=time.strftime("%Y-%m-%d").split("-") + weekday, total_day=monthrange(int(year), int(month)) + return "%s-%s-%s"%(year,month,day) + + def default_get(self,field_names=None,context={},**kw): + defaults=context.get("defaults",{}) + date_from=defaults.get("date_from", self._get_date_from()) + date_to=defaults.get("date_to", self._get_date_to()) + yearnow=date_from.split("-")[0] + for period in get_model('clinic.period').search_browse([['name','=',yearnow]]): + for line in period.lines: + if line.state=='open': + period_id=line.id + date_from=line.date_start + date_to=line.date_stop + break + res={ + 'period_id': period_id, + 'date': time.strftime("%Y-%m-%d"), + 'date_from': date_from, + 'date_to': date_to, + 'inv_state': 'waiting_payment', + 'view_type': 'invoice', + } + return res + + def onchange_period(self,context={}): + data=context['data'] + period_id=data['period_id'] + period=get_model('clinic.period.line').browse(period_id) + data['date_from']=period.date_start + data['date_to']=period.date_stop + return data + + def get_report_data(self,ids,context={}): + defaults=self.default_get(context=context) + print('defaults ', defaults) + date_from=defaults.get('date_from') + date_to=defaults.get('date_to') + branch_id=None + department_id=None + inv_state=defaults.get('inv_state') + view_type=defaults.get('view_type') + if ids: + obj=self.browse(ids)[0] + date_from=obj.date_from + date_to=obj.date_to + branch_id=obj.branch_id.id + department_id=obj.department_id.id + inv_state=obj.inv_state + view_type=obj.view_type + lines=[] + dom=[ + ['date','>=',date_from], + ['date','<=',date_to], + ['state','=',inv_state], + ] + if branch_id and not department_id: + dom.append(['department_id.branch_id','=',branch_id]) + elif department_id: + dom.append(['department_id','=',department_id]) + if view_type=='invoice': + field_names=['date','number','amount_due'] + for inv in get_model('account.invoice').search_read(dom,field_names): + vals={} + for field_name in field_names: + vals[field_name]=inv[field_name], + lines.append(vals) + data={ + 'lines': lines, + 'date_from': date_from, + 'date_to': date_to, + 'total_inv': len(lines), + 'view_type': view_type, + } + return data + + +PaymentMatching.register() diff --git a/netforce_clinic/readme.txt b/netforce_clinic/readme.txt index 1c0929d..914fccf 100644 --- a/netforce_clinic/readme.txt +++ b/netforce_clinic/readme.txt @@ -1,4 +1,4 @@ -- location - - staff - - patient - +mathching payment: + target + get invoice all invoice + can match any diff --git a/netforce_clinic/reports/payment_matching.xlsx b/netforce_clinic/reports/payment_matching.xlsx new file mode 100644 index 0000000..ee67794 Binary files /dev/null and b/netforce_clinic/reports/payment_matching.xlsx differ diff --git a/netforce_clinic/templates/payment_matching.hbs b/netforce_clinic/templates/payment_matching.hbs new file mode 100644 index 0000000..e750aa0 --- /dev/null +++ b/netforce_clinic/templates/payment_matching.hbs @@ -0,0 +1,38 @@ + + + + + + + TOTAL: {{total_inv}} + + + + + {{#ifeq view_type 'invoice'}} + + Invoice Date + Number + + + {{#if lines}} + {{#each lines}} + + {{date}} + {{number}} + + {{/each}} + {{else}} + {{/if}} + + + + {{else}} + TODO + {{/ifeq}} +