diff --git a/netforce_clinic/actions/report_clinic_payment_form.xml b/netforce_clinic/actions/report_clinic_payment_form.xml index 7110519..a4a67f9 100644 --- a/netforce_clinic/actions/report_clinic_payment_form.xml +++ b/netforce_clinic/actions/report_clinic_payment_form.xml @@ -1,6 +1,6 @@ - report_odt + report_odt2 clinic.hd.case - get_report_payment_data - payment_form + get_payment_data + cust_payment diff --git a/netforce_clinic/layouts/clinic_sickbed_form.xml b/netforce_clinic/layouts/clinic_sickbed_form.xml index cdb9cd0..a61cac1 100644 --- a/netforce_clinic/layouts/clinic_sickbed_form.xml +++ b/netforce_clinic/layouts/clinic_sickbed_form.xml @@ -14,6 +14,6 @@ - + diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 8c87a26..6355815 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -5,6 +5,7 @@ from netforce.model import Model, fields, get_model from netforce.utils import get_data_path, get_file_path from netforce.access import get_active_user,set_active_user from netforce.access import get_active_company +from . import utils class HDCase(Model): _name="clinic.hd.case" @@ -351,15 +352,12 @@ class HDCase(Model): 'ref': bill_no or obj.number or "", 'direct_lines': [], } - patient=obj.patient_id ptype=patient.type_id - #XXX shop_type=st.shop_type_id if not shop_type: raise Exception("No Patient Type -> Clinic Settings-> RD Shop -> Patient Type") ptype=shop_type - prod_acc=st.get_product_account for line in obj.lines: if line.reimbursable=='no': @@ -383,14 +381,6 @@ class HDCase(Model): "amount": line.amount or 0, 'account_id': account_id, })) - #vals['direct_lines'].append(('create',{ - #'description': 'Payment; %s'%obj.number, - #'account_id': income_account_id, - #'qty': 1, - #'unit_price': pay_amount, - #'amount': pay_amount, - #})) - payment_id=get_model("account.payment").create(vals,context={"type":"in"}) obj.write({ 'state': 'paid', @@ -922,42 +912,91 @@ class HDCase(Model): }, 'flash': 'Finish treatment!', } - - def get_report_payment_data(self,context={}): - settings=get_model("settings").browse(1) - refer_id=context.get("refer_id") - payment_id=context.get("payment_id") - data={ - 'settings_address_text': settings.default_address_id and settings.default_address_id.get_address_text()[settings.default_address_id.id] or "", - 'logo': get_file_path(settings.logo) or "", - } - if refer_id: - pass - if payment_id: - #context['refer_id']=payment_id - #data=get_model("account.payment").get_report_data(context=context) - payment=get_model("account.payment").browse(int(payment_id)) - partner_address_id=payment.partner_id.default_address_id - data['number']=payment.number - data['ref']=payment.related_id.number - data['date']=payment.date - data['partner_name']=payment.partner_id.name or 0 - data['partner_address_text']=partner_address_id and partner_address_id.get_address_text()[partner_address_id.id] or "", - lines=[] - for line in payment.direct_lines: - lines.append({ - 'description': line.description or '', - 'qty': line.qty, - 'unit_price': line.unit_price or 0.0, - 'amount': line.amount or 0.0, - }) - data['lines']=lines - data['amount_subtotal']=payment.amount_subtotal or 0.0 - data['amount_tax']=payment.amount_tax or 0.0 - data['amount_total']=payment.amount_total or 0.0 + def get_report_payment_data(self,context={}): + if not context.get('payment_id'): + return {} + payment_id=context.get("payment_id") + if not payment_id: + return {} + payment=get_model("account.payment").browse(int(payment_id)) + comp_id=get_active_company() + comp=get_model('company').browse(comp_id) + st=get_model('settings').browse(1) + addresses=st.addresses + comp_addr='' + if addresses: + comp_addr=addresses[0].address_text + cust=payment.partner_id + cust_name=cust.name or '' + cust_addr='' + if cust.addresses: + cust_addr=cust.addresses[0].address_text + if cust.walkin_cust: + cust_name=payment.ref or '' + no=1 + sub_total=0 + amount_total=0 + lines=[] + for line in payment.lines: + amt=line.amount or 0 + lines.append({ + 'no': no, + 'product_name': '', + 'description': line.description or '', + 'uom_name': '', + 'qty': line.qty or 0, + 'price': line.unit_price or 0, + 'amount': amt, + }) + sub_total+=amt + no+=1 + amount_total=sub_total + is_draft=payment.state=='draft' and True or False + is_cheque=False + pay_type=payment.pay_type or '' + data={ + 'comp_name': comp.name or '', + 'comp_addr': comp_addr or '', + 'tax_no': st.tax_no or '', + 'number': payment.number or '', + 'ref': payment.ref, + 'date': payment.date, + 'cust_name': cust_name, + 'cust_addr': cust_addr, + 'note': payment.memo or '', + 'lines':lines, + 'amount_subtotal': sub_total, + 'amount_total': amount_total, + 'total_text': utils.num2word(amount_total), + 'is_cheque': is_cheque, + 'is_draft': is_draft, + 'pay_type': pay_type, + } + if pay_type=='direct': + data['pay_type']='Cash' + else: + data['pay_type']='Credit' + if st.logo: + data['logo']=get_file_path(st.logo) return data - + + def get_payment_data(self,ids,context={}): + settings=get_model('settings').browse(1) + pages=[] + for obj in self.browse(ids): + for payment in obj.payments: + context['payment_id']=payment.id + data=self.get_report_payment_data(context=context) + pages.append(data) + if pages: + pages[-1]["is_last_page"]=True + return { + "pages": pages, + "logo": get_file_path(settings.logo), + } + return + def new_dialyzer(self,ids,context={}): obj=self.browse(ids)[0] is_wiz=context.get("is_wiz") diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py index 3f34d7d..f3f7ab0 100644 --- a/netforce_clinic/models/shop.py +++ b/netforce_clinic/models/shop.py @@ -53,7 +53,6 @@ class Shop(Model): 'cheque_no': fields.Char("Cheque No."), 'hd_case_call': fields.Boolean("HD Case Call"), 'note': fields.Text("Note"), - 'is_cheque': fields.Boolean("Is Cheque"), } def _get_branch(self,context={}): @@ -522,11 +521,9 @@ class Shop(Model): sub_total+=amt no+=1 amount_total=sub_total #XXX - is_cash='' - is_cheque=shop.is_cheque and 'x' or '' - if shop.pay_type=='cash': - is_cash='x' is_draft=shop.state=='draft' and True or False + is_cheque=False + pay_type=shop.pay_type or '' data={ 'comp_name': comp.name or '', 'comp_addr': comp_addr or '', @@ -542,9 +539,19 @@ class Shop(Model): 'amount_total': amount_total, 'total_text': utils.num2word(amount_total), 'is_cheque': is_cheque, - 'is_cash': is_cash, 'is_draft': is_draft, } + blank_dot='' + if pay_type=='cash': + data['pay_type']='Cash' + if shop.cheque_no: + data['is_cheque']=True + data['bank_name']=shop.bank_name or blank_dot + data['branch_name']=shop.branch_name or blank_dot + data['cheque_no']=shop.cheque_no or blank_dot + data['cheque_date']=shop.pay_date or blank_dot + else: + data['pay_type']='Credit' if st.logo: data['logo']=get_file_path(st.logo) diff --git a/netforce_clinic/reports/cust_payment.odt b/netforce_clinic/reports/cust_payment.odt index dd4ba6e..6d350f5 100644 Binary files a/netforce_clinic/reports/cust_payment.odt and b/netforce_clinic/reports/cust_payment.odt differ