Skip to content

Commit

Permalink
Merge pull request #335 from yrestom/develop
Browse files Browse the repository at this point in the history
Version 6.0.1
  • Loading branch information
yrestom authored Jun 16, 2023
2 parents 025b794 + 2883adc commit 3a19e04
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 54 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
27. Supports Sales Person
28. Supports Delivery Charges
29. Search and add items by Batch Number
30. Accept new payments from customers against existing invoices
31. Payments Reconciliation

---

Expand Down
2 changes: 1 addition & 1 deletion posawesome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe

__version__ = "6.0.0"
__version__ = "6.0.1"


def console(*data):
Expand Down
87 changes: 45 additions & 42 deletions posawesome/posawesome/api/posapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,19 +562,17 @@ def submit_invoice(invoice, data):
is_payment_entry = 1

payments = []

if data.get("is_cashback") and not is_payment_entry:
for payment in invoice.get("payments"):
for i in invoice_doc.payments:
if i.mode_of_payment == payment["mode_of_payment"]:
i.amount = payment["amount"]
i.base_amount = 0
if i.amount:
payments.append(i)
break

if len(payments) == 0 and not invoice_doc.is_return and invoice_doc.is_pos:
payments = [invoice_doc.payments[0]]
for payment in invoice.get("payments"):
for i in invoice_doc.payments:
if i.mode_of_payment == payment["mode_of_payment"]:
i.amount = payment["amount"]
i.base_amount = 0
if i.amount:
payments.append(i)
break

if len(payments) == 0 and not invoice_doc.is_return and invoice_doc.is_pos:
payments = [invoice_doc.payments[0]]
else:
invoice_doc.is_pos = 0

Expand Down Expand Up @@ -613,12 +611,13 @@ def submit_invoice(invoice, data):
"is_payment_entry": is_payment_entry,
"total_cash": total_cash,
"cash_account": cash_account,
"payments": payments,
},
)
else:
invoice_doc.submit()
redeeming_customer_credit(
invoice_doc, data, is_payment_entry, total_cash, cash_account
invoice_doc, data, is_payment_entry, total_cash, cash_account, payments
)

return {"name": invoice_doc.name, "status": invoice_doc.docstatus}
Expand Down Expand Up @@ -646,7 +645,7 @@ def set_batch_nos_for_bundels(doc, warehouse_field, throw=False):


