I want fixed subscription invoice date on my stripe subscriptions. Currently it takes 30days in each month and If I create a subscription on 1st, next invoice comes on 30th but it should be 1st for every month. Here is my code-
$subscription = $stripe->subscriptions->create([
'customer' => $customerID,
'items' => $items,
'add_invoice_items' => $invoiceitems,
'payment_behavior' => 'default_incomplete',
'expand' => ['latest_invoice.payment_intent'],
'trial_end' => $startdate,
//'cancel_at' => $enddate,
'proration_behavior' => 'always_invoice',
'billing_cycle_anchor' => $startdate
]);
I can see in your code snippet that you are using the billing_date_anchor. The docs state
Determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices.
Based on that here are two things you should try.
Verify the price.recurring attribute has your prices recurring with interval set to "month" and interval_count set to 1.
Ensure the $startdate value passed in is anchored to your timezone.
Related
I am using DatePicker and I want to set a calendar date based on other calendar field, if the date of first calendar falls in current month then the date of second calendar should be valid from the date of first calendar (for eg: 1st calendar date is set to 20-06-2021 which is of current month then the second calendar date should allow to add date from 20-06-2021), if the date of first calendar falls in last month then the date of second calendar should be valid from the start date of this month (for eg: 1st calendar is set to 20-05-2021 which is of last month then the second calendar date should allow to add date from 01-06-2021), please give me a solution on how I can resolve this issue.
You can do it by using state suppose you have started your first date picker from 2021-06-20
this.state = {date:"2021-06-20"}
and then when the user changes the date you update your state by
onDateChange={(date) => {this.setState({date: date})}}
now by using this updated state you can start your second date picker by using the current state.
And by assigning it to a variable you can apply any conditional statements that you want.
I'm working on a project, which should include calendar and hourly list of reservations in each day. I'm stuck on a problem, where i need to set data from rest api in the markedDates object.
This is the object i get from api
{
"dateTimeFrom":"2020-10-01 00:00:00",
"dateTimeTo":"2020-10-31 00:00:00",
"dom":"[\"2020-10-13\"]",
"dow":"[1,4]",
"id":"1",
"transport_id":"1",
"typeID":"1"
},
The response means, that the reservation is from 2020-10-01 till 2020-10-31, except all Mondays and Thursdays, and also 2020-10-13
dateTime from and To stands for reservation start date and end date,
dom and dow stands for blocked days in a month, dom : '2020-10-13' means that 13th date in 10th month is blocked, and dow : 1,4 stands for all mondays and thursdays are blocked.
Is it possible to achieve this with react-native-calendars, or should i use something else / create custom component?
I'm trying to find the Oracle SQL for finding the last business day of current month and also last business day of previous month. Both cases should consider the federal holidays calendar.
For Example:
Last Business Day of Current Month
If am running as of date 15th November, 2019
I should technically get my output as 29th November since 28th is Thanksgiving holiday.
Store those federal holidays in a holidays table as DATE type and then
try something like this: Find the oldest ( MAX ) day in the last seven days of the month that is neither a Saturday or a Sunday nor a holiday mentioned in
the holidays table.
The assumptions here are that 1) not all seven days at the end of the month can all be holidays or weekend and 2) Saturday and Sundays are off. You may adjust the level or where clause accordingly, depending on whether the above assumption should always hold true or not.
SELECT MAX(dt) AS last_working_day
FROM
(
SELECT last_day(SYSDATE) - level + 1 as dt
FROM dual CONNECT BY
level <= 7 -- the last seven days of the month
) WHERE TO_CHAR(dt,'DY', 'NLS_DATE_LANGUAGE = AMERICAN') NOT IN ('SAT','SUN')
AND dt NOT IN ( SELECT holiday from federal_holidays );
A much better approach would be to have a Calendar table with all the dates of the year and predefined column called isbusinessday. Then the query would be much simpler.
SELECT MAX(dt)
FROM calendar
WHERE isbusinessday = 'Y'
AND TO_CHAR(dt,'YYYYMM') = TO_CHAR(SYSDATE,'YYYYMM');
Having a holiday table is working in general, however it requires some maintenance as certain holidays are moving. For example Thanksgiving Day is the 4th Thursday in November, i.e. it varies from November 22 to November 28.
You can also use the Oracle build-in Scheduler. Usually it is used to control the SCHEDULER JOBS but I don't see any reason why it should not be used for something else.
First create a list of federal holidays, for example this:
BEGIN
DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name => 'CHRISTMAS', repeat_interval => 'FREQ=YEARLY;INTERVAL=1;BYDATE=1225', comments => 'December 25');
DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name => 'COLUMBUS_DAY', repeat_interval => 'FREQ=MONTHLY;BYMONTH=OCT;BYDAY=2 MON', comments => '2nd Monday in October');
DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name => 'INDEPENDENCE_DAY', repeat_interval => 'FREQ=YEARLY;INTERVAL=1;BYDATE=0704', comments => 'July 4');
DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name => 'MARTIN_LUTHER_KING_DAY', repeat_interval => 'FREQ=MONTHLY;BYMONTH=JAN;BYDAY=3 MON', comments => '3rd Monday in January');
DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name => 'MEMORIAL_DAY', repeat_interval => 'FREQ=MONTHLY;BYMONTH=MAY;BYDAY=-1 MON', comments => 'Last Monday of May');
DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name => 'NEW_YEARS_DAY', repeat_interval => 'FREQ=YEARLY;INTERVAL=1;BYDATE=0101', comments => 'January 1');
DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name => 'THANKSGIVING', repeat_interval => 'FREQ=MONTHLY;BYMONTH=NOV;BYDAY=4 THU', comments => '4th Thursday in November');
DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name => 'WASHINGTONS_BIRTHDAY', repeat_interval => 'FREQ=MONTHLY;BYMONTH=FEB;BYDAY=3 MON', comments => '3rd Monday in February');
DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name => 'WEEKEND', repeat_interval => 'FREQ=DAILY;INTERVAL=1;BYDAY=SAT,SUN');
-- Combined schedule for all federal holidays
DBMS_SCHEDULER.CREATE_SCHEDULE(schedule_name => 'FEDERAL_HOLIDAYS', repeat_interval => 'FREQ=DAILY;INTERSECT=CHRISTMAS,INDEPENDENCE_DAY,MARTIN_LUTHER_KING_DAY,MEMORIAL_DAY,NEW_YEARS_DAY,THANKSGIVING,WASHINGTONS_BIRTHDAY');
END;
/
Have a look at Calendaring Syntax to see how repeat_interval needs to be specified.
Then you can use procedure DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING to get your date:
CREATE OR REPLACE FUNCTION LAST_BUSINESS_DAY(today IN TIMESTAMP DEFAULT SYSTIMESTAMP) RETURN TIMESTAMP AS
return_date_after TIMESTAMP := TRUNC(today);
next_run_date TIMESTAMP;
BEGIN
LOOP
DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING('FREQ=DAILY;INTERVAL=1;EXCLUDE=FEDERAL_HOLIDAYS,WEEKEND', NULL, return_date_after, next_run_date);
EXIT WHEN next_run_date >= LAST_DAY(TRUNC(today));
return_date_after := next_run_date;
END LOOP;
RETURN return_date_after;
END LAST_BUSINESS_DAY;
How to write query to send notifications when user package expired after 3 days in Yii?
For example, account expired on 25th Dec, then send expired email on 26th, 27th and 28th Dec.
$expireddate = date('Y-m-d', strtotime('-3 days')); // (Coming from db)
$model = TblPackageUserplan::model()->findAll('expire_date>=:expire_date', array(':expire_date' => $expireddate));
It's not working correct, because its sending mail before 20th Dec, too.
I want to send mail exactly user package expired after 3 days. How to get user details package expired after 3 days?
You may use only criteria.
As of your question
expired on 25th Dec, then send expired email on 26th, 27th and 28th Dec
You need to compare expire_date + 3days.
$criteria = new CDbCriteria;
// With this condition we get only packages on next three days after expire_date.
$criteria->addCondition('DATEDIFF(CURRENT_DATE(),t.expire_date) BETWEEN 1 AND 3');
I have an urgent need to know the specific code for UPS Standard shipping within Shopify's API. It would be a 2-digit number found in the Order API, shipping-lines > shipping-line > code.
Thanks for any assistance.
UPS Standart code value is '11'
Also some other UPS codes:
'01' => 'Next Day Air ("Red")',
'02' => 'Second Day Air ("Blue")',
'03' => 'Ground',
'07' => 'Express',
'08' => 'Expedited',
'11' => 'Standard',
'12' => 'Third Day Select',
'13' => 'Next Day Air Saver ("Red Saver")',
'14' => 'Next Day Air Early A.M.',
'15' => 'Next Day Air Early A.M.',
'22' => 'Ground - Returns Plus - Three Pickup Attempts',
'32' => 'Next Day Air Early A.M. - COD',
'33' => 'Next Day Air Early A.M. - Saturday Delivery, COD',
'41' => 'Next Day Air Early A.M. - Saturday Delivery',
'42' => 'Ground - Signature Required',
'44' => 'Next Day Air - Saturday Delivery',
'54' => 'Express Plus',
'59' => 'Second Day Air A.M.',
'65' => 'WorldWide Saver',
'66' => 'Worldwide Express',
'72' => 'Ground - Collect on Delivery',
'78' => 'Ground - Returns Plus - One Pickup Attempt',
'90' => 'Ground - Returns - UPS Prints and Mails Label',
'A0' => 'Next Day Air Early A.M. - Adult Signature Required',
'A1' => 'Next Day Air Early A.M. - Saturday Delivery, Adult Signature Required',
'A2' => 'Next Day Air - Adult Signature Required',
'A8' => 'Ground - Adult Signature Required',
'A9' => 'Next Day Air Early A.M. - Adult Signature Required, COD',
'AA' => 'Next Day Air Early A.M. - Saturday Delivery, Adult Signature Required, COD',
If you download the UPS shipping developer documentation, there are no longer any codes for 'Saturday' delivery in the Appendix or elsewhere. Instead you use the service you want, say 'Next Day Air' or 'Next Day Air Early AM' would be the common ones along with the SaturdayDeliveryIndicator. From their documentation:
Saturday delivery indicator. The presence indicates Saturday delivery;
the absence indicates not Saturday delivery.
There are several ways:
in magento admin go to system > configuration and click on shipping methods tab and rightclick inside of the Allowed Methods box, Inpect the element and you'll see something like UPS Standard value represents the method code.
or open app/code/core/Mage/Usa/Model/Shipping/Carrier/Ups.php and around the line 327 you will see all shipping methods with corresponding codes.