def redeeming_customer_credit(
invoice_doc, data, is_payment_entry, total_cash, cash_account
invoice_doc, data, is_payment_entry, total_cash, cash_account, payments
):
# redeeming customer credit with journal voucher
today = nowdate()
Expand Down Expand Up @@ -709,35 +708,39 @@ def redeeming_customer_credit(
jv_doc.submit()

if is_payment_entry and total_cash > 0:
payment_entry_doc = frappe.get_doc(
{
"doctype": "Payment Entry",
"posting_date": today,
"payment_type": "Receive",
"party_type": "Customer",
"party": invoice_doc.customer,
"paid_amount": total_cash,
"received_amount": total_cash,
"paid_from": invoice_doc.debit_to,
"paid_to": cash_account["account"],
"company": invoice_doc.company,
}
)
for payment in payments:
if not payment.amount:
continue
payment_entry_doc = frappe.get_doc(
{
"doctype": "Payment Entry",
"posting_date": today,
"payment_type": "Receive",
"party_type": "Customer",
"party": invoice_doc.customer,
"paid_amount": payment.amount,
"received_amount": payment.amount,
"paid_from": invoice_doc.debit_to,
"paid_to": payment.account,
"company": invoice_doc.company,
"mode_of_payment": payment.mode_of_payment,
"reference_no": invoice_doc.posa_pos_opening_shift,
"reference_date": today,
}
)

payment_reference = {
"allocated_amount": total_cash,
"due_date": data.get("due_date"),
"outstanding_amount": total_cash,
"reference_doctype": "Sales Invoice",
"reference_name": invoice_doc.name,
"total_amount": total_cash,
}
payment_reference = {
"allocated_amount": payment.amount,
"due_date": data.get("due_date"),
"reference_doctype": "Sales Invoice",
"reference_name": invoice_doc.name,
}

payment_entry_doc.append("references", payment_reference)
payment_entry_doc.flags.ignore_permissions = True
frappe.flags.ignore_account_permission = True
payment_entry_doc.save()
payment_entry_doc.submit()
payment_entry_doc.append("references", payment_reference)
payment_entry_doc.flags.ignore_permissions = True
frappe.flags.ignore_account_permission = True
payment_entry_doc.save()
payment_entry_doc.submit()


def submit_in_background_job(kwargs):
Expand Down
7 changes: 6 additions & 1 deletion posawesome/public/js/posapp/components/payments/Pay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ export default {
freeze_message: __('Processing Payment'),
callback: function (r) {
if (r.message) {
frappe.utils.play_sound('submit');
vm.clear_all(false);
vm.customer_name = customer;
vm.get_outstanding_invoices();
Expand Down Expand Up @@ -774,7 +775,7 @@ export default {
},
},
created: function () {
mounted: function () {
this.$nextTick(function () {
this.float_precision =
frappe.defaults.get_default('float_precision') || 2;
Expand All @@ -794,6 +795,10 @@ export default {
});
});
},
beforeDestroy() {
evntBus.$off('update_customer');
evntBus.$off('fetch_customer_details');
},
};
</script>

Expand Down
13 changes: 12 additions & 1 deletion posawesome/public/js/posapp/components/pos/Invoice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2547,7 +2547,7 @@ export default {
},
},
created() {
mounted() {
evntBus.$on('register_pos_profile', (data) => {
this.pos_profile = data.pos_profile;
this.customer = data.pos_profile.customer;
Expand Down Expand Up @@ -2609,6 +2609,17 @@ export default {
document.addEventListener('keydown', this.shortOpenFirstItem.bind(this));
document.addEventListener('keydown', this.shortSelectDiscount.bind(this));
},
beforeDestroy() {
evntBus.$off('register_pos_profile');
evntBus.$off('add_item');
evntBus.$off('update_customer');
evntBus.$off('fetch_customer_details');
evntBus.$off('new_invoice');
evntBus.$off('set_offers');
evntBus.$off('update_invoice_offers');
evntBus.$off('update_invoice_coupons');
evntBus.$off('set_all_items');
},
destroyed() {
document.removeEventListener('keydown', this.shortOpenPayment);
document.removeEventListener('keydown', this.shortDeleteFirstItem);
Expand Down
7 changes: 5 additions & 2 deletions posawesome/public/js/posapp/components/pos/Mpesa-Payments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
color="success"
dark
@click="submit_dialog"
>{{ __('Select') }}</v-btn
>{{ __('Submit') }}</v-btn
>
</v-card-actions>
</v-card>
Expand Down Expand Up @@ -175,5 +175,8 @@ export default {
this.selected = [];
});
},
beforeDestroy() {
evntBus.$off('open_mpesa_payments');
},
};
</script>
</script>
28 changes: 22 additions & 6 deletions posawesome/public/js/posapp/components/pos/Payments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,8 @@ export default {
}
let credit_calc_check = this.customer_credit_dict.filter((row) => {
if (row.credit_to_redeem)
return row.credit_to_redeem > row.total_credit;
if (flt(row.credit_to_redeem))
return flt(row.credit_to_redeem) > flt(row.total_credit);
else return false;
});
Expand Down Expand Up @@ -846,6 +846,11 @@ export default {
this.invoice_doc.payments.forEach((payment) => {
payment.amount = flt(payment.amount);
});
if (this.customer_credit_dict.length) {
this.customer_credit_dict.forEach((row) => {
row.credit_to_redeem = flt(row.credit_to_redeem);
});
}
let data = {};
data['total_change'] = -this.diff_payment;
data['paid_change'] = this.paid_change;
Expand Down Expand Up @@ -1186,8 +1191,8 @@ export default {
const advance = {
type: 'Advance',
credit_origin: payment.name,
total_credit: payment.unallocated_amount,
credit_to_redeem: payment.unallocated_amount,
total_credit: flt(payment.unallocated_amount),
credit_to_redeem: flt(payment.unallocated_amount),
};
this.clear_all_amounts();
this.customer_credit_dict.push(advance);
Expand Down Expand Up @@ -1246,7 +1251,7 @@ export default {
redeemed_customer_credit() {
let total = 0;
this.customer_credit_dict.map((row) => {
if (row.credit_to_redeem) total += this.flt(row.credit_to_redeem);
if (flt(row.credit_to_redeem)) total += flt(row.credit_to_redeem);
else row.credit_to_redeem = 0;
});
Expand Down Expand Up @@ -1284,7 +1289,7 @@ export default {
},
},
created: function () {
mounted: function () {
this.$nextTick(function () {
evntBus.$on('send_invoice_doc_payment', (invoice_doc) => {
this.invoice_doc = invoice_doc;
Expand Down Expand Up @@ -1342,6 +1347,17 @@ export default {
});
document.addEventListener('keydown', this.shortPay.bind(this));
},
beforeDestroy() {
evntBus.$off('send_invoice_doc_payment');
evntBus.$off('register_pos_profile');
evntBus.$off('add_the_new_address');
evntBus.$off('update_invoice_type');
evntBus.$off('update_customer');
evntBus.$off('set_pos_settings');
evntBus.$off('set_customer_info_to_edit');
evntBus.$off('update_invoice_coupons');
evntBus.$off('set_mpesa_payment');
},
destroyed() {
document.removeEventListener('keydown', this.shortPay);
Expand Down
11 changes: 10 additions & 1 deletion posawesome/public/js/posapp/components/pos/Pos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default {
},
},
created: function () {
mounted: function () {
this.$nextTick(function () {
this.check_opening_entry();
this.get_pos_setting();
Expand Down Expand Up @@ -217,6 +217,15 @@ export default {
});
});
},
beforeDestroy() {
evntBus.$off('close_opening_dialog');
evntBus.$off('register_pos_data');
evntBus.$off('LoadPosProfile');
evntBus.$off('show_offers');
evntBus.$off('show_coupons');
evntBus.$off('open_closing_dialog');
evntBus.$off('submit_closing_pos');
},
};
</script>

Expand Down

0 comments on commit 3a19e04

Please sign in to comment